Skip to content

Commit

Permalink
Fixes #7
Browse files Browse the repository at this point in the history
Permanently listen for direction changes
Only cancel the listview onTouch once
Reset far boolean when direction changes
Bumped version number
  • Loading branch information
wdullaer committed Jan 2, 2015
1 parent 35cc3a5 commit 34962dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

VERSION_NAME=1.3.0
VERSION_CODE=5
VERSION_NAME=1.3.1
VERSION_CODE=6
GROUP=com.wdullaer

ANDROID_BUILD_MIN_SDK_VERSION=14
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,10 @@ public void onAnimationEnd(Animator animation) {
mVelocityTracker.addMovement(motionEvent);
float deltaX = motionEvent.getRawX() - mDownX;
float deltaY = motionEvent.getRawY() - mDownY;
if (Math.abs(deltaX) > mSlop && Math.abs(deltaY) < Math.abs(deltaX) / 2) {
if (!mSwiping && Math.abs(deltaX) > mSlop && Math.abs(deltaY) < Math.abs(deltaX) / 2) {
mSwiping = true;
mSwipingSlop = (deltaX > 0 ? mSlop : -mSlop);

if(!mFar && Math.abs(deltaX) > mViewWidth/2) mFar = true;
if(!mFar) mDirection = (deltaX > 0 ? SwipeDirections.DIRECTION_NORMAL_RIGHT : SwipeDirections.DIRECTION_NORMAL_LEFT);
else mDirection = (deltaX > 0 ? SwipeDirections.DIRECTION_FAR_RIGHT : SwipeDirections.DIRECTION_FAR_LEFT);
mDownViewGroup.showBackground(mDirection);

mListView.requestDisallowInterceptTouchEvent(true);

// Cancel ListView's touch (un-highlighting the item)
Expand All @@ -376,6 +371,12 @@ public void onAnimationEnd(Animator animation) {
}

if (mSwiping) {
if(mDirection*deltaX < 0) mFar = false;
if(!mFar && Math.abs(deltaX) > mViewWidth/2) mFar = true;
if(!mFar) mDirection = (deltaX > 0 ? SwipeDirections.DIRECTION_NORMAL_RIGHT : SwipeDirections.DIRECTION_NORMAL_LEFT);
else mDirection = (deltaX > 0 ? SwipeDirections.DIRECTION_FAR_RIGHT : SwipeDirections.DIRECTION_FAR_LEFT);
mDownViewGroup.showBackground(mDirection);

mDownView.setTranslationX(deltaX - mSwipingSlop);
if(mFadeOut) mDownView.setAlpha(Math.max(0f, Math.min(1f,
1f - 2f * Math.abs(deltaX) / mViewWidth)));
Expand Down

0 comments on commit 34962dc

Please sign in to comment.