mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 19:42:17 +02:00
code simplification
This commit is contained in:
parent
ffb1925e1c
commit
3a55bed5c2
4 changed files with 20 additions and 35 deletions
|
@ -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) {
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue