mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
more configurable animation providers
This commit is contained in:
parent
e1ec594d9d
commit
101148db9e
7 changed files with 41 additions and 23 deletions
|
@ -62,12 +62,23 @@ abstract class AnimationProvider {
|
|||
mySpeed = 0;
|
||||
}
|
||||
|
||||
void startManualScrolling(int startX, int startY, int endX, int endY, ZLView.Direction direction, int w, int h) {
|
||||
void startManualScrolling(int x, int y, ZLView.Direction direction, int w, int h) {
|
||||
myMode = Mode.ManualScrolling;
|
||||
setup(startX, startY, endX, endY, direction, w, h);
|
||||
setup(x, y, direction, w, h);
|
||||
}
|
||||
|
||||
void startAutoScrolling(boolean forward, float startSpeed, ZLView.Direction direction, int w, int h, Integer x, Integer y, int speed) {
|
||||
void scrollTo(int x, int y) {
|
||||
if (myMode == Mode.ManualScrolling) {
|
||||
myEndX = x;
|
||||
myEndY = y;
|
||||
}
|
||||
}
|
||||
|
||||
final void startAutoScrolling(boolean forward, float startSpeed, ZLView.Direction direction, int w, int h, Integer x, Integer y, int speed) {
|
||||
startAutoScrollingInternal(forward, startSpeed, direction, w, h, x, y, speed);
|
||||
}
|
||||
|
||||
protected void startAutoScrollingInternal(boolean forward, float startSpeed, ZLView.Direction direction, int w, int h, Integer x, Integer y, int speed) {
|
||||
if (!inProgress()) {
|
||||
if (x == null || y == null) {
|
||||
if (direction.IsHorizontal) {
|
||||
|
@ -78,7 +89,7 @@ abstract class AnimationProvider {
|
|||
y = speed < 0 ? h : 0;
|
||||
}
|
||||
}
|
||||
setup(x, y, x, y, direction, w, h);
|
||||
setup(x, y, direction, w, h);
|
||||
}
|
||||
|
||||
myMode = forward
|
||||
|
@ -95,11 +106,11 @@ abstract class AnimationProvider {
|
|||
return myDirection.IsHorizontal ? myEndX - myStartX : myEndY - myStartY;
|
||||
}
|
||||
|
||||
private void setup(int startX, int startY, int endX, int endY, ZLView.Direction direction, int width, int height) {
|
||||
myStartX = startX;
|
||||
myStartY = startY;
|
||||
myEndX = endX;
|
||||
myEndY = endY;
|
||||
private void setup(int x, int y, ZLView.Direction direction, int width, int height) {
|
||||
myStartX = x;
|
||||
myStartY = y;
|
||||
myEndX = x;
|
||||
myEndY = y;
|
||||
myDirection = direction;
|
||||
myWidth = width;
|
||||
myHeight = height;
|
||||
|
@ -113,7 +124,11 @@ abstract class AnimationProvider {
|
|||
return 100 * shift / full;
|
||||
}
|
||||
|
||||
abstract void draw(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap);
|
||||
final void draw(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
||||
drawInternal(canvas, bgBitmap, fgBitmap);
|
||||
}
|
||||
|
||||
protected abstract void drawInternal(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap);
|
||||
|
||||
abstract ZLView.PageIndex getPageToScrollTo();
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class CurlAnimationProvider extends AnimationProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
||||
protected void drawInternal(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
||||
canvas.drawBitmap(bgBitmap, 0, 0, myPaint);
|
||||
|
||||
final int cornerX = myStartX > myWidth / 2 ? myWidth : 0;
|
||||
|
@ -199,7 +199,7 @@ class CurlAnimationProvider extends AnimationProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
void startAutoScrolling(boolean forward, float startSpeed, ZLView.Direction direction, int w, int h, Integer x, Integer y, int speed) {
|
||||
protected void startAutoScrollingInternal(boolean forward, float startSpeed, ZLView.Direction direction, int w, int h, Integer x, Integer y, int speed) {
|
||||
if (x == null || y == null) {
|
||||
if (direction.IsHorizontal) {
|
||||
x = startSpeed < 0 ? w - 3 : 3;
|
||||
|
@ -221,7 +221,7 @@ class CurlAnimationProvider extends AnimationProvider {
|
|||
x = Math.abs(cornerX - deltaX);
|
||||
y = Math.abs(cornerY - deltaY);
|
||||
}
|
||||
super.startAutoScrolling(forward, startSpeed, direction, w, h, x, y, speed);
|
||||
super.startAutoScrollingInternal(forward, startSpeed, direction, w, h, x, y, speed);
|
||||
mySpeedFactor = (float)Math.pow(2.0, 0.25 * speed);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ class NoneAnimationProvider extends SimpleAnimationProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
||||
protected void drawInternal(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
||||
canvas.drawBitmap(fgBitmap, 0, 0, myPaint);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class ShiftAnimationProvider extends SimpleAnimationProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
||||
protected void drawInternal(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
||||
myPaint.setColor(Color.rgb(127, 127, 127));
|
||||
if (myDirection.IsHorizontal) {
|
||||
final int dX = myEndX - myStartX;
|
||||
|
|
|
@ -46,7 +46,7 @@ abstract class SimpleAnimationProvider extends AnimationProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
void startAutoScrolling(boolean forward, float startSpeed, ZLView.Direction direction, int w, int h, Integer x, Integer y, int speed) {
|
||||
protected void startAutoScrollingInternal(boolean forward, float startSpeed, ZLView.Direction direction, int w, int h, Integer x, Integer y, int speed) {
|
||||
super.startAutoScrolling(forward, startSpeed, direction, w, h, x, y, speed);
|
||||
mySpeedFactor = (float)Math.pow(1.5, 0.25 * speed);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class SlideAnimationProvider extends SimpleAnimationProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
||||
protected void drawInternal(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
||||
canvas.drawBitmap(bgBitmap, 0, 0, myPaint);
|
||||
myPaint.setColor(Color.rgb(127, 127, 127));
|
||||
if (myDirection.IsHorizontal) {
|
||||
|
|
|
@ -181,12 +181,15 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
|||
return;
|
||||
}
|
||||
|
||||
final AnimationProvider animator = getAnimationProvider();
|
||||
if (!animator.inProgress()) {
|
||||
getAnimationProvider().startManualScrolling(
|
||||
startX, startY,
|
||||
endX, endY,
|
||||
direction,
|
||||
getWidth(), getMainAreaHeight()
|
||||
);
|
||||
}
|
||||
getAnimationProvider().scrollTo(endX, endY);
|
||||
setPageToScrollTo(getAnimationProvider().getPageToScrollTo());
|
||||
drawOnBitmap(mySecondaryBitmap);
|
||||
postInvalidate();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue