We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
`private static final int CLICK_THRESHOLD = 5; // 定义点击的阈值,单位是像素
@Override public boolean onTouch(View v, MotionEvent event) { float x = event.getX(); float y = event.getY(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: mDownX = event.getX(); mDownY = event.getY(); mFirstY = Math.round(event.getRawY()); mFirstX = Math.round(event.getRawX()); mHandler.removeCallbacksAndMessages(mRunnable); resetStatus(); isMove = false; // 重置移动标志 break; case MotionEvent.ACTION_MOVE: float deltaX = Math.abs(x - mDownX); float deltaY = Math.abs(y - mDownY); if (deltaX > CLICK_THRESHOLD || deltaY > CLICK_THRESHOLD) { isMove = true; offsetTopAndBottom((int) (y - mDownY)); offsetLeftAndRight((int) (x - mDownX)); } break; case MotionEvent.ACTION_UP: if (!isMove) { // 如果没有移动,则认为是点击 if (mOnFloatClickListener != null) { mOnFloatClickListener.onClick(v); } } else { // 如果移动了,则执行吸边逻辑 if (getAdsorbType() == ADSORB_VERTICAL) { adsorbTopAndBottom(event); } else if (getAdsorbType() == ADSORB_HORIZONTAL) { adsorbLeftAndRight(event); } } if (getAdsorbTime() > 0) { mHandler.postDelayed(mRunnable, getAdsorbTime()); } break; } return getIsCanDrag(); }`
原代码只有在贴吧的情况下会响应点击回调。 这样增加后,会在不贴边的情况下,响应点击回调。
The text was updated successfully, but these errors were encountered:
No branches or pull requests
`private static final int CLICK_THRESHOLD = 5; // 定义点击的阈值,单位是像素
原代码只有在贴吧的情况下会响应点击回调。
这样增加后,会在不贴边的情况下,响应点击回调。
The text was updated successfully, but these errors were encountered: