mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
animation refactoring (in progress)
This commit is contained in:
parent
e7ca10f8d9
commit
3074f93d8d
1 changed files with 13 additions and 11 deletions
|
@ -54,7 +54,6 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
private boolean myScrollHorizontally;
|
private boolean myScrollHorizontally;
|
||||||
|
|
||||||
private float myScrollingSpeed;
|
private float myScrollingSpeed;
|
||||||
private int myScrollingBound;
|
|
||||||
|
|
||||||
public ZLAndroidWidget(Context context, AttributeSet attrs, int defStyle) {
|
public ZLAndroidWidget(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
|
@ -165,21 +164,27 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
} else {
|
} else {
|
||||||
myEndY += (int)myScrollingSpeed;
|
myEndY += (int)myScrollingSpeed;
|
||||||
}
|
}
|
||||||
if (myScrollingSpeed > 0) {
|
final int bound;
|
||||||
if (getAnimationProvider().getScrollingShift() >= myScrollingBound) {
|
if (myScrollingState == ScrollingState.AutoScrollingForward) {
|
||||||
if (myScrollHorizontally) {
|
bound = myScrollHorizontally ? getWidth() : getMainAreaHeight();
|
||||||
myEndX = myStartX + myScrollingBound;
|
|
||||||
} else {
|
} else {
|
||||||
myEndY = myStartY + myScrollingBound;
|
bound = 0;
|
||||||
|
}
|
||||||
|
if (myScrollingSpeed > 0) {
|
||||||
|
if (getAnimationProvider().getScrollingShift() >= bound) {
|
||||||
|
if (myScrollHorizontally) {
|
||||||
|
myEndX = myStartX + bound;
|
||||||
|
} else {
|
||||||
|
myEndY = myStartY + bound;
|
||||||
}
|
}
|
||||||
doStopScrolling = true;
|
doStopScrolling = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (getAnimationProvider().getScrollingShift() <= myScrollingBound) {
|
if (getAnimationProvider().getScrollingShift() <= -bound) {
|
||||||
if (myScrollHorizontally) {
|
if (myScrollHorizontally) {
|
||||||
myEndX = myStartX + myScrollingBound;
|
myEndX = myStartX - bound;
|
||||||
} else {
|
} else {
|
||||||
myEndY = myStartY + myScrollingBound;
|
myEndY = myStartY - bound;
|
||||||
}
|
}
|
||||||
doStopScrolling = true;
|
doStopScrolling = true;
|
||||||
}
|
}
|
||||||
|
@ -188,7 +193,7 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doStopScrolling) {
|
if (doStopScrolling) {
|
||||||
if (myScrollingBound != 0) {
|
if (myScrollingState != ScrollingState.AutoScrollingBackward) {
|
||||||
Bitmap swap = myMainBitmap;
|
Bitmap swap = myMainBitmap;
|
||||||
myMainBitmap = mySecondaryBitmap;
|
myMainBitmap = mySecondaryBitmap;
|
||||||
mySecondaryBitmap = swap;
|
mySecondaryBitmap = swap;
|
||||||
|
@ -284,18 +289,15 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
myScrollingSpeed = 3;
|
myScrollingSpeed = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
myScrollingBound = 0;
|
|
||||||
break;
|
break;
|
||||||
case previous:
|
case previous:
|
||||||
myScrollingState = ScrollingState.AutoScrollingForward;
|
myScrollingState = ScrollingState.AutoScrollingForward;
|
||||||
myScrollingSpeed = 3;
|
myScrollingSpeed = 3;
|
||||||
myScrollingBound = horizontally ? getWidth() : getMainAreaHeight();
|
|
||||||
setPageToScrollTo(pageIndex);
|
setPageToScrollTo(pageIndex);
|
||||||
break;
|
break;
|
||||||
case next:
|
case next:
|
||||||
myScrollingState = ScrollingState.AutoScrollingForward;
|
myScrollingState = ScrollingState.AutoScrollingForward;
|
||||||
myScrollingSpeed = -3;
|
myScrollingSpeed = -3;
|
||||||
myScrollingBound = horizontally ? -getWidth() : -getMainAreaHeight();
|
|
||||||
setPageToScrollTo(pageIndex);
|
setPageToScrollTo(pageIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue