添加边界提示控制
This commit is contained in:
1 parent
748c5cb812
commit
a7a3d56c91
2 files changed
+10
-5
No files matched your search
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user