1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 17:59:33 +02:00

enums moved to ZLViewEnums

This commit is contained in:
Dl Mv 2014-12-06 23:35:58 +03:00
parent 62dce62a70
commit 34404ff50d
17 changed files with 156 additions and 120 deletions

View file

@ -25,11 +25,10 @@ import org.geometerplus.zlibrary.core.application.*;
import org.geometerplus.zlibrary.core.drm.FileEncryptionInfo; import org.geometerplus.zlibrary.core.drm.FileEncryptionInfo;
import org.geometerplus.zlibrary.core.drm.EncryptionMethod; import org.geometerplus.zlibrary.core.drm.EncryptionMethod;
import org.geometerplus.zlibrary.core.util.*; 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.hyphenation.ZLTextHyphenator;
import org.geometerplus.zlibrary.text.model.ZLTextModel; import org.geometerplus.zlibrary.text.model.ZLTextModel;
import org.geometerplus.zlibrary.text.view.*; import org.geometerplus.zlibrary.text.view.*;
import org.geometerplus.fbreader.book.*; import org.geometerplus.fbreader.book.*;
import org.geometerplus.fbreader.bookmodel.*; import org.geometerplus.fbreader.bookmodel.*;
import org.geometerplus.fbreader.fbreader.options.*; import org.geometerplus.fbreader.fbreader.options.*;
@ -113,10 +112,10 @@ public final class FBReaderApp extends ZLApplication {
addAction(ActionCode.TURN_PAGE_FORWARD, new TurnPageAction(this, true)); addAction(ActionCode.TURN_PAGE_FORWARD, new TurnPageAction(this, true));
addAction(ActionCode.TURN_PAGE_BACK, new TurnPageAction(this, false)); addAction(ActionCode.TURN_PAGE_BACK, new TurnPageAction(this, false));
addAction(ActionCode.MOVE_CURSOR_UP, new MoveCursorAction(this, FBView.Direction.up)); addAction(ActionCode.MOVE_CURSOR_UP, new MoveCursorAction(this, ZLViewEnums.Direction.up));
addAction(ActionCode.MOVE_CURSOR_DOWN, new MoveCursorAction(this, FBView.Direction.down)); addAction(ActionCode.MOVE_CURSOR_DOWN, new MoveCursorAction(this, ZLViewEnums.Direction.down));
addAction(ActionCode.MOVE_CURSOR_LEFT, new MoveCursorAction(this, FBView.Direction.rightToLeft)); addAction(ActionCode.MOVE_CURSOR_LEFT, new MoveCursorAction(this, ZLViewEnums.Direction.rightToLeft));
addAction(ActionCode.MOVE_CURSOR_RIGHT, new MoveCursorAction(this, FBView.Direction.leftToRight)); addAction(ActionCode.MOVE_CURSOR_RIGHT, new MoveCursorAction(this, ZLViewEnums.Direction.leftToRight));
addAction(ActionCode.VOLUME_KEY_SCROLL_FORWARD, new VolumeKeyTurnPageAction(this, true)); addAction(ActionCode.VOLUME_KEY_SCROLL_FORWARD, new VolumeKeyTurnPageAction(this, true));
addAction(ActionCode.VOLUME_KEY_SCROLL_BACK, new VolumeKeyTurnPageAction(this, false)); addAction(ActionCode.VOLUME_KEY_SCROLL_BACK, new VolumeKeyTurnPageAction(this, false));

View file

@ -26,12 +26,13 @@ import org.geometerplus.zlibrary.core.filesystem.ZLResourceFile;
import org.geometerplus.zlibrary.core.fonts.FontEntry; import org.geometerplus.zlibrary.core.fonts.FontEntry;
import org.geometerplus.zlibrary.core.library.ZLibrary; import org.geometerplus.zlibrary.core.library.ZLibrary;
import org.geometerplus.zlibrary.core.util.ZLColor; import org.geometerplus.zlibrary.core.util.ZLColor;
import org.geometerplus.zlibrary.core.view.ZLPaintContext; 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.text.model.ZLTextModel; import org.geometerplus.zlibrary.text.model.ZLTextModel;
import org.geometerplus.zlibrary.text.view.*; import org.geometerplus.zlibrary.text.view.*;
import org.geometerplus.zlibrary.text.view.style.ZLTextStyleCollection; import org.geometerplus.zlibrary.text.view.style.ZLTextStyleCollection;
import org.geometerplus.fbreader.bookmodel.BookModel; import org.geometerplus.fbreader.bookmodel.BookModel;
import org.geometerplus.fbreader.bookmodel.FBHyperlinkType; import org.geometerplus.fbreader.bookmodel.FBHyperlinkType;
import org.geometerplus.fbreader.bookmodel.TOCTree; import org.geometerplus.fbreader.bookmodel.TOCTree;

View file

@ -19,13 +19,14 @@
package org.geometerplus.fbreader.fbreader; 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.ZLTextRegion;
import org.geometerplus.zlibrary.text.view.ZLTextWordRegionSoul; import org.geometerplus.zlibrary.text.view.ZLTextWordRegionSoul;
class MoveCursorAction extends FBAction { class MoveCursorAction extends FBAction {
private final FBView.Direction myDirection; private final ZLViewEnums.Direction myDirection;
MoveCursorAction(FBReaderApp fbreader, FBView.Direction direction) { MoveCursorAction(FBReaderApp fbreader, ZLViewEnums.Direction direction) {
super(fbreader); super(fbreader);
myDirection = direction; myDirection = direction;
} }

View file

@ -20,6 +20,7 @@
package org.geometerplus.fbreader.fbreader; package org.geometerplus.fbreader.fbreader;
import org.geometerplus.fbreader.fbreader.options.PageTurningOptions; import org.geometerplus.fbreader.fbreader.options.PageTurningOptions;
import org.geometerplus.zlibrary.core.view.ZLViewEnums;
class TurnPageAction extends FBAction { class TurnPageAction extends FBAction {
private final boolean myForward; private final boolean myForward;
@ -45,17 +46,17 @@ class TurnPageAction extends FBAction {
final int x = (Integer)params[0]; final int x = (Integer)params[0];
final int y = (Integer)params[1]; final int y = (Integer)params[1];
Reader.getViewWidget().startAnimatedScrolling( Reader.getViewWidget().startAnimatedScrolling(
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous, myForward ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous,
x, y, x, y,
preferences.Horizontal.getValue() preferences.Horizontal.getValue()
? FBView.Direction.rightToLeft : FBView.Direction.up, ? ZLViewEnums.Direction.rightToLeft : ZLViewEnums.Direction.up,
preferences.AnimationSpeed.getValue() preferences.AnimationSpeed.getValue()
); );
} else { } else {
Reader.getViewWidget().startAnimatedScrolling( Reader.getViewWidget().startAnimatedScrolling(
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous, myForward ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous,
preferences.Horizontal.getValue() preferences.Horizontal.getValue()
? FBView.Direction.rightToLeft : FBView.Direction.up, ? ZLViewEnums.Direction.rightToLeft : ZLViewEnums.Direction.up,
preferences.AnimationSpeed.getValue() preferences.AnimationSpeed.getValue()
); );
} }

View file

@ -20,6 +20,7 @@
package org.geometerplus.fbreader.fbreader; package org.geometerplus.fbreader.fbreader;
import org.geometerplus.fbreader.fbreader.options.PageTurningOptions; import org.geometerplus.fbreader.fbreader.options.PageTurningOptions;
import org.geometerplus.zlibrary.core.view.ZLViewEnums;
class VolumeKeyTurnPageAction extends FBAction { class VolumeKeyTurnPageAction extends FBAction {
private final boolean myForward; private final boolean myForward;
@ -33,9 +34,9 @@ class VolumeKeyTurnPageAction extends FBAction {
protected void run(Object ... params) { protected void run(Object ... params) {
final PageTurningOptions preferences = Reader.PageTurningOptions; final PageTurningOptions preferences = Reader.PageTurningOptions;
Reader.getViewWidget().startAnimatedScrolling( Reader.getViewWidget().startAnimatedScrolling(
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous, myForward ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous,
preferences.Horizontal.getValue() preferences.Horizontal.getValue()
? FBView.Direction.rightToLeft : FBView.Direction.up, ? ZLViewEnums.Direction.rightToLeft : ZLViewEnums.Direction.up,
preferences.AnimationSpeed.getValue() preferences.AnimationSpeed.getValue()
); );
} }

View file

@ -21,6 +21,7 @@ package org.geometerplus.fbreader.fbreader.options;
import org.geometerplus.zlibrary.core.options.*; import org.geometerplus.zlibrary.core.options.*;
import org.geometerplus.zlibrary.core.view.ZLView; import org.geometerplus.zlibrary.core.view.ZLView;
import org.geometerplus.zlibrary.core.view.ZLViewEnums;
public class PageTurningOptions { public class PageTurningOptions {
public static enum FingerScrollingType { public static enum FingerScrollingType {
@ -29,8 +30,8 @@ public class PageTurningOptions {
public final ZLEnumOption<FingerScrollingType> FingerScrolling = public final ZLEnumOption<FingerScrollingType> FingerScrolling =
new ZLEnumOption<FingerScrollingType>("Scrolling", "Finger", FingerScrollingType.byTapAndFlick); new ZLEnumOption<FingerScrollingType>("Scrolling", "Finger", FingerScrollingType.byTapAndFlick);
public final ZLEnumOption<ZLView.Animation> Animation = public final ZLEnumOption<ZLViewEnums.Animation> Animation =
new ZLEnumOption<ZLView.Animation>("Scrolling", "Animation", ZLView.Animation.slide); new ZLEnumOption<ZLViewEnums.Animation>("Scrolling", "Animation", ZLViewEnums.Animation.slide);
public final ZLIntegerRangeOption AnimationSpeed = public final ZLIntegerRangeOption AnimationSpeed =
new ZLIntegerRangeOption("Scrolling", "AnimationSpeed", 1, 10, 7); new ZLIntegerRangeOption("Scrolling", "AnimationSpeed", 1, 10, 7);

View file

@ -20,6 +20,8 @@
package org.geometerplus.zlibrary.core.view; package org.geometerplus.zlibrary.core.view;
import org.geometerplus.zlibrary.core.application.ZLApplication; 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 {
public final ZLApplication Application; public final ZLApplication Application;
@ -52,44 +54,6 @@ abstract public class ZLView {
abstract public FooterArea getFooterArea(); abstract public FooterArea getFooterArea();
public static enum PageIndex {
previous, current, next;
public PageIndex getNext() {
switch (this) {
case previous:
return current;
case current:
return next;
default:
return null;
}
}
public PageIndex getPrevious() {
switch (this) {
case next:
return current;
case current:
return previous;
default:
return null;
}
}
};
public static enum Direction {
leftToRight(true), rightToLeft(true), up(false), down(false);
public final boolean IsHorizontal;
Direction(boolean isHorizontal) {
IsHorizontal = isHorizontal;
}
};
public static enum Animation {
none, curl, slide, slideOldStyle, shift
}
public abstract Animation getAnimationType(); public abstract Animation getAnimationType();
abstract public void preparePage(ZLPaintContext context, PageIndex pageIndex); abstract public void preparePage(ZLPaintContext context, PageIndex pageIndex);

View file

@ -0,0 +1,63 @@
/*
* Copyright (C) 2007-2014 Geometer Plus <contact@geometerplus.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
package org.geometerplus.zlibrary.core.view;
abstract public class ZLViewEnums {
public static enum PageIndex {
previous, current, next;
public PageIndex getNext() {
switch (this) {
case previous:
return current;
case current:
return next;
default:
return null;
}
}
public PageIndex getPrevious() {
switch (this) {
case next:
return current;
case current:
return previous;
default:
return null;
}
}
};
public static enum Direction {
leftToRight(true), rightToLeft(true), up(false), down(false);
public final boolean IsHorizontal;
Direction(boolean isHorizontal) {
IsHorizontal = isHorizontal;
}
};
public static enum Animation {
none, curl, slide, slideOldStyle, shift
}
}

View file

@ -23,9 +23,9 @@ public interface ZLViewWidget {
void reset(); void reset();
void repaint(); void repaint();
void startManualScrolling(int x, int y, ZLView.Direction direction); void startManualScrolling(int x, int y, ZLViewEnums.Direction direction);
void scrollManuallyTo(int x, int y); void scrollManuallyTo(int x, int y);
void startAnimatedScrolling(ZLView.PageIndex pageIndex, int x, int y, ZLView.Direction direction, int speed); void startAnimatedScrolling(ZLViewEnums.PageIndex pageIndex, int x, int y, ZLViewEnums.Direction direction, int speed);
void startAnimatedScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed); void startAnimatedScrolling(ZLViewEnums.PageIndex pageIndex, ZLViewEnums.Direction direction, int speed);
void startAnimatedScrolling(int x, int y, int speed); void startAnimatedScrolling(int x, int y, int speed);
} }

View file

@ -21,6 +21,8 @@ package org.geometerplus.zlibrary.text.view;
import java.util.*; import java.util.*;
import org.geometerplus.zlibrary.core.view.ZLViewEnums;
final class ZLTextElementAreaVector { final class ZLTextElementAreaVector {
private final List<ZLTextElementArea> myAreas = private final List<ZLTextElementArea> myAreas =
Collections.synchronizedList(new ArrayList<ZLTextElementArea>()); Collections.synchronizedList(new ArrayList<ZLTextElementArea>());
@ -166,7 +168,7 @@ final class ZLTextElementAreaVector {
return bestRegion; return bestRegion;
} }
protected ZLTextRegion nextRegion(ZLTextRegion currentRegion, ZLTextView.Direction direction, ZLTextRegion.Filter filter) { protected ZLTextRegion nextRegion(ZLTextRegion currentRegion, ZLViewEnums.Direction direction, ZLTextRegion.Filter filter) {
synchronized (myElementRegions) { synchronized (myElementRegions) {
if (myElementRegions.isEmpty()) { if (myElementRegions.isEmpty()) {
return null; return null;

View file

@ -25,8 +25,9 @@ import org.geometerplus.zlibrary.core.application.ZLApplication;
import org.geometerplus.zlibrary.core.filesystem.ZLFile; import org.geometerplus.zlibrary.core.filesystem.ZLFile;
import org.geometerplus.zlibrary.core.util.RationalNumber; import org.geometerplus.zlibrary.core.util.RationalNumber;
import org.geometerplus.zlibrary.core.util.ZLColor; import org.geometerplus.zlibrary.core.util.ZLColor;
import org.geometerplus.zlibrary.core.view.ZLPaintContext; 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.text.model.*; import org.geometerplus.zlibrary.text.model.*;
import org.geometerplus.zlibrary.text.hyphenation.*; import org.geometerplus.zlibrary.text.hyphenation.*;
import org.geometerplus.zlibrary.text.view.style.ZLTextStyleCollection; import org.geometerplus.zlibrary.text.view.style.ZLTextStyleCollection;

View file

@ -26,6 +26,7 @@ import android.util.FloatMath;
import org.geometerplus.zlibrary.core.library.ZLibrary; import org.geometerplus.zlibrary.core.library.ZLibrary;
import org.geometerplus.zlibrary.core.view.ZLView; import org.geometerplus.zlibrary.core.view.ZLView;
import org.geometerplus.zlibrary.core.view.ZLViewEnums;
abstract class AnimationProvider { abstract class AnimationProvider {
static enum Mode { static enum Mode {
@ -47,7 +48,7 @@ abstract class AnimationProvider {
protected int myStartY; protected int myStartY;
protected int myEndX; protected int myEndX;
protected int myEndY; protected int myEndY;
protected ZLView.Direction myDirection; protected ZLViewEnums.Direction myDirection;
protected float mySpeed; protected float mySpeed;
protected int myWidth; protected int myWidth;
@ -87,7 +88,7 @@ abstract class AnimationProvider {
return; return;
} }
if (getPageToScrollTo(x, y) == ZLView.PageIndex.current) { if (getPageToScrollTo(x, y) == ZLViewEnums.PageIndex.current) {
return; return;
} }
@ -123,7 +124,7 @@ abstract class AnimationProvider {
} }
myDrawInfos.clear(); myDrawInfos.clear();
if (getPageToScrollTo() == ZLView.PageIndex.previous) { if (getPageToScrollTo() == ZLViewEnums.PageIndex.previous) {
forward = !forward; forward = !forward;
} }
@ -141,7 +142,7 @@ abstract class AnimationProvider {
startAnimatedScrollingInternal(speed); startAnimatedScrollingInternal(speed);
} }
public void startAnimatedScrolling(ZLView.PageIndex pageIndex, Integer x, Integer y, int speed) { public void startAnimatedScrolling(ZLViewEnums.PageIndex pageIndex, Integer x, Integer y, int speed) {
if (myMode.Auto) { if (myMode.Auto) {
return; return;
} }
@ -152,11 +153,11 @@ abstract class AnimationProvider {
switch (myDirection) { switch (myDirection) {
case up: case up:
case rightToLeft: case rightToLeft:
mySpeed = pageIndex == ZLView.PageIndex.next ? -15 : 15; mySpeed = pageIndex == ZLViewEnums.PageIndex.next ? -15 : 15;
break; break;
case leftToRight: case leftToRight:
case down: case down:
mySpeed = pageIndex == ZLView.PageIndex.next ? 15 : -15; mySpeed = pageIndex == ZLViewEnums.PageIndex.next ? 15 : -15;
break; break;
} }
setupAnimatedScrollingStart(x, y); setupAnimatedScrollingStart(x, y);
@ -174,7 +175,7 @@ abstract class AnimationProvider {
return myDirection.IsHorizontal ? myEndX - myStartX : myEndY - myStartY; return myDirection.IsHorizontal ? myEndX - myStartX : myEndY - myStartY;
} }
final void setup(ZLView.Direction direction, int width, int height) { final void setup(ZLViewEnums.Direction direction, int width, int height) {
myDirection = direction; myDirection = direction;
myWidth = width; myWidth = width;
myHeight = height; myHeight = height;
@ -214,14 +215,14 @@ abstract class AnimationProvider {
protected abstract void drawInternal(Canvas canvas); protected abstract void drawInternal(Canvas canvas);
abstract ZLView.PageIndex getPageToScrollTo(int x, int y); abstract ZLViewEnums.PageIndex getPageToScrollTo(int x, int y);
final ZLView.PageIndex getPageToScrollTo() { final ZLViewEnums.PageIndex getPageToScrollTo() {
return getPageToScrollTo(myEndX, myEndY); return getPageToScrollTo(myEndX, myEndY);
} }
protected Bitmap getBitmapFrom() { protected Bitmap getBitmapFrom() {
return myBitmapManager.getBitmap(ZLView.PageIndex.current); return myBitmapManager.getBitmap(ZLViewEnums.PageIndex.current);
} }
protected Bitmap getBitmapTo() { protected Bitmap getBitmapTo() {

View file

@ -22,11 +22,12 @@ package org.geometerplus.zlibrary.ui.android.view;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import org.geometerplus.zlibrary.core.view.ZLView; import org.geometerplus.zlibrary.core.view.ZLView;
import org.geometerplus.zlibrary.core.view.ZLViewEnums;
class BitmapManager { class BitmapManager {
private final int SIZE = 2; private final int SIZE = 2;
private final Bitmap[] myBitmaps = new Bitmap[SIZE]; private final Bitmap[] myBitmaps = new Bitmap[SIZE];
private final ZLView.PageIndex[] myIndexes = new ZLView.PageIndex[SIZE]; private final ZLViewEnums.PageIndex[] myIndexes = new ZLViewEnums.PageIndex[SIZE];
private int myWidth; private int myWidth;
private int myHeight; private int myHeight;
@ -51,7 +52,7 @@ class BitmapManager {
} }
} }
Bitmap getBitmap(ZLView.PageIndex index) { Bitmap getBitmap(ZLViewEnums.PageIndex index) {
for (int i = 0; i < SIZE; ++i) { for (int i = 0; i < SIZE; ++i) {
if (index == myIndexes[i]) { if (index == myIndexes[i]) {
return myBitmaps[i]; return myBitmaps[i];
@ -72,14 +73,14 @@ class BitmapManager {
return myBitmaps[iIndex]; return myBitmaps[iIndex];
} }
private int getInternalIndex(ZLView.PageIndex index) { private int getInternalIndex(ZLViewEnums.PageIndex index) {
for (int i = 0; i < SIZE; ++i) { for (int i = 0; i < SIZE; ++i) {
if (myIndexes[i] == null) { if (myIndexes[i] == null) {
return i; return i;
} }
} }
for (int i = 0; i < SIZE; ++i) { for (int i = 0; i < SIZE; ++i) {
if (myIndexes[i] != ZLView.PageIndex.current) { if (myIndexes[i] != ZLViewEnums.PageIndex.current) {
return i; return i;
} }
} }

View file

@ -23,7 +23,7 @@ import android.graphics.*;
import android.util.FloatMath; import android.util.FloatMath;
import org.geometerplus.zlibrary.core.view.ZLView; import org.geometerplus.zlibrary.core.view.ZLView;
import org.geometerplus.zlibrary.core.view.ZLViewEnums;
import org.geometerplus.zlibrary.ui.android.util.ZLAndroidColorUtil; import org.geometerplus.zlibrary.ui.android.util.ZLAndroidColorUtil;
class CurlAnimationProvider extends AnimationProvider { class CurlAnimationProvider extends AnimationProvider {
@ -208,22 +208,22 @@ class CurlAnimationProvider extends AnimationProvider {
} }
@Override @Override
ZLView.PageIndex getPageToScrollTo(int x, int y) { ZLViewEnums.PageIndex getPageToScrollTo(int x, int y) {
if (myDirection == null) { if (myDirection == null) {
return ZLView.PageIndex.current; return ZLViewEnums.PageIndex.current;
} }
switch (myDirection) { switch (myDirection) {
case leftToRight: case leftToRight:
return myStartX < myWidth / 2 ? ZLView.PageIndex.next : ZLView.PageIndex.previous; return myStartX < myWidth / 2 ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous;
case rightToLeft: case rightToLeft:
return myStartX < myWidth / 2 ? ZLView.PageIndex.previous : ZLView.PageIndex.next; return myStartX < myWidth / 2 ? ZLViewEnums.PageIndex.previous : ZLViewEnums.PageIndex.next;
case up: case up:
return myStartY < myHeight / 2 ? ZLView.PageIndex.previous : ZLView.PageIndex.next; return myStartY < myHeight / 2 ? ZLViewEnums.PageIndex.previous : ZLViewEnums.PageIndex.next;
case down: case down:
return myStartY < myHeight / 2 ? ZLView.PageIndex.next : ZLView.PageIndex.previous; return myStartY < myHeight / 2 ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous;
} }
return ZLView.PageIndex.current; return ZLViewEnums.PageIndex.current;
} }
@Override @Override

View file

@ -22,6 +22,7 @@ package org.geometerplus.zlibrary.ui.android.view;
import android.graphics.*; import android.graphics.*;
import org.geometerplus.zlibrary.core.view.ZLView; import org.geometerplus.zlibrary.core.view.ZLView;
import org.geometerplus.zlibrary.core.view.ZLViewEnums;
class NoneAnimationProvider extends AnimationProvider { class NoneAnimationProvider extends AnimationProvider {
private final Paint myPaint = new Paint(); private final Paint myPaint = new Paint();
@ -60,22 +61,22 @@ class NoneAnimationProvider extends AnimationProvider {
} }
@Override @Override
ZLView.PageIndex getPageToScrollTo(int x, int y) { ZLViewEnums.PageIndex getPageToScrollTo(int x, int y) {
if (myDirection == null) { if (myDirection == null) {
return ZLView.PageIndex.current; return ZLViewEnums.PageIndex.current;
} }
switch (myDirection) { switch (myDirection) {
case rightToLeft: case rightToLeft:
return myStartX < x ? ZLView.PageIndex.previous : ZLView.PageIndex.next; return myStartX < x ? ZLViewEnums.PageIndex.previous : ZLViewEnums.PageIndex.next;
case leftToRight: case leftToRight:
return myStartX < x ? ZLView.PageIndex.next : ZLView.PageIndex.previous; return myStartX < x ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous;
case up: case up:
return myStartY < y ? ZLView.PageIndex.previous : ZLView.PageIndex.next; return myStartY < y ? ZLViewEnums.PageIndex.previous : ZLViewEnums.PageIndex.next;
case down: case down:
return myStartY < y ? ZLView.PageIndex.next : ZLView.PageIndex.previous; return myStartY < y ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous;
} }
return ZLView.PageIndex.current; return ZLViewEnums.PageIndex.current;
} }
@Override @Override

View file

@ -20,6 +20,7 @@
package org.geometerplus.zlibrary.ui.android.view; package org.geometerplus.zlibrary.ui.android.view;
import org.geometerplus.zlibrary.core.view.ZLView; import org.geometerplus.zlibrary.core.view.ZLView;
import org.geometerplus.zlibrary.core.view.ZLViewEnums;
abstract class SimpleAnimationProvider extends AnimationProvider { abstract class SimpleAnimationProvider extends AnimationProvider {
private float mySpeedFactor; private float mySpeedFactor;
@ -29,22 +30,22 @@ abstract class SimpleAnimationProvider extends AnimationProvider {
} }
@Override @Override
ZLView.PageIndex getPageToScrollTo(int x, int y) { ZLViewEnums.PageIndex getPageToScrollTo(int x, int y) {
if (myDirection == null) { if (myDirection == null) {
return ZLView.PageIndex.current; return ZLViewEnums.PageIndex.current;
} }
switch (myDirection) { switch (myDirection) {
case rightToLeft: case rightToLeft:
return myStartX < x ? ZLView.PageIndex.previous : ZLView.PageIndex.next; return myStartX < x ? ZLViewEnums.PageIndex.previous : ZLViewEnums.PageIndex.next;
case leftToRight: case leftToRight:
return myStartX < x ? ZLView.PageIndex.next : ZLView.PageIndex.previous; return myStartX < x ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous;
case up: case up:
return myStartY < y ? ZLView.PageIndex.previous : ZLView.PageIndex.next; return myStartY < y ? ZLViewEnums.PageIndex.previous : ZLViewEnums.PageIndex.next;
case down: case down:
return myStartY < y ? ZLView.PageIndex.next : ZLView.PageIndex.previous; return myStartY < y ? ZLViewEnums.PageIndex.next : ZLViewEnums.PageIndex.previous;
} }
return ZLView.PageIndex.current; return ZLViewEnums.PageIndex.current;
} }
@Override @Override

View file

@ -26,9 +26,7 @@ import android.view.*;
import org.geometerplus.zlibrary.core.application.ZLApplication; import org.geometerplus.zlibrary.core.application.ZLApplication;
import org.geometerplus.zlibrary.core.application.ZLKeyBindings; import org.geometerplus.zlibrary.core.application.ZLKeyBindings;
import org.geometerplus.zlibrary.core.view.ZLView; import org.geometerplus.zlibrary.core.view.*;
import org.geometerplus.zlibrary.core.view.ZLViewWidget;
import org.geometerplus.android.fbreader.FBReader; import org.geometerplus.android.fbreader.FBReader;
public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongClickListener { public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongClickListener {
@ -66,7 +64,7 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
if (myScreenIsTouched) { if (myScreenIsTouched) {
final ZLView view = ZLApplication.Instance().getCurrentView(); final ZLView view = ZLApplication.Instance().getCurrentView();
myScreenIsTouched = false; myScreenIsTouched = false;
view.onScrollingFinished(ZLView.PageIndex.current); view.onScrollingFinished(ZLViewEnums.PageIndex.current);
} }
} }
@ -92,9 +90,9 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
} }
private AnimationProvider myAnimationProvider; private AnimationProvider myAnimationProvider;
private ZLView.Animation myAnimationType; private ZLViewEnums.Animation myAnimationType;
private AnimationProvider getAnimationProvider() { private AnimationProvider getAnimationProvider() {
final ZLView.Animation type = ZLApplication.Instance().getCurrentView().getAnimationType(); final ZLViewEnums.Animation type = ZLApplication.Instance().getCurrentView().getAnimationType();
if (myAnimationProvider == null || myAnimationType != type) { if (myAnimationProvider == null || myAnimationType != type) {
myAnimationType = type; myAnimationType = type;
switch (type) { switch (type) {
@ -137,14 +135,14 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
switch (oldMode) { switch (oldMode) {
case AnimatedScrollingForward: case AnimatedScrollingForward:
{ {
final ZLView.PageIndex index = animator.getPageToScrollTo(); final ZLViewEnums.PageIndex index = animator.getPageToScrollTo();
myBitmapManager.shift(index == ZLView.PageIndex.next); myBitmapManager.shift(index == ZLViewEnums.PageIndex.next);
view.onScrollingFinished(index); view.onScrollingFinished(index);
ZLApplication.Instance().onRepaintFinished(); ZLApplication.Instance().onRepaintFinished();
break; break;
} }
case AnimatedScrollingBackward: case AnimatedScrollingBackward:
view.onScrollingFinished(ZLView.PageIndex.current); view.onScrollingFinished(ZLViewEnums.PageIndex.current);
break; break;
} }
onDrawStatic(canvas); onDrawStatic(canvas);
@ -162,7 +160,7 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
} }
@Override @Override
public void startManualScrolling(int x, int y, ZLView.Direction direction) { public void startManualScrolling(int x, int y, ZLViewEnums.Direction direction) {
final AnimationProvider animator = getAnimationProvider(); final AnimationProvider animator = getAnimationProvider();
animator.setup(direction, getWidth(), getMainAreaHeight()); animator.setup(direction, getWidth(), getMainAreaHeight());
animator.startManualScrolling(x, y); animator.startManualScrolling(x, y);
@ -179,9 +177,9 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
} }
@Override @Override
public void startAnimatedScrolling(ZLView.PageIndex pageIndex, int x, int y, ZLView.Direction direction, int speed) { public void startAnimatedScrolling(ZLViewEnums.PageIndex pageIndex, int x, int y, ZLViewEnums.Direction direction, int speed) {
final ZLView view = ZLApplication.Instance().getCurrentView(); final ZLView view = ZLApplication.Instance().getCurrentView();
if (pageIndex == ZLView.PageIndex.current || !view.canScroll(pageIndex)) { if (pageIndex == ZLViewEnums.PageIndex.current || !view.canScroll(pageIndex)) {
return; return;
} }
final AnimationProvider animator = getAnimationProvider(); final AnimationProvider animator = getAnimationProvider();
@ -193,9 +191,9 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
} }
@Override @Override
public void startAnimatedScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed) { public void startAnimatedScrolling(ZLViewEnums.PageIndex pageIndex, ZLViewEnums.Direction direction, int speed) {
final ZLView view = ZLApplication.Instance().getCurrentView(); final ZLView view = ZLApplication.Instance().getCurrentView();
if (pageIndex == ZLView.PageIndex.current || !view.canScroll(pageIndex)) { if (pageIndex == ZLViewEnums.PageIndex.current || !view.canScroll(pageIndex)) {
return; return;
} }
final AnimationProvider animator = getAnimationProvider(); final AnimationProvider animator = getAnimationProvider();
@ -218,7 +216,7 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
postInvalidate(); postInvalidate();
} }
void drawOnBitmap(Bitmap bitmap, ZLView.PageIndex index) { void drawOnBitmap(Bitmap bitmap, ZLViewEnums.PageIndex index) {
final ZLView view = ZLApplication.Instance().getCurrentView(); final ZLView view = ZLApplication.Instance().getCurrentView();
if (view == null) { if (view == null) {
return; return;
@ -279,7 +277,7 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
private void onDrawStatic(final Canvas canvas) { private void onDrawStatic(final Canvas canvas) {
myBitmapManager.setSize(getWidth(), getMainAreaHeight()); myBitmapManager.setSize(getWidth(), getMainAreaHeight());
canvas.drawBitmap(myBitmapManager.getBitmap(ZLView.PageIndex.current), 0, 0, myPaint); canvas.drawBitmap(myBitmapManager.getBitmap(ZLViewEnums.PageIndex.current), 0, 0, myPaint);
drawFooter(canvas, null); drawFooter(canvas, null);
new Thread() { new Thread() {
@Override @Override
@ -297,7 +295,7 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
), ),
view.isScrollbarShown() ? getVerticalScrollbarWidth() : 0 view.isScrollbarShown() ? getVerticalScrollbarWidth() : 0
); );
view.preparePage(context, ZLView.PageIndex.next); view.preparePage(context, ZLViewEnums.PageIndex.next);
} }
}.start(); }.start();
} }
@ -490,12 +488,12 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
} }
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(ZLViewEnums.PageIndex.current);
final int to = view.getScrollbarThumbLength(animator.getPageToScrollTo()); 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 {
return view.getScrollbarThumbLength(ZLView.PageIndex.current); return view.getScrollbarThumbLength(ZLViewEnums.PageIndex.current);
} }
} }
@ -507,12 +505,12 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
} }
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(ZLViewEnums.PageIndex.current);
final int to = view.getScrollbarThumbPosition(animator.getPageToScrollTo()); 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 {
return view.getScrollbarThumbPosition(ZLView.PageIndex.current); return view.getScrollbarThumbPosition(ZLViewEnums.PageIndex.current);
} }
} }