Skip to content
This repository was archived by the owner on Jul 22, 2019. It is now read-only.
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
10 changes: 8 additions & 2 deletions library/src/main/java/link/fls/swipestack/SwipeHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public boolean onTouch(View v, MotionEvent event) {

switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if(!mListenForTouchEvents || !mSwipeStack.isEnabled()) {
if (!mListenForTouchEvents || !mSwipeStack.isEnabled()) {
return false;
}

Expand Down Expand Up @@ -92,6 +92,12 @@ public boolean onTouch(View v, MotionEvent event) {
return true;

case MotionEvent.ACTION_UP:
dx = event.getX() - mDownX;
dy = event.getY() - mDownY;
if (Math.abs(dx + dy) <= SwipeStack.CLICK_DISTANCE_THRESHOLD) {
v.performClick();
}

v.getParent().requestDisallowInterceptTouchEvent(false);
mSwipeStack.onSwipeEnd();
checkViewPosition();
Expand All @@ -104,7 +110,7 @@ public boolean onTouch(View v, MotionEvent event) {
}

private void checkViewPosition() {
if(!mSwipeStack.isEnabled()) {
if (!mSwipeStack.isEnabled()) {
resetViewPosition();
return;
}
Expand Down
1 change: 1 addition & 0 deletions library/src/main/java/link/fls/swipestack/SwipeStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class SwipeStack extends ViewGroup {
public static final float DEFAULT_SWIPE_OPACITY = 1f;
public static final float DEFAULT_SCALE_FACTOR = 1f;
public static final boolean DEFAULT_DISABLE_HW_ACCELERATION = true;
public static final float CLICK_DISTANCE_THRESHOLD = 0;

private static final String KEY_SUPER_STATE = "superState";
private static final String KEY_CURRENT_INDEX = "currentIndex";
Expand Down