Skip to content

Commit

Permalink
Use existed suppressFlingGesture() method in RangeWidget (getodk#1371)
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 authored and lognaturel committed Aug 23, 2017
1 parent ceaefe8 commit f546c2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ public class FormEntryActivity extends AppCompatActivity implements AnimationLis
private static final int SAVING_IMAGE_DIALOG = 3;

private boolean autoSaved;
private boolean doSwipe = true;

// Random ID
private static final int DELETE_REPEAT = 654321;
Expand Down Expand Up @@ -2818,7 +2817,7 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
PreferenceKeys.KEY_NAVIGATION,
PreferenceKeys.NAVIGATION_SWIPE);

if (navigation.contains(PreferenceKeys.NAVIGATION_SWIPE) && doSwipe) {
if (navigation.contains(PreferenceKeys.NAVIGATION_SWIPE)) {
// Looks for user swipes. If the user has swiped, move to the
// appropriate screen.

Expand Down Expand Up @@ -2954,8 +2953,4 @@ public EmptyView(Context context) {
super(context);
}
}

public void allowSwiping(boolean doSwipe) {
this.doSwipe = doSwipe;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public abstract class RangeWidget extends QuestionWidget {
private View view;

private boolean isPickerAppearance;
private boolean suppressFlingGesture;

private Button pickerButton;
private TextView answerTextView;
Expand Down Expand Up @@ -98,6 +99,11 @@ public void setOnLongClickListener(OnLongClickListener l) {
}
}

@Override
public boolean suppressFlingGesture(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
return suppressFlingGesture;
}

private void setUpLayoutElements() {
if (!isPickerAppearance) {
TextView minValue = (TextView) view.findViewById(R.id.min_value);
Expand Down Expand Up @@ -160,12 +166,12 @@ private void setUpSeekBar() {
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
((FormEntryActivity) getContext()).allowSwiping(true);
suppressFlingGesture = false;
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {
((FormEntryActivity) getContext()).allowSwiping(false);
suppressFlingGesture = true;
}

@Override
Expand Down

0 comments on commit f546c2e

Please sign in to comment.