@@ -39,6 +39,9 @@ public class SwipeHelper implements View.OnTouchListener {
3939 private float mOpacityEnd = SwipeStack .DEFAULT_SWIPE_OPACITY ;
4040 private int mAnimationDuration = SwipeStack .DEFAULT_ANIMATION_DURATION ;
4141
42+ private boolean isClick = true ;
43+
44+
4245 public SwipeHelper (SwipeStack swipeStack ) {
4346 mSwipeStack = swipeStack ;
4447 }
@@ -48,7 +51,9 @@ public boolean onTouch(View v, MotionEvent event) {
4851
4952 switch (event .getAction ()) {
5053 case MotionEvent .ACTION_DOWN :
51- if (!mListenForTouchEvents || !mSwipeStack .isEnabled ()) {
54+ isClick = true ;
55+
56+ if (!mListenForTouchEvents || !mSwipeStack .isEnabled ()) {
5257 return false ;
5358 }
5459
@@ -67,6 +72,8 @@ public boolean onTouch(View v, MotionEvent event) {
6772 float dx = event .getX (pointerIndex ) - mDownX ;
6873 float dy = event .getY (pointerIndex ) - mDownY ;
6974
75+ isClick = Math .abs (dx + dy ) < SwipeStack .CLICK_DISTANCE_THRESHOLD ;
76+
7077 float newX = mObservedView .getX () + dx ;
7178 float newY = mObservedView .getY () + dy ;
7279
@@ -92,6 +99,10 @@ public boolean onTouch(View v, MotionEvent event) {
9299 return true ;
93100
94101 case MotionEvent .ACTION_UP :
102+ if (isClick ) {
103+ v .performClick ();
104+ }
105+
95106 v .getParent ().requestDisallowInterceptTouchEvent (false );
96107 mSwipeStack .onSwipeEnd ();
97108 checkViewPosition ();
@@ -104,7 +115,7 @@ public boolean onTouch(View v, MotionEvent event) {
104115 }
105116
106117 private void checkViewPosition () {
107- if (!mSwipeStack .isEnabled ()) {
118+ if (!mSwipeStack .isEnabled ()) {
108119 resetViewPosition ();
109120 return ;
110121 }
0 commit comments