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 a bug about gesture #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
18 changes: 13 additions & 5 deletions ptr-lib/src/in/srain/cube/views/ptr/PtrFrameLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class PtrFrameLayout extends ViewGroup {
private long mLoadingStartTime = 0;
private PtrIndicator mPtrIndicator;
private boolean mHasSendCancelEvent = false;
private boolean isCanNotMove=false;

public PtrFrameLayout(Context context) {
this(context, null);
Expand Down Expand Up @@ -261,6 +262,7 @@ public boolean dispatchTouchEvent(MotionEvent e) {
switch (action) {
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
isCanNotMove=false;
mPtrIndicator.onRelease();
if (mPtrIndicator.hasLeftStartPosition()) {
if (DEBUG) {
Expand All @@ -278,6 +280,7 @@ public boolean dispatchTouchEvent(MotionEvent e) {

case MotionEvent.ACTION_DOWN:
mHasSendCancelEvent = false;
isCanNotMove=false;
mPtrIndicator.onPressDown(e.getX(), e.getY());

mScrollChecker.abortIfWorking();
Expand All @@ -301,7 +304,8 @@ public boolean dispatchTouchEvent(MotionEvent e) {
}
}
if (mPreventForHorizontal) {
return dispatchTouchEventSupper(e);
isCanNotMove=dispatchTouchEventSupper(e)
return isCanNotMove;
}

boolean moveDown = offsetY > 0;
Expand All @@ -312,13 +316,17 @@ public boolean dispatchTouchEvent(MotionEvent e) {
boolean canMoveDown = mPtrHandler != null && mPtrHandler.checkCanDoRefresh(this, mContent, mHeaderView);
PtrCLog.v(LOG_TAG, "ACTION_MOVE: offsetY:%s, currentPos: %s, moveUp: %s, canMoveUp: %s, moveDown: %s: canMoveDown: %s", offsetY, mPtrIndicator.getCurrentPosY(), moveUp, canMoveUp, moveDown, canMoveDown);
}

// disable move when header not reach top
if (moveDown && mPtrHandler != null && !mPtrHandler.checkCanDoRefresh(this, mContent, mHeaderView)) {
return dispatchTouchEventSupper(e);
isCanNotMove=dispatchTouchEventSupper(e)
return isCanNotMove;
}

if ((moveUp && canMoveUp) || moveDown) {
if(Math.abs(offsetX)>Math.abs(offsetY)){
isCanNotMove =dispatchTouchEventSupper(e);
return isCanNotMove;
}
if (((moveUp && canMoveUp) || moveDown)&&!isCanNotMove) {
movePos(offsetY);
return true;
}
Expand Down