Skip to content

Commit

Permalink
fixing bug with directions view not toggling on older devices
Browse files Browse the repository at this point in the history
  • Loading branch information
lucky-bai committed Aug 1, 2014
1 parent cfbbea6 commit 277c5df
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ public class DirectionsView extends LinearLayout implements OnClickListener {
CharSequence directions_long = "";
CharSequence directions_collapsed = "";


// What is the textview showing?
static final int STATE_NONE = 1; // not showing a route
static final int STATE_COLLAPSED = 2; // collapsed form
static final int STATE_LONG = 3; // long form
int current_state = STATE_NONE;


public DirectionsView(Context context, AttributeSet attrs) {
super(context, attrs);
Expand All @@ -39,19 +46,21 @@ public DirectionsView(Context context, AttributeSet attrs) {

public void setText(CharSequence text){
textview.setText(text);
current_state = STATE_NONE;
}


@Override
public void onClick(View v) {

// Flip between long and collapsed directions
CharSequence cur = textview.getText();
if(cur.equals(directions_long)){
textview.setText(directions_collapsed);
}
else if(cur.equals(directions_collapsed)){
if(current_state == STATE_COLLAPSED){
textview.setText(directions_long);
current_state = STATE_LONG;
}
else if(current_state == STATE_LONG){
textview.setText(directions_collapsed);
current_state = STATE_COLLAPSED;
}

}
Expand Down Expand Up @@ -147,6 +156,7 @@ else if(step.getPathType() == Path.TYPE_STAIR){
// Long directions
directions_long = Html.fromHtml("[<tt>-</tt>] " + sb.toString());
setText(directions_long);
current_state = STATE_LONG;
}

}

0 comments on commit 277c5df

Please sign in to comment.