Skip to content

Commit

Permalink
Merge pull request #128 from daniel-stoneuk/master
Browse files Browse the repository at this point in the history
Fix #125
  • Loading branch information
janheinrichmerker authored Sep 6, 2016
2 parents 7d371cc + 2bb3fc3 commit fd9f568
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 fd9f568

Please sign in to comment.