Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
additional fix when flipping from right to left
Browse files Browse the repository at this point in the history
  • Loading branch information
siegfriedpammer committed Jan 2, 2013
1 parent b7eb257 commit 2622d34
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions FlipView/FlipLibrary/src/com/aphidmobile/flip/FlipCards.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,12 @@ public void invalidateTexture() {
backCards.abandonTexture();
}

private int lastPageIndex;
private boolean alreadyFlipped;

public synchronized boolean handleTouchEvent(MotionEvent event, boolean isOnTouchEvent) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
// remember page we started on...
lastPageIndex = getPageIndexFromAngle(accumulatedAngle);
alreadyFlipped = false;
lastPosition = orientationVertical ? event.getY() : event.getX();
return isOnTouchEvent;
case MotionEvent.ACTION_MOVE:
Expand All @@ -268,7 +267,7 @@ public synchronized boolean handleTouchEvent(MotionEvent event, boolean isOnTouc
angleDelta = Math.signum(angleDelta) * MAX_TOUCH_MOVE_ANGLE;

// do not flip more than one page with one touch...
if (Math.abs(getPageIndexFromAngle(accumulatedAngle + angleDelta) - lastPageIndex) <= 1) {
if (!alreadyFlipped) {
accumulatedAngle += angleDelta;
}

Expand All @@ -287,10 +286,12 @@ public synchronized boolean handleTouchEvent(MotionEvent event, boolean isOnTouc
swapCards(); //frontCards becomes the backCards
frontCards.resetWithIndex(backCards.getIndex() - 1);
controller.flippedToView(anglePageIndex, false);
alreadyFlipped = true;
} else if (anglePageIndex == frontCards.getIndex() + 1) { //moved to next page
swapCards();
backCards.resetWithIndex(frontCards.getIndex() + 1);
controller.flippedToView(anglePageIndex, false);
alreadyFlipped = true;
} else
throw new RuntimeException(AphidLog.format("Inconsistent states: anglePageIndex: %d, accumulatedAngle %.1f, frontCards %d, backCards %d", anglePageIndex, accumulatedAngle, frontCards.getIndex(), backCards.getIndex()));
}
Expand Down

0 comments on commit 2622d34

Please sign in to comment.