1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-05 10:49:24 +02:00

code simplification

This commit is contained in:
Nikolay Pultsin 2011-04-13 03:26:21 +01:00
parent ffb1925e1c
commit 3a55bed5c2
4 changed files with 20 additions and 35 deletions

View file

@ -194,13 +194,6 @@ public final class FBView extends ZLTextView {
private synchronized void runAutoScrolling(int x, int y) {
final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue();
final int diff = horizontal ? x - myStartX : y - myStartY;
boolean doScroll = false;
if (diff > 0) {
doScroll = canScrollBackward();
} else if (diff < 0) {
doScroll = canScrollForward();
}
if (doScroll) {
final int h = myContext.getHeight();
final int w = myContext.getWidth();
final int minDiff = horizontal ?
@ -212,7 +205,6 @@ public final class FBView extends ZLTextView {
: (diff < 0 ? PageIndex.next : PageIndex.previous);
myReader.startViewAutoScrolling(pageIndex, horizontal ? Direction.rightToLeft : Direction.up, ScrollingPreferences.Instance().AnimationSpeedOption.getValue());
}
}
public boolean onFingerRelease(int x, int y) {
if (myIsBrightnessAdjustmentInProgress) {

View file

@ -34,14 +34,9 @@ class TurnPageAction extends FBAction {
final ScrollingPreferences.FingerScrolling fingerScrolling =
preferences.FingerScrollingOption.getValue();
if (fingerScrolling != ScrollingPreferences.FingerScrolling.byTap &&
fingerScrolling != ScrollingPreferences.FingerScrolling.byTapAndFlick) {
return false;
}
return myForward
? Reader.getTextView().canScrollForward()
: Reader.getTextView().canScrollBackward();
return
fingerScrolling == ScrollingPreferences.FingerScrolling.byTap ||
fingerScrolling == ScrollingPreferences.FingerScrolling.byTapAndFlick;
}
public void run() {

View file

@ -41,15 +41,6 @@ class VolumeKeyTurnPageAction extends FBAction {
forward = !forward;
}
if (forward) {
if (!Reader.getTextView().canScrollForward()) {
return;
}
} else {
if (!Reader.getTextView().canScrollBackward()) {
return;
}
}
Reader.startViewAutoScrolling(
forward ? FBView.PageIndex.next : FBView.PageIndex.previous,
preferences.HorizontalOption.getValue()

View file

@ -166,6 +166,7 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
}
public void startAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, Integer x, Integer y, int speed) {
final ZLView view = ZLApplication.Instance().getCurrentView();
final AnimationProvider animator = getAnimationProvider();
final int w = getWidth();
final int h = getMainAreaHeight();
@ -184,9 +185,15 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
}
break;
case previous:
if (!view.canScrollBackward()) {
return;
}
animator.startAutoScrolling(true, 3, direction, w, h, x, y, speed);
break;
case next:
if (!view.canScrollForward()) {
return;
}
animator.startAutoScrolling(true, -3, direction, w, h, x, y, speed);
break;
}