diff --git a/src/com/hippo/ehviewer/gallery/GalleryView.java b/src/com/hippo/ehviewer/gallery/GalleryView.java index 4b94e608d..a36f0330f 100644 --- a/src/com/hippo/ehviewer/gallery/GalleryView.java +++ b/src/com/hippo/ehviewer/gallery/GalleryView.java @@ -94,6 +94,7 @@ public class GalleryView extends GLView private static final float MILLSEC_PER_DIX = 0.2f; private static final float CHANGE_PAGE_PROPORTION = 0.1f; private static final float SLIDE_SENSITIVITY = 0; + private static final float BORDER_TIP_SENSITIVITY = Ui.dp2pix(48); private static final int ANIMATE_MIN = 200; @@ -1224,7 +1225,7 @@ public class GalleryView extends GLView } @Override - public boolean onScrollEnd() { + public boolean onScrollEnd(float totalX, float totalY) { if (isScale) return false; @@ -1264,7 +1265,7 @@ public class GalleryView extends GLView break; case SCROLL_NONE: ShowItem showItem = showItems[CUR_TARGET_INDEX]; - if (showItem != null) { + if (showItem != null && Math.abs(totalX) - BORDER_TIP_SENSITIVITY > 0) { if (isFirstPage() && showItem.mRect.left >= 0) MaterialToast.showToast(mContext.getString(R.string.first_page)); else if (isLastPage() && showItem.mRect.right <= mScreenWidth) diff --git a/src/com/hippo/ehviewer/gallery/ui/GestureRecognizer.java b/src/com/hippo/ehviewer/gallery/ui/GestureRecognizer.java index 9bf3c2dcd..68bee58fb 100644 --- a/src/com/hippo/ehviewer/gallery/ui/GestureRecognizer.java +++ b/src/com/hippo/ehviewer/gallery/ui/GestureRecognizer.java @@ -35,7 +35,7 @@ public class GestureRecognizer { void onLongPress(MotionEvent e); boolean onScrollBegin(float dx, float dy, float totalX, float totalY); boolean onScroll(float dx, float dy, float totalX, float totalY); - boolean onScrollEnd(); + boolean onScrollEnd(float totalX, float totalY); boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY); boolean onScaleBegin(float focusX, float focusY); boolean onScale(float focusX, float focusY, float scale); @@ -149,9 +149,13 @@ public class GestureRecognizer { } private class MyDownUpListener implements DownUpDetector.DownUpListener { + + private float mFirstX; + private float mFirstY; + @Override public void onDown(MotionEvent e) { - mListener.onDown(e.getX(), e.getY()); + mListener.onDown(mFirstX = e.getX(), mFirstY = e.getY()); } @Override @@ -159,7 +163,7 @@ public class GestureRecognizer { mListener.onUp(); if (mStillScroll) { mStillScroll = false; - mListener.onScrollEnd(); + mListener.onScrollEnd(e.getX() - mFirstX, e.getY() - mFirstY); } } }