Skip to content

Instantly share code, notes, and snippets.

@enginebai
Created November 20, 2016 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enginebai/7c3f9affdadeb7cffd33f043b3c95cc6 to your computer and use it in GitHub Desktop.
Save enginebai/7c3f9affdadeb7cffd33f043b3c95cc6 to your computer and use it in GitHub Desktop.
@Override
public boolean onTouchEvent(MotionEvent event) {
if (mEnabled) {
this.getParent().requestDisallowInterceptTouchEvent(true);
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (mOnSwagPointsChangeListener != null)
mOnSwagPointsChangeListener.onStartTrackingTouch(this);
updateOnTouch(event);
break;
case MotionEvent.ACTION_MOVE:
updateOnTouch(event);
break;
case MotionEvent.ACTION_UP:
if (mOnSwagPointsChangeListener != null)
mOnSwagPointsChangeListener.onStopTrackingTouch(this);
setPressed(false);
this.getParent().requestDisallowInterceptTouchEvent(false);
break;
case MotionEvent.ACTION_CANCEL:
if (mOnSwagPointsChangeListener != null)
mOnSwagPointsChangeListener.onStopTrackingTouch(this);
setPressed(false);
this.getParent().requestDisallowInterceptTouchEvent(false);
break;
}
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment