From a7a3d56c917093a98ebe7de70fd1bb33f372099f Mon Sep 17 00:00:00 2001 From: seven332 Date: Wed, 8 Oct 2014 23:22:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BE=B9=E7=95=8C=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/hippo/ehviewer/gallery/GalleryView.java | 5 +++-- .../hippo/ehviewer/gallery/ui/GestureRecognizer.java | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) 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); } } }