From eb4502e0324df9309b1303408496df7f15fc4ad6 Mon Sep 17 00:00:00 2001 From: Wu Chikin Date: Mon, 27 Nov 2017 12:15:15 +0800 Subject: [PATCH 1/2] Update SwipeStack.java Add a method callled when a view has been clicked,in the SwipeStackListener. --- .../src/main/java/link/fls/swipestack/SwipeStack.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/src/main/java/link/fls/swipestack/SwipeStack.java b/library/src/main/java/link/fls/swipestack/SwipeStack.java index 175e28d..78461d3 100644 --- a/library/src/main/java/link/fls/swipestack/SwipeStack.java +++ b/library/src/main/java/link/fls/swipestack/SwipeStack.java @@ -300,6 +300,10 @@ public void onSwipeEnd() { if (mProgressListener != null) mProgressListener.onSwipeEnd(getCurrentPosition()); } + public void onViewClicked() { + if (mListener != null) mListener.onViewClicked(getCurrentPosition()); + } + public void onViewSwipedToLeft() { if (mListener != null) mListener.onViewSwipedToLeft(getCurrentPosition()); removeTopView(); @@ -420,6 +424,13 @@ public void resetStack() { * swiped to the left / right or when the stack gets empty. */ public interface SwipeStackListener { + /** + * Called when a view has been clicked. + * + * @param position The position of the view in the adapter currently in use. + */ + void onViewClicked(int position); + /** * Called when a view has been dismissed to the left. * From e49df9863134ea0f5febbeab4008ae216ef345c0 Mon Sep 17 00:00:00 2001 From: Wu Chikin Date: Mon, 27 Nov 2017 12:17:39 +0800 Subject: [PATCH 2/2] Update SwipeHelper.java Reset listener in method resetViewPosition(). --- library/src/main/java/link/fls/swipestack/SwipeHelper.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/link/fls/swipestack/SwipeHelper.java b/library/src/main/java/link/fls/swipestack/SwipeHelper.java index 43b7b72..64e45ad 100644 --- a/library/src/main/java/link/fls/swipestack/SwipeHelper.java +++ b/library/src/main/java/link/fls/swipestack/SwipeHelper.java @@ -132,7 +132,12 @@ private void resetViewPosition() { .alpha(1) .setDuration(mAnimationDuration) .setInterpolator(new OvershootInterpolator(1.4f)) - .setListener(null); + .setListener(new AnimationUtils.AnimationEndListener() { + @Override + public void onAnimationEnd(Animator animation) { + mSwipeStack.onViewClicked(); + } + }); } private void swipeViewToLeft(int duration) {