Skip to content

Commit

Permalink
Fix #125
Browse files Browse the repository at this point in the history
Fixed swiping issues
  • Loading branch information
daniel-stoneuk committed Sep 6, 2016
1 parent 7d371cc commit 2bb3fc3
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.Context;
import android.support.annotation.IntDef;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
Expand Down Expand Up @@ -61,15 +60,15 @@ public boolean onInterceptTouchEvent(MotionEvent event) {
private boolean handleTouchEvent(MotionEvent event) {
if (getSwipeDirection(event) == SWIPE_DIRECTION_RIGHT && !swipeRightEnabled) {
if (!locked) {
updatePosition();
locked = true;
updatePosition();
}
return false;
}
else if (getSwipeDirection(event) == SWIPE_DIRECTION_LEFT && !swipeLeftEnabled) {
if (!locked) {
updatePosition();
locked = true;
updatePosition();
}
return false;
}
Expand All @@ -80,10 +79,6 @@ else if (getSwipeDirection(event) == SWIPE_DIRECTION_LEFT && !swipeLeftEnabled)
private void updatePosition() {
int currentItem = getCurrentItem();
scrollTo(currentItem * getWidth(), getScrollY());
PagerAdapter adapter = getAdapter();
if (adapter != null) {
adapter.notifyDataSetChanged();
}
setCurrentItem(currentItem);
}

Expand All @@ -103,7 +98,7 @@ public int getSwipeDirection(MotionEvent event) {
}
if (distanceX > 0) {
return SWIPE_DIRECTION_RIGHT;
} else {
} else if (distanceX < 0) {
return SWIPE_DIRECTION_LEFT;
}
}
Expand Down

0 comments on commit 2bb3fc3

Please sign in to comment.