From 22fd615a9830784c420c8fdef78e74dba6b8a0ad Mon Sep 17 00:00:00 2001 From: Nikolay Pultsin Date: Sun, 7 Dec 2014 03:52:01 +0000 Subject: [PATCH] ZLViewEnums is an interface --- .../fbreader/fbreader/FBReaderApp.java | 11 ++--- .../fbreader/fbreader/FBView.java | 7 ++-- .../fbreader/fbreader/MoveCursorAction.java | 5 +-- .../fbreader/fbreader/TurnPageAction.java | 9 ++--- .../fbreader/VolumeKeyTurnPageAction.java | 5 +-- .../fbreader/options/PageTurningOptions.java | 5 +-- .../zlibrary/core/view/ZLView.java | 4 +- .../zlibrary/core/view/ZLViewEnums.java | 17 ++++---- .../zlibrary/core/view/ZLViewWidget.java | 6 +-- .../text/view/ZLTextElementAreaVector.java | 4 +- .../zlibrary/text/view/ZLTextView.java | 5 +-- .../ui/android/view/AnimationProvider.java | 21 +++++----- .../ui/android/view/BitmapManager.java | 9 ++--- .../android/view/CurlAnimationProvider.java | 16 ++++---- .../android/view/NoneAnimationProvider.java | 15 ++++--- .../android/view/SimpleAnimationProvider.java | 15 ++++--- .../ui/android/view/ZLAndroidWidget.java | 40 ++++++++++--------- 17 files changed, 91 insertions(+), 103 deletions(-) diff --git a/src/org/geometerplus/fbreader/fbreader/FBReaderApp.java b/src/org/geometerplus/fbreader/fbreader/FBReaderApp.java index c5b6d7ea1..d8a9e0332 100644 --- a/src/org/geometerplus/fbreader/fbreader/FBReaderApp.java +++ b/src/org/geometerplus/fbreader/fbreader/FBReaderApp.java @@ -25,10 +25,11 @@ import org.geometerplus.zlibrary.core.application.*; import org.geometerplus.zlibrary.core.drm.FileEncryptionInfo; import org.geometerplus.zlibrary.core.drm.EncryptionMethod; import org.geometerplus.zlibrary.core.util.*; -import org.geometerplus.zlibrary.core.view.ZLViewEnums; + import org.geometerplus.zlibrary.text.hyphenation.ZLTextHyphenator; import org.geometerplus.zlibrary.text.model.ZLTextModel; import org.geometerplus.zlibrary.text.view.*; + import org.geometerplus.fbreader.book.*; import org.geometerplus.fbreader.bookmodel.*; import org.geometerplus.fbreader.fbreader.options.*; @@ -112,10 +113,10 @@ public final class FBReaderApp extends ZLApplication { addAction(ActionCode.TURN_PAGE_FORWARD, new TurnPageAction(this, true)); addAction(ActionCode.TURN_PAGE_BACK, new TurnPageAction(this, false)); - addAction(ActionCode.MOVE_CURSOR_UP, new MoveCursorAction(this, ZLViewEnums.Direction.up)); - addAction(ActionCode.MOVE_CURSOR_DOWN, new MoveCursorAction(this, ZLViewEnums.Direction.down)); - addAction(ActionCode.MOVE_CURSOR_LEFT, new MoveCursorAction(this, ZLViewEnums.Direction.rightToLeft)); - addAction(ActionCode.MOVE_CURSOR_RIGHT, new MoveCursorAction(this, ZLViewEnums.Direction.leftToRight)); + addAction(ActionCode.MOVE_CURSOR_UP, new MoveCursorAction(this, FBView.Direction.up)); + addAction(ActionCode.MOVE_CURSOR_DOWN, new MoveCursorAction(this, FBView.Direction.down)); + addAction(ActionCode.MOVE_CURSOR_LEFT, new MoveCursorAction(this, FBView.Direction.rightToLeft)); + addAction(ActionCode.MOVE_CURSOR_RIGHT, new MoveCursorAction(this, FBView.Direction.leftToRight)); addAction(ActionCode.VOLUME_KEY_SCROLL_FORWARD, new VolumeKeyTurnPageAction(this, true)); addAction(ActionCode.VOLUME_KEY_SCROLL_BACK, new VolumeKeyTurnPageAction(this, false)); diff --git a/src/org/geometerplus/fbreader/fbreader/FBView.java b/src/org/geometerplus/fbreader/fbreader/FBView.java index f216e6313..664484d51 100644 --- a/src/org/geometerplus/fbreader/fbreader/FBView.java +++ b/src/org/geometerplus/fbreader/fbreader/FBView.java @@ -26,13 +26,12 @@ import org.geometerplus.zlibrary.core.filesystem.ZLResourceFile; import org.geometerplus.zlibrary.core.fonts.FontEntry; import org.geometerplus.zlibrary.core.library.ZLibrary; import org.geometerplus.zlibrary.core.util.ZLColor; -import org.geometerplus.zlibrary.core.view.*; -import org.geometerplus.zlibrary.core.view.ZLViewEnums.Animation; -import org.geometerplus.zlibrary.core.view.ZLViewEnums.Direction; -import org.geometerplus.zlibrary.core.view.ZLViewEnums.PageIndex; +import org.geometerplus.zlibrary.core.view.ZLPaintContext; + import org.geometerplus.zlibrary.text.model.ZLTextModel; import org.geometerplus.zlibrary.text.view.*; import org.geometerplus.zlibrary.text.view.style.ZLTextStyleCollection; + import org.geometerplus.fbreader.bookmodel.BookModel; import org.geometerplus.fbreader.bookmodel.FBHyperlinkType; import org.geometerplus.fbreader.bookmodel.TOCTree; diff --git a/src/org/geometerplus/fbreader/fbreader/MoveCursorAction.java b/src/org/geometerplus/fbreader/fbreader/MoveCursorAction.java index 40184894a..1b137078b 100644 --- a/src/org/geometerplus/fbreader/fbreader/MoveCursorAction.java +++ b/src/org/geometerplus/fbreader/fbreader/MoveCursorAction.java @@ -19,14 +19,13 @@ package org.geometerplus.fbreader.fbreader; -import org.geometerplus.zlibrary.core.view.ZLViewEnums; import org.geometerplus.zlibrary.text.view.ZLTextRegion; import org.geometerplus.zlibrary.text.view.ZLTextWordRegionSoul; class MoveCursorAction extends FBAction { - private final ZLViewEnums.Direction myDirection; + private final FBView.Direction myDirection; - MoveCursorAction(FBReaderApp fbreader, ZLViewEnums.Direction direction) { + MoveCursorAction(FBReaderApp fbreader, FBView.Direction direction) { super(fbreader); myDirection = direction; } diff --git a/src/org/geometerplus/fbreader/fbreader/TurnPageAction.java b/src/org/geometerplus/fbreader/fbreader/TurnPageAction.java index f58aac83f..6a1b0733a 100644 --- a/src/org/geometerplus/fbreader/fbreader/TurnPageAction.java +++ b/src/org/geometerplus/fbreader/fbreader/TurnPageAction.java @@ -20,7 +20,6 @@ package org.geometerplus.fbreader.fbreader; import org.geometerplus.fbreader.fbreader.options.PageTurningOptions; -import org.geometerplus.zlibrary.core.view.ZLViewEnums; class TurnPageAction extends FBAction { private final boolean myForward; @@ -46,17 +45,17 @@ class TurnPageAction extends FBAction { final int x = (Integer)params[0]; final int y = (Integer)params[1]; Reader.getViewWidget().startAnimatedScrolling( - myForward ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous, + myForward ? FBView.PageIndex.next : FBView.PageIndex.previous, x, y, preferences.Horizontal.getValue() - ? ZLViewEnums.Direction.rightToLeft : ZLViewEnums.Direction.up, + ? FBView.Direction.rightToLeft : FBView.Direction.up, preferences.AnimationSpeed.getValue() ); } else { Reader.getViewWidget().startAnimatedScrolling( - myForward ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous, + myForward ? FBView.PageIndex.next : FBView.PageIndex.previous, preferences.Horizontal.getValue() - ? ZLViewEnums.Direction.rightToLeft : ZLViewEnums.Direction.up, + ? FBView.Direction.rightToLeft : FBView.Direction.up, preferences.AnimationSpeed.getValue() ); } diff --git a/src/org/geometerplus/fbreader/fbreader/VolumeKeyTurnPageAction.java b/src/org/geometerplus/fbreader/fbreader/VolumeKeyTurnPageAction.java index df6883aff..2f661e277 100644 --- a/src/org/geometerplus/fbreader/fbreader/VolumeKeyTurnPageAction.java +++ b/src/org/geometerplus/fbreader/fbreader/VolumeKeyTurnPageAction.java @@ -20,7 +20,6 @@ package org.geometerplus.fbreader.fbreader; import org.geometerplus.fbreader.fbreader.options.PageTurningOptions; -import org.geometerplus.zlibrary.core.view.ZLViewEnums; class VolumeKeyTurnPageAction extends FBAction { private final boolean myForward; @@ -34,9 +33,9 @@ class VolumeKeyTurnPageAction extends FBAction { protected void run(Object ... params) { final PageTurningOptions preferences = Reader.PageTurningOptions; Reader.getViewWidget().startAnimatedScrolling( - myForward ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous, + myForward ? FBView.PageIndex.next : FBView.PageIndex.previous, preferences.Horizontal.getValue() - ? ZLViewEnums.Direction.rightToLeft : ZLViewEnums.Direction.up, + ? FBView.Direction.rightToLeft : FBView.Direction.up, preferences.AnimationSpeed.getValue() ); } diff --git a/src/org/geometerplus/fbreader/fbreader/options/PageTurningOptions.java b/src/org/geometerplus/fbreader/fbreader/options/PageTurningOptions.java index 8002dc541..6351f885f 100644 --- a/src/org/geometerplus/fbreader/fbreader/options/PageTurningOptions.java +++ b/src/org/geometerplus/fbreader/fbreader/options/PageTurningOptions.java @@ -21,7 +21,6 @@ package org.geometerplus.fbreader.fbreader.options; import org.geometerplus.zlibrary.core.options.*; import org.geometerplus.zlibrary.core.view.ZLView; -import org.geometerplus.zlibrary.core.view.ZLViewEnums; public class PageTurningOptions { public static enum FingerScrollingType { @@ -30,8 +29,8 @@ public class PageTurningOptions { public final ZLEnumOption FingerScrolling = new ZLEnumOption("Scrolling", "Finger", FingerScrollingType.byTapAndFlick); - public final ZLEnumOption Animation = - new ZLEnumOption("Scrolling", "Animation", ZLViewEnums.Animation.slide); + public final ZLEnumOption Animation = + new ZLEnumOption("Scrolling", "Animation", ZLView.Animation.slide); public final ZLIntegerRangeOption AnimationSpeed = new ZLIntegerRangeOption("Scrolling", "AnimationSpeed", 1, 10, 7); diff --git a/src/org/geometerplus/zlibrary/core/view/ZLView.java b/src/org/geometerplus/zlibrary/core/view/ZLView.java index 7ee6fb166..1fbde67e5 100644 --- a/src/org/geometerplus/zlibrary/core/view/ZLView.java +++ b/src/org/geometerplus/zlibrary/core/view/ZLView.java @@ -20,10 +20,8 @@ package org.geometerplus.zlibrary.core.view; import org.geometerplus.zlibrary.core.application.ZLApplication; -import org.geometerplus.zlibrary.core.view.ZLViewEnums.Animation; -import org.geometerplus.zlibrary.core.view.ZLViewEnums.PageIndex; -abstract public class ZLView { +abstract public class ZLView implements ZLViewEnums { public final ZLApplication Application; private ZLPaintContext myViewContext = new DummyPaintContext(); diff --git a/src/org/geometerplus/zlibrary/core/view/ZLViewEnums.java b/src/org/geometerplus/zlibrary/core/view/ZLViewEnums.java index 4d40c68e7..64f0eed9f 100644 --- a/src/org/geometerplus/zlibrary/core/view/ZLViewEnums.java +++ b/src/org/geometerplus/zlibrary/core/view/ZLViewEnums.java @@ -19,10 +19,8 @@ package org.geometerplus.zlibrary.core.view; - -abstract public class ZLViewEnums { - - public static enum PageIndex { +public interface ZLViewEnums { + public enum PageIndex { previous, current, next; public PageIndex getNext() { @@ -46,8 +44,9 @@ abstract public class ZLViewEnums { return null; } } - }; - public static enum Direction { + } + + public enum Direction { leftToRight(true), rightToLeft(true), up(false), down(false); public final boolean IsHorizontal; @@ -55,9 +54,9 @@ abstract public class ZLViewEnums { Direction(boolean isHorizontal) { IsHorizontal = isHorizontal; } - }; - public static enum Animation { - none, curl, slide, slideOldStyle, shift } + public enum Animation { + none, curl, slide, slideOldStyle, shift + } } diff --git a/src/org/geometerplus/zlibrary/core/view/ZLViewWidget.java b/src/org/geometerplus/zlibrary/core/view/ZLViewWidget.java index aef72d91b..e86bbad10 100644 --- a/src/org/geometerplus/zlibrary/core/view/ZLViewWidget.java +++ b/src/org/geometerplus/zlibrary/core/view/ZLViewWidget.java @@ -23,9 +23,9 @@ public interface ZLViewWidget { void reset(); void repaint(); - void startManualScrolling(int x, int y, ZLViewEnums.Direction direction); + void startManualScrolling(int x, int y, ZLView.Direction direction); void scrollManuallyTo(int x, int y); - void startAnimatedScrolling(ZLViewEnums.PageIndex pageIndex, int x, int y, ZLViewEnums.Direction direction, int speed); - void startAnimatedScrolling(ZLViewEnums.PageIndex pageIndex, ZLViewEnums.Direction direction, int speed); + void startAnimatedScrolling(ZLView.PageIndex pageIndex, int x, int y, ZLView.Direction direction, int speed); + void startAnimatedScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed); void startAnimatedScrolling(int x, int y, int speed); } diff --git a/src/org/geometerplus/zlibrary/text/view/ZLTextElementAreaVector.java b/src/org/geometerplus/zlibrary/text/view/ZLTextElementAreaVector.java index 16fad0e33..43d179a10 100644 --- a/src/org/geometerplus/zlibrary/text/view/ZLTextElementAreaVector.java +++ b/src/org/geometerplus/zlibrary/text/view/ZLTextElementAreaVector.java @@ -21,8 +21,6 @@ package org.geometerplus.zlibrary.text.view; import java.util.*; -import org.geometerplus.zlibrary.core.view.ZLViewEnums; - final class ZLTextElementAreaVector { private final List myAreas = Collections.synchronizedList(new ArrayList()); @@ -168,7 +166,7 @@ final class ZLTextElementAreaVector { return bestRegion; } - protected ZLTextRegion nextRegion(ZLTextRegion currentRegion, ZLViewEnums.Direction direction, ZLTextRegion.Filter filter) { + protected ZLTextRegion nextRegion(ZLTextRegion currentRegion, ZLTextView.Direction direction, ZLTextRegion.Filter filter) { synchronized (myElementRegions) { if (myElementRegions.isEmpty()) { return null; diff --git a/src/org/geometerplus/zlibrary/text/view/ZLTextView.java b/src/org/geometerplus/zlibrary/text/view/ZLTextView.java index dddec3527..25780ccb8 100644 --- a/src/org/geometerplus/zlibrary/text/view/ZLTextView.java +++ b/src/org/geometerplus/zlibrary/text/view/ZLTextView.java @@ -25,9 +25,8 @@ import org.geometerplus.zlibrary.core.application.ZLApplication; import org.geometerplus.zlibrary.core.filesystem.ZLFile; import org.geometerplus.zlibrary.core.util.RationalNumber; import org.geometerplus.zlibrary.core.util.ZLColor; -import org.geometerplus.zlibrary.core.view.*; -import org.geometerplus.zlibrary.core.view.ZLViewEnums.Direction; -import org.geometerplus.zlibrary.core.view.ZLViewEnums.PageIndex; +import org.geometerplus.zlibrary.core.view.ZLPaintContext; + import org.geometerplus.zlibrary.text.model.*; import org.geometerplus.zlibrary.text.hyphenation.*; import org.geometerplus.zlibrary.text.view.style.ZLTextStyleCollection; diff --git a/src/org/geometerplus/zlibrary/ui/android/view/AnimationProvider.java b/src/org/geometerplus/zlibrary/ui/android/view/AnimationProvider.java index 27f7ad3a6..091bcd3ae 100644 --- a/src/org/geometerplus/zlibrary/ui/android/view/AnimationProvider.java +++ b/src/org/geometerplus/zlibrary/ui/android/view/AnimationProvider.java @@ -26,7 +26,6 @@ import android.util.FloatMath; import org.geometerplus.zlibrary.core.library.ZLibrary; import org.geometerplus.zlibrary.core.view.ZLView; -import org.geometerplus.zlibrary.core.view.ZLViewEnums; abstract class AnimationProvider { static enum Mode { @@ -48,7 +47,7 @@ abstract class AnimationProvider { protected int myStartY; protected int myEndX; protected int myEndY; - protected ZLViewEnums.Direction myDirection; + protected ZLView.Direction myDirection; protected float mySpeed; protected int myWidth; @@ -88,7 +87,7 @@ abstract class AnimationProvider { return; } - if (getPageToScrollTo(x, y) == ZLViewEnums.PageIndex.current) { + if (getPageToScrollTo(x, y) == ZLView.PageIndex.current) { return; } @@ -124,7 +123,7 @@ abstract class AnimationProvider { } myDrawInfos.clear(); - if (getPageToScrollTo() == ZLViewEnums.PageIndex.previous) { + if (getPageToScrollTo() == ZLView.PageIndex.previous) { forward = !forward; } @@ -142,7 +141,7 @@ abstract class AnimationProvider { startAnimatedScrollingInternal(speed); } - public void startAnimatedScrolling(ZLViewEnums.PageIndex pageIndex, Integer x, Integer y, int speed) { + public void startAnimatedScrolling(ZLView.PageIndex pageIndex, Integer x, Integer y, int speed) { if (myMode.Auto) { return; } @@ -153,11 +152,11 @@ abstract class AnimationProvider { switch (myDirection) { case up: case rightToLeft: - mySpeed = pageIndex == ZLViewEnums.PageIndex.next ? -15 : 15; + mySpeed = pageIndex == ZLView.PageIndex.next ? -15 : 15; break; case leftToRight: case down: - mySpeed = pageIndex == ZLViewEnums.PageIndex.next ? 15 : -15; + mySpeed = pageIndex == ZLView.PageIndex.next ? 15 : -15; break; } setupAnimatedScrollingStart(x, y); @@ -175,7 +174,7 @@ abstract class AnimationProvider { return myDirection.IsHorizontal ? myEndX - myStartX : myEndY - myStartY; } - final void setup(ZLViewEnums.Direction direction, int width, int height) { + final void setup(ZLView.Direction direction, int width, int height) { myDirection = direction; myWidth = width; myHeight = height; @@ -215,14 +214,14 @@ abstract class AnimationProvider { protected abstract void drawInternal(Canvas canvas); - abstract ZLViewEnums.PageIndex getPageToScrollTo(int x, int y); + abstract ZLView.PageIndex getPageToScrollTo(int x, int y); - final ZLViewEnums.PageIndex getPageToScrollTo() { + final ZLView.PageIndex getPageToScrollTo() { return getPageToScrollTo(myEndX, myEndY); } protected Bitmap getBitmapFrom() { - return myBitmapManager.getBitmap(ZLViewEnums.PageIndex.current); + return myBitmapManager.getBitmap(ZLView.PageIndex.current); } protected Bitmap getBitmapTo() { diff --git a/src/org/geometerplus/zlibrary/ui/android/view/BitmapManager.java b/src/org/geometerplus/zlibrary/ui/android/view/BitmapManager.java index d2b69dfc3..77ef7a0b4 100644 --- a/src/org/geometerplus/zlibrary/ui/android/view/BitmapManager.java +++ b/src/org/geometerplus/zlibrary/ui/android/view/BitmapManager.java @@ -22,12 +22,11 @@ package org.geometerplus.zlibrary.ui.android.view; import android.graphics.Bitmap; import org.geometerplus.zlibrary.core.view.ZLView; -import org.geometerplus.zlibrary.core.view.ZLViewEnums; class BitmapManager { private final int SIZE = 2; private final Bitmap[] myBitmaps = new Bitmap[SIZE]; - private final ZLViewEnums.PageIndex[] myIndexes = new ZLViewEnums.PageIndex[SIZE]; + private final ZLView.PageIndex[] myIndexes = new ZLView.PageIndex[SIZE]; private int myWidth; private int myHeight; @@ -52,7 +51,7 @@ class BitmapManager { } } - Bitmap getBitmap(ZLViewEnums.PageIndex index) { + Bitmap getBitmap(ZLView.PageIndex index) { for (int i = 0; i < SIZE; ++i) { if (index == myIndexes[i]) { return myBitmaps[i]; @@ -73,14 +72,14 @@ class BitmapManager { return myBitmaps[iIndex]; } - private int getInternalIndex(ZLViewEnums.PageIndex index) { + private int getInternalIndex(ZLView.PageIndex index) { for (int i = 0; i < SIZE; ++i) { if (myIndexes[i] == null) { return i; } } for (int i = 0; i < SIZE; ++i) { - if (myIndexes[i] != ZLViewEnums.PageIndex.current) { + if (myIndexes[i] != ZLView.PageIndex.current) { return i; } } diff --git a/src/org/geometerplus/zlibrary/ui/android/view/CurlAnimationProvider.java b/src/org/geometerplus/zlibrary/ui/android/view/CurlAnimationProvider.java index fec7f84d9..522946921 100644 --- a/src/org/geometerplus/zlibrary/ui/android/view/CurlAnimationProvider.java +++ b/src/org/geometerplus/zlibrary/ui/android/view/CurlAnimationProvider.java @@ -23,7 +23,7 @@ import android.graphics.*; import android.util.FloatMath; import org.geometerplus.zlibrary.core.view.ZLView; -import org.geometerplus.zlibrary.core.view.ZLViewEnums; + import org.geometerplus.zlibrary.ui.android.util.ZLAndroidColorUtil; class CurlAnimationProvider extends AnimationProvider { @@ -208,22 +208,22 @@ class CurlAnimationProvider extends AnimationProvider { } @Override - ZLViewEnums.PageIndex getPageToScrollTo(int x, int y) { + ZLView.PageIndex getPageToScrollTo(int x, int y) { if (myDirection == null) { - return ZLViewEnums.PageIndex.current; + return ZLView.PageIndex.current; } switch (myDirection) { case leftToRight: - return myStartX < myWidth / 2 ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous; + return myStartX < myWidth / 2 ? ZLView.PageIndex.next : ZLView.PageIndex.previous; case rightToLeft: - return myStartX < myWidth / 2 ? ZLViewEnums.PageIndex.previous : ZLViewEnums.PageIndex.next; + return myStartX < myWidth / 2 ? ZLView.PageIndex.previous : ZLView.PageIndex.next; case up: - return myStartY < myHeight / 2 ? ZLViewEnums.PageIndex.previous : ZLViewEnums.PageIndex.next; + return myStartY < myHeight / 2 ? ZLView.PageIndex.previous : ZLView.PageIndex.next; case down: - return myStartY < myHeight / 2 ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous; + return myStartY < myHeight / 2 ? ZLView.PageIndex.next : ZLView.PageIndex.previous; } - return ZLViewEnums.PageIndex.current; + return ZLView.PageIndex.current; } @Override diff --git a/src/org/geometerplus/zlibrary/ui/android/view/NoneAnimationProvider.java b/src/org/geometerplus/zlibrary/ui/android/view/NoneAnimationProvider.java index a59e30e6c..8386e26b2 100644 --- a/src/org/geometerplus/zlibrary/ui/android/view/NoneAnimationProvider.java +++ b/src/org/geometerplus/zlibrary/ui/android/view/NoneAnimationProvider.java @@ -22,7 +22,6 @@ package org.geometerplus.zlibrary.ui.android.view; import android.graphics.*; import org.geometerplus.zlibrary.core.view.ZLView; -import org.geometerplus.zlibrary.core.view.ZLViewEnums; class NoneAnimationProvider extends AnimationProvider { private final Paint myPaint = new Paint(); @@ -61,22 +60,22 @@ class NoneAnimationProvider extends AnimationProvider { } @Override - ZLViewEnums.PageIndex getPageToScrollTo(int x, int y) { + ZLView.PageIndex getPageToScrollTo(int x, int y) { if (myDirection == null) { - return ZLViewEnums.PageIndex.current; + return ZLView.PageIndex.current; } switch (myDirection) { case rightToLeft: - return myStartX < x ? ZLViewEnums.PageIndex.previous : ZLViewEnums.PageIndex.next; + return myStartX < x ? ZLView.PageIndex.previous : ZLView.PageIndex.next; case leftToRight: - return myStartX < x ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous; + return myStartX < x ? ZLView.PageIndex.next : ZLView.PageIndex.previous; case up: - return myStartY < y ? ZLViewEnums.PageIndex.previous : ZLViewEnums.PageIndex.next; + return myStartY < y ? ZLView.PageIndex.previous : ZLView.PageIndex.next; case down: - return myStartY < y ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous; + return myStartY < y ? ZLView.PageIndex.next : ZLView.PageIndex.previous; } - return ZLViewEnums.PageIndex.current; + return ZLView.PageIndex.current; } @Override diff --git a/src/org/geometerplus/zlibrary/ui/android/view/SimpleAnimationProvider.java b/src/org/geometerplus/zlibrary/ui/android/view/SimpleAnimationProvider.java index 40a5e9ff6..076af387b 100644 --- a/src/org/geometerplus/zlibrary/ui/android/view/SimpleAnimationProvider.java +++ b/src/org/geometerplus/zlibrary/ui/android/view/SimpleAnimationProvider.java @@ -20,7 +20,6 @@ package org.geometerplus.zlibrary.ui.android.view; import org.geometerplus.zlibrary.core.view.ZLView; -import org.geometerplus.zlibrary.core.view.ZLViewEnums; abstract class SimpleAnimationProvider extends AnimationProvider { private float mySpeedFactor; @@ -30,22 +29,22 @@ abstract class SimpleAnimationProvider extends AnimationProvider { } @Override - ZLViewEnums.PageIndex getPageToScrollTo(int x, int y) { + ZLView.PageIndex getPageToScrollTo(int x, int y) { if (myDirection == null) { - return ZLViewEnums.PageIndex.current; + return ZLView.PageIndex.current; } switch (myDirection) { case rightToLeft: - return myStartX < x ? ZLViewEnums.PageIndex.previous : ZLViewEnums.PageIndex.next; + return myStartX < x ? ZLView.PageIndex.previous : ZLView.PageIndex.next; case leftToRight: - return myStartX < x ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous; + return myStartX < x ? ZLView.PageIndex.next : ZLView.PageIndex.previous; case up: - return myStartY < y ? ZLViewEnums.PageIndex.previous : ZLViewEnums.PageIndex.next; + return myStartY < y ? ZLView.PageIndex.previous : ZLView.PageIndex.next; case down: - return myStartY < y ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous; + return myStartY < y ? ZLView.PageIndex.next : ZLView.PageIndex.previous; } - return ZLViewEnums.PageIndex.current; + return ZLView.PageIndex.current; } @Override diff --git a/src/org/geometerplus/zlibrary/ui/android/view/ZLAndroidWidget.java b/src/org/geometerplus/zlibrary/ui/android/view/ZLAndroidWidget.java index 031acf968..7f921bc20 100644 --- a/src/org/geometerplus/zlibrary/ui/android/view/ZLAndroidWidget.java +++ b/src/org/geometerplus/zlibrary/ui/android/view/ZLAndroidWidget.java @@ -26,7 +26,9 @@ import android.view.*; import org.geometerplus.zlibrary.core.application.ZLApplication; import org.geometerplus.zlibrary.core.application.ZLKeyBindings; -import org.geometerplus.zlibrary.core.view.*; +import org.geometerplus.zlibrary.core.view.ZLView; +import org.geometerplus.zlibrary.core.view.ZLViewWidget; + import org.geometerplus.android.fbreader.FBReader; public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongClickListener { @@ -64,7 +66,7 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl if (myScreenIsTouched) { final ZLView view = ZLApplication.Instance().getCurrentView(); myScreenIsTouched = false; - view.onScrollingFinished(ZLViewEnums.PageIndex.current); + view.onScrollingFinished(ZLView.PageIndex.current); } } @@ -90,9 +92,9 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl } private AnimationProvider myAnimationProvider; - private ZLViewEnums.Animation myAnimationType; + private ZLView.Animation myAnimationType; private AnimationProvider getAnimationProvider() { - final ZLViewEnums.Animation type = ZLApplication.Instance().getCurrentView().getAnimationType(); + final ZLView.Animation type = ZLApplication.Instance().getCurrentView().getAnimationType(); if (myAnimationProvider == null || myAnimationType != type) { myAnimationType = type; switch (type) { @@ -135,14 +137,14 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl switch (oldMode) { case AnimatedScrollingForward: { - final ZLViewEnums.PageIndex index = animator.getPageToScrollTo(); - myBitmapManager.shift(index == ZLViewEnums.PageIndex.next); + final ZLView.PageIndex index = animator.getPageToScrollTo(); + myBitmapManager.shift(index == ZLView.PageIndex.next); view.onScrollingFinished(index); ZLApplication.Instance().onRepaintFinished(); break; } case AnimatedScrollingBackward: - view.onScrollingFinished(ZLViewEnums.PageIndex.current); + view.onScrollingFinished(ZLView.PageIndex.current); break; } onDrawStatic(canvas); @@ -160,7 +162,7 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl } @Override - public void startManualScrolling(int x, int y, ZLViewEnums.Direction direction) { + public void startManualScrolling(int x, int y, ZLView.Direction direction) { final AnimationProvider animator = getAnimationProvider(); animator.setup(direction, getWidth(), getMainAreaHeight()); animator.startManualScrolling(x, y); @@ -177,9 +179,9 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl } @Override - public void startAnimatedScrolling(ZLViewEnums.PageIndex pageIndex, int x, int y, ZLViewEnums.Direction direction, int speed) { + public void startAnimatedScrolling(ZLView.PageIndex pageIndex, int x, int y, ZLView.Direction direction, int speed) { final ZLView view = ZLApplication.Instance().getCurrentView(); - if (pageIndex == ZLViewEnums.PageIndex.current || !view.canScroll(pageIndex)) { + if (pageIndex == ZLView.PageIndex.current || !view.canScroll(pageIndex)) { return; } final AnimationProvider animator = getAnimationProvider(); @@ -191,9 +193,9 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl } @Override - public void startAnimatedScrolling(ZLViewEnums.PageIndex pageIndex, ZLViewEnums.Direction direction, int speed) { + public void startAnimatedScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed) { final ZLView view = ZLApplication.Instance().getCurrentView(); - if (pageIndex == ZLViewEnums.PageIndex.current || !view.canScroll(pageIndex)) { + if (pageIndex == ZLView.PageIndex.current || !view.canScroll(pageIndex)) { return; } final AnimationProvider animator = getAnimationProvider(); @@ -216,7 +218,7 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl postInvalidate(); } - void drawOnBitmap(Bitmap bitmap, ZLViewEnums.PageIndex index) { + void drawOnBitmap(Bitmap bitmap, ZLView.PageIndex index) { final ZLView view = ZLApplication.Instance().getCurrentView(); if (view == null) { return; @@ -277,7 +279,7 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl private void onDrawStatic(final Canvas canvas) { myBitmapManager.setSize(getWidth(), getMainAreaHeight()); - canvas.drawBitmap(myBitmapManager.getBitmap(ZLViewEnums.PageIndex.current), 0, 0, myPaint); + canvas.drawBitmap(myBitmapManager.getBitmap(ZLView.PageIndex.current), 0, 0, myPaint); drawFooter(canvas, null); new Thread() { @Override @@ -295,7 +297,7 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl ), view.isScrollbarShown() ? getVerticalScrollbarWidth() : 0 ); - view.preparePage(context, ZLViewEnums.PageIndex.next); + view.preparePage(context, ZLView.PageIndex.next); } }.start(); } @@ -488,12 +490,12 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl } final AnimationProvider animator = getAnimationProvider(); if (animator.inProgress()) { - final int from = view.getScrollbarThumbLength(ZLViewEnums.PageIndex.current); + final int from = view.getScrollbarThumbLength(ZLView.PageIndex.current); final int to = view.getScrollbarThumbLength(animator.getPageToScrollTo()); final int percent = animator.getScrolledPercent(); return (from * (100 - percent) + to * percent) / 100; } else { - return view.getScrollbarThumbLength(ZLViewEnums.PageIndex.current); + return view.getScrollbarThumbLength(ZLView.PageIndex.current); } } @@ -505,12 +507,12 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl } final AnimationProvider animator = getAnimationProvider(); if (animator.inProgress()) { - final int from = view.getScrollbarThumbPosition(ZLViewEnums.PageIndex.current); + final int from = view.getScrollbarThumbPosition(ZLView.PageIndex.current); final int to = view.getScrollbarThumbPosition(animator.getPageToScrollTo()); final int percent = animator.getScrolledPercent(); return (from * (100 - percent) + to * percent) / 100; } else { - return view.getScrollbarThumbPosition(ZLViewEnums.PageIndex.current); + return view.getScrollbarThumbPosition(ZLView.PageIndex.current); } }