mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 18:29:23 +02:00
animation code cleanup
This commit is contained in:
parent
c27c9a604a
commit
f2381bffc6
2 changed files with 7 additions and 16 deletions
|
@ -1157,6 +1157,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
|
|
||||||
public void clearCaches() {
|
public void clearCaches() {
|
||||||
rebuildPaintInfo();
|
rebuildPaintInfo();
|
||||||
|
ZLApplication.Instance().resetView();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void rebuildPaintInfo() {
|
protected void rebuildPaintInfo() {
|
||||||
|
|
|
@ -35,8 +35,6 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
private final BitmapManager myBitmapManager = new BitmapManager(this);
|
private final BitmapManager myBitmapManager = new BitmapManager(this);
|
||||||
private Bitmap myFooterBitmap;
|
private Bitmap myFooterBitmap;
|
||||||
|
|
||||||
private ZLView.PageIndex myPageToScrollTo = ZLView.PageIndex.current;
|
|
||||||
|
|
||||||
public ZLAndroidWidget(Context context, AttributeSet attrs, int defStyle) {
|
public ZLAndroidWidget(Context context, AttributeSet attrs, int defStyle) {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
init();
|
init();
|
||||||
|
@ -68,7 +66,6 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
getAnimationProvider().terminate();
|
getAnimationProvider().terminate();
|
||||||
myScreenIsTouched = false;
|
myScreenIsTouched = false;
|
||||||
view.onScrollingFinished(ZLView.PageIndex.current);
|
view.onScrollingFinished(ZLView.PageIndex.current);
|
||||||
setPageToScrollTo(ZLView.PageIndex.current);
|
|
||||||
}
|
}
|
||||||
myBitmapManager.setSize(w, h);
|
myBitmapManager.setSize(w, h);
|
||||||
}
|
}
|
||||||
|
@ -137,8 +134,9 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
switch (oldMode) {
|
switch (oldMode) {
|
||||||
case AutoScrollingForward:
|
case AutoScrollingForward:
|
||||||
{
|
{
|
||||||
myBitmapManager.shift(animator.getPageToScrollTo() == ZLView.PageIndex.next);
|
final ZLView.PageIndex index = animator.getPageToScrollTo();
|
||||||
view.onScrollingFinished(myPageToScrollTo);
|
myBitmapManager.shift(index == ZLView.PageIndex.next);
|
||||||
|
view.onScrollingFinished(index);
|
||||||
ZLApplication.Instance().onRepaintFinished();
|
ZLApplication.Instance().onRepaintFinished();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -146,15 +144,10 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
view.onScrollingFinished(ZLView.PageIndex.current);
|
view.onScrollingFinished(ZLView.PageIndex.current);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
setPageToScrollTo(ZLView.PageIndex.current);
|
|
||||||
onDrawStatic(canvas);
|
onDrawStatic(canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPageToScrollTo(ZLView.PageIndex pageIndex) {
|
|
||||||
myPageToScrollTo = pageIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetBitmaps() {
|
public void resetBitmaps() {
|
||||||
myBitmapManager.reset();
|
myBitmapManager.reset();
|
||||||
}
|
}
|
||||||
|
@ -169,7 +162,6 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
animator.scrollTo(endX, endY);
|
animator.scrollTo(endX, endY);
|
||||||
setPageToScrollTo(animator.getPageToScrollTo());
|
|
||||||
postInvalidate();
|
postInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +171,7 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
final int h = getMainAreaHeight();
|
final int h = getMainAreaHeight();
|
||||||
switch (pageIndex) {
|
switch (pageIndex) {
|
||||||
case current:
|
case current:
|
||||||
switch (myPageToScrollTo) {
|
switch (animator.getPageToScrollTo()) {
|
||||||
case current:
|
case current:
|
||||||
animator.terminate();
|
animator.terminate();
|
||||||
break;
|
break;
|
||||||
|
@ -193,11 +185,9 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
break;
|
break;
|
||||||
case previous:
|
case previous:
|
||||||
animator.startAutoScrolling(true, 3, direction, w, h, x, y, speed);
|
animator.startAutoScrolling(true, 3, direction, w, h, x, y, speed);
|
||||||
setPageToScrollTo(pageIndex);
|
|
||||||
break;
|
break;
|
||||||
case next:
|
case next:
|
||||||
animator.startAutoScrolling(true, -3, direction, w, h, x, y, speed);
|
animator.startAutoScrolling(true, -3, direction, w, h, x, y, speed);
|
||||||
setPageToScrollTo(pageIndex);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
postInvalidate();
|
postInvalidate();
|
||||||
|
@ -457,7 +447,7 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
final AnimationProvider animator = getAnimationProvider();
|
final AnimationProvider animator = getAnimationProvider();
|
||||||
if (animator.inProgress()) {
|
if (animator.inProgress()) {
|
||||||
final int from = view.getScrollbarThumbLength(ZLView.PageIndex.current);
|
final int from = view.getScrollbarThumbLength(ZLView.PageIndex.current);
|
||||||
final int to = view.getScrollbarThumbLength(myPageToScrollTo);
|
final int to = view.getScrollbarThumbLength(animator.getPageToScrollTo());
|
||||||
final int percent = animator.getScrolledPercent();
|
final int percent = animator.getScrolledPercent();
|
||||||
return (from * (100 - percent) + to * percent) / 100;
|
return (from * (100 - percent) + to * percent) / 100;
|
||||||
} else {
|
} else {
|
||||||
|
@ -473,7 +463,7 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
final AnimationProvider animator = getAnimationProvider();
|
final AnimationProvider animator = getAnimationProvider();
|
||||||
if (animator.inProgress()) {
|
if (animator.inProgress()) {
|
||||||
final int from = view.getScrollbarThumbPosition(ZLView.PageIndex.current);
|
final int from = view.getScrollbarThumbPosition(ZLView.PageIndex.current);
|
||||||
final int to = view.getScrollbarThumbPosition(myPageToScrollTo);
|
final int to = view.getScrollbarThumbPosition(animator.getPageToScrollTo());
|
||||||
final int percent = animator.getScrolledPercent();
|
final int percent = animator.getScrolledPercent();
|
||||||
return (from * (100 - percent) + to * percent) / 100;
|
return (from * (100 - percent) + to * percent) / 100;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue