Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #125 #128

Merged
merged 1 commit into from
Sep 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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