mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +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) {
|
private synchronized void runAutoScrolling(int x, int y) {
|
||||||
final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue();
|
final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue();
|
||||||
final int diff = horizontal ? x - myStartX : y - myStartY;
|
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 h = myContext.getHeight();
|
||||||
final int w = myContext.getWidth();
|
final int w = myContext.getWidth();
|
||||||
final int minDiff = horizontal ?
|
final int minDiff = horizontal ?
|
||||||
|
@ -212,7 +205,6 @@ public final class FBView extends ZLTextView {
|
||||||
: (diff < 0 ? PageIndex.next : PageIndex.previous);
|
: (diff < 0 ? PageIndex.next : PageIndex.previous);
|
||||||
myReader.startViewAutoScrolling(pageIndex, horizontal ? Direction.rightToLeft : Direction.up, ScrollingPreferences.Instance().AnimationSpeedOption.getValue());
|
myReader.startViewAutoScrolling(pageIndex, horizontal ? Direction.rightToLeft : Direction.up, ScrollingPreferences.Instance().AnimationSpeedOption.getValue());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean onFingerRelease(int x, int y) {
|
public boolean onFingerRelease(int x, int y) {
|
||||||
if (myIsBrightnessAdjustmentInProgress) {
|
if (myIsBrightnessAdjustmentInProgress) {
|
||||||
|
|
|
@ -34,14 +34,9 @@ class TurnPageAction extends FBAction {
|
||||||
|
|
||||||
final ScrollingPreferences.FingerScrolling fingerScrolling =
|
final ScrollingPreferences.FingerScrolling fingerScrolling =
|
||||||
preferences.FingerScrollingOption.getValue();
|
preferences.FingerScrollingOption.getValue();
|
||||||
if (fingerScrolling != ScrollingPreferences.FingerScrolling.byTap &&
|
return
|
||||||
fingerScrolling != ScrollingPreferences.FingerScrolling.byTapAndFlick) {
|
fingerScrolling == ScrollingPreferences.FingerScrolling.byTap ||
|
||||||
return false;
|
fingerScrolling == ScrollingPreferences.FingerScrolling.byTapAndFlick;
|
||||||
}
|
|
||||||
|
|
||||||
return myForward
|
|
||||||
? Reader.getTextView().canScrollForward()
|
|
||||||
: Reader.getTextView().canScrollBackward();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -41,15 +41,6 @@ class VolumeKeyTurnPageAction extends FBAction {
|
||||||
forward = !forward;
|
forward = !forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (forward) {
|
|
||||||
if (!Reader.getTextView().canScrollForward()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!Reader.getTextView().canScrollBackward()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reader.startViewAutoScrolling(
|
Reader.startViewAutoScrolling(
|
||||||
forward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
forward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
||||||
preferences.HorizontalOption.getValue()
|
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) {
|
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 AnimationProvider animator = getAnimationProvider();
|
||||||
final int w = getWidth();
|
final int w = getWidth();
|
||||||
final int h = getMainAreaHeight();
|
final int h = getMainAreaHeight();
|
||||||
|
@ -184,9 +185,15 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case previous:
|
case previous:
|
||||||
|
if (!view.canScrollBackward()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
animator.startAutoScrolling(true, 3, direction, w, h, x, y, speed);
|
animator.startAutoScrolling(true, 3, direction, w, h, x, y, speed);
|
||||||
break;
|
break;
|
||||||
case next:
|
case next:
|
||||||
|
if (!view.canScrollForward()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
animator.startAutoScrolling(true, -3, direction, w, h, x, y, speed);
|
animator.startAutoScrolling(true, -3, direction, w, h, x, y, speed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue