Skip to content

LongClick #36

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -52,6 +52,8 @@ public void onBindViewHolder(final FullDelDemoVH holder, final int position) {
public boolean onLongClick(View v) {
Toast.makeText(mContext, "longclig", Toast.LENGTH_SHORT).show();
Log.d("TAG", "onLongClick() called with: v = [" + v + "]");
((SwipeMenuLayout) holder.itemView).setSwipeEnable(false);
// SwipeMenuLayout.resetIsTouching(); by [email protected]
return false;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,38 +342,41 @@ public boolean dispatchTouchEvent(MotionEvent ev) {
if (iosInterceptFlag) {
break;
}
float gap = mLastP.x - ev.getRawX();
//为了在水平滑动中禁止父类ListView等再竖直滑动
if (Math.abs(gap) > 10 || Math.abs(getScrollX()) > 10) {//2016 09 29 修改此处,使屏蔽父布局滑动更加灵敏,
getParent().requestDisallowInterceptTouchEvent(true);
}
//2016 10 22 add , 仿QQ,侧滑菜单展开时,点击内容区域,关闭侧滑菜单。begin
if (Math.abs(gap) > mScaleTouchSlop) {
isUnMoved = false;
}
//2016 10 22 add , 仿QQ,侧滑菜单展开时,点击内容区域,关闭侧滑菜单。end
//如果scroller还没有滑动结束 停止滑动动画
/* if (!mScroller.isFinished()) {
mScroller.abortAnimation();
}*/
scrollBy((int) (gap), 0);//滑动使用scrollBy
//越界修正
if (isLeftSwipe) {//左滑
if (getScrollX() < 0) {
scrollTo(0, 0);
float gapX = mLastP.x - ev.getRawX();
float gapY = mLastP.y - ev.getRawy();
// Make sure scroll on X distance
if (Math.abs(gapX) > Math.abs(gapY)) {
//为了在水平滑动中禁止父类ListView等再竖直滑动
if (Math.abs(gapX) > 10 || Math.abs(getScrollX()) > 10) {//2016 09 29 修改此处,使屏蔽父布局滑动更加灵敏,
getParent().requestDisallowInterceptTouchEvent(true);
}
if (getScrollX() > mRightMenuWidths) {
scrollTo(mRightMenuWidths, 0);
//2016 10 22 add , 仿QQ,侧滑菜单展开时,点击内容区域,关闭侧滑菜单。begin
if (Math.abs(gapX) > mScaleTouchSlop) {
isUnMoved = false;
}
} else {//右滑
if (getScrollX() < -mRightMenuWidths) {
scrollTo(-mRightMenuWidths, 0);
}
if (getScrollX() > 0) {
scrollTo(0, 0);
//2016 10 22 add , 仿QQ,侧滑菜单展开时,点击内容区域,关闭侧滑菜单。end
//如果scroller还没有滑动结束 停止滑动动画
/* if (!mScroller.isFinished()) {
mScroller.abortAnimation();
}*/
scrollBy((int) (gapX), 0);//滑动使用scrollBy
//越界修正
if (isLeftSwipe) {//左滑
if (getScrollX() < 0) {
scrollTo(0, 0);
}
if (getScrollX() > mRightMenuWidths) {
scrollTo(mRightMenuWidths, 0);
}
} else {//右滑
if (getScrollX() < -mRightMenuWidths) {
scrollTo(-mRightMenuWidths, 0);
}
if (getScrollX() > 0) {
scrollTo(0, 0);
}
}
}

mLastP.set(ev.getRawX(), ev.getRawY());
break;
case MotionEvent.ACTION_UP:
Expand Down Expand Up @@ -645,4 +648,13 @@ public void quickClose() {
}
}

/**
* If setSwipeEnable false before ACTION_DOWN/ACTION_CANCEL,
* this ACTION_DOWN/ACTION_CANCEL will interceptTouchEvent by mIsSwipeEnable(false),
* such as when onLongCLick, setSwipeEnable false.
*/
public static void resetIsTouching() {
isTouching = false;
}

}