mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
view paint refactoring
This commit is contained in:
parent
fb12829e58
commit
b84a11abc9
16 changed files with 241 additions and 162 deletions
|
@ -93,6 +93,7 @@ public final class FBView extends ZLTextView {
|
||||||
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.HyperlinkFilter);
|
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.HyperlinkFilter);
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
selectRegion(region);
|
selectRegion(region);
|
||||||
|
myReader.resetView();
|
||||||
myReader.repaintView();
|
myReader.repaintView();
|
||||||
myReader.doAction(ActionCode.PROCESS_HYPERLINK);
|
myReader.doAction(ActionCode.PROCESS_HYPERLINK);
|
||||||
return true;
|
return true;
|
||||||
|
@ -183,7 +184,7 @@ public final class FBView extends ZLTextView {
|
||||||
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;
|
||||||
final Direction direction = horizontal ? Direction.rightToLeft : Direction.up;
|
final Direction direction = horizontal ? Direction.rightToLeft : Direction.up;
|
||||||
if (diff > 0) {
|
if (diff >= 0) {
|
||||||
final ZLTextWordCursor cursor = getStartCursor();
|
final ZLTextWordCursor cursor = getStartCursor();
|
||||||
if (cursor == null || cursor.isNull()) {
|
if (cursor == null || cursor.isNull()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -191,7 +192,7 @@ public final class FBView extends ZLTextView {
|
||||||
if (!cursor.isStartOfParagraph() || !cursor.getParagraphCursor().isFirst()) {
|
if (!cursor.isStartOfParagraph() || !cursor.getParagraphCursor().isFirst()) {
|
||||||
myReader.scrollViewManually(myStartX, myStartY, x, y, direction);
|
myReader.scrollViewManually(myStartX, myStartY, x, y, direction);
|
||||||
}
|
}
|
||||||
} else if (diff < 0) {
|
} else {
|
||||||
final ZLTextWordCursor cursor = getEndCursor();
|
final ZLTextWordCursor cursor = getEndCursor();
|
||||||
if (cursor == null || cursor.isNull()) {
|
if (cursor == null || cursor.isNull()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -199,8 +200,6 @@ public final class FBView extends ZLTextView {
|
||||||
if (!cursor.isEndOfParagraph() || !cursor.getParagraphCursor().isLast()) {
|
if (!cursor.isEndOfParagraph() || !cursor.getParagraphCursor().isLast()) {
|
||||||
myReader.scrollViewManually(myStartX, myStartY, x, y, direction);
|
myReader.scrollViewManually(myStartX, myStartY, x, y, direction);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
myReader.scrollViewToCenter();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -243,14 +242,7 @@ public final class FBView extends ZLTextView {
|
||||||
Math.abs(diff) < minDiff
|
Math.abs(diff) < minDiff
|
||||||
? PageIndex.current
|
? PageIndex.current
|
||||||
: (diff < 0 ? PageIndex.next : PageIndex.previous);
|
: (diff < 0 ? PageIndex.next : PageIndex.previous);
|
||||||
if (getAnimationType() != Animation.none) {
|
startAutoScrolling(pageIndex, horizontal ? Direction.rightToLeft : Direction.up, ScrollingPreferences.Instance().AnimationSpeedOption.getValue());
|
||||||
startAutoScrolling(pageIndex, horizontal ? Direction.rightToLeft : Direction.up, ScrollingPreferences.Instance().AnimationSpeedOption.getValue());
|
|
||||||
} else {
|
|
||||||
myReader.scrollViewToCenter();
|
|
||||||
onScrollingFinished(pageIndex);
|
|
||||||
myReader.repaintView();
|
|
||||||
setScrollingActive(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -268,6 +260,7 @@ public final class FBView extends ZLTextView {
|
||||||
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.AnyRegionFilter);
|
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.AnyRegionFilter);
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
selectRegion(region);
|
selectRegion(region);
|
||||||
|
myReader.resetView();
|
||||||
myReader.repaintView();
|
myReader.repaintView();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -286,6 +279,7 @@ public final class FBView extends ZLTextView {
|
||||||
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.AnyRegionFilter);
|
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextElementRegion.AnyRegionFilter);
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
selectRegion(region);
|
selectRegion(region);
|
||||||
|
myReader.resetView();
|
||||||
myReader.repaintView();
|
myReader.repaintView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,6 +324,7 @@ public final class FBView extends ZLTextView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
myReader.resetView();
|
||||||
myReader.repaintView();
|
myReader.repaintView();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -562,6 +557,7 @@ public final class FBView extends ZLTextView {
|
||||||
} else {
|
} else {
|
||||||
gotoPage(page);
|
gotoPage(page);
|
||||||
}
|
}
|
||||||
|
myReader.resetView();
|
||||||
myReader.repaintView();
|
myReader.repaintView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,34 +56,22 @@ class TurnPageAction extends FBAction {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
||||||
final FBView view = Reader.getTextView();
|
Reader.getTextView().startAutoScrolling(
|
||||||
if (view.getAnimationType() != FBView.Animation.none) {
|
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
||||||
view.startAutoScrolling(
|
preferences.HorizontalOption.getValue()
|
||||||
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
||||||
preferences.HorizontalOption.getValue()
|
preferences.AnimationSpeedOption.getValue()
|
||||||
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
);
|
||||||
preferences.AnimationSpeedOption.getValue()
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
view.scrollPage(myForward, FBView.ScrollingMode.NO_OVERLAPPING, 0);
|
|
||||||
Reader.repaintView();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runWithCoordinates(int x, int y) {
|
public void runWithCoordinates(int x, int y) {
|
||||||
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
||||||
final FBView view = Reader.getTextView();
|
Reader.getTextView().startAutoScrolling(
|
||||||
if (view.getAnimationType() != FBView.Animation.none) {
|
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
||||||
view.startAutoScrolling(
|
preferences.HorizontalOption.getValue()
|
||||||
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
||||||
preferences.HorizontalOption.getValue()
|
x, y,
|
||||||
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
preferences.AnimationSpeedOption.getValue()
|
||||||
x, y,
|
);
|
||||||
preferences.AnimationSpeedOption.getValue()
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
view.scrollPage(myForward, FBView.ScrollingMode.NO_OVERLAPPING, 0);
|
|
||||||
Reader.repaintView();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,17 +54,11 @@ class VolumeKeyTurnPageAction extends FBAction {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final FBView view = Reader.getTextView();
|
Reader.getTextView().startAutoScrolling(
|
||||||
if (view.getAnimationType() != FBView.Animation.none) {
|
forward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
||||||
view.startAutoScrolling(
|
preferences.HorizontalOption.getValue()
|
||||||
forward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
||||||
preferences.HorizontalOption.getValue()
|
preferences.AnimationSpeedOption.getValue()
|
||||||
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
);
|
||||||
preferences.AnimationSpeedOption.getValue()
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
view.scrollPage(forward, FBView.ScrollingMode.NO_OVERLAPPING, 0);
|
|
||||||
Reader.repaintView();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ public abstract class ZLApplication {
|
||||||
protected final void setView(ZLView view) {
|
protected final void setView(ZLView view) {
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
myView = view;
|
myView = view;
|
||||||
|
resetView();
|
||||||
repaintView();
|
repaintView();
|
||||||
onViewChanged();
|
onViewChanged();
|
||||||
}
|
}
|
||||||
|
@ -62,6 +63,12 @@ public abstract class ZLApplication {
|
||||||
setView(myView);
|
setView(myView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void resetView() {
|
||||||
|
if (myWindow != null) {
|
||||||
|
myWindow.resetView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public final void repaintView() {
|
public final void repaintView() {
|
||||||
if (myWindow != null) {
|
if (myWindow != null) {
|
||||||
myWindow.repaintView();
|
myWindow.repaintView();
|
||||||
|
@ -74,12 +81,6 @@ public abstract class ZLApplication {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void scrollViewToCenter() {
|
|
||||||
if (myWindow != null) {
|
|
||||||
myWindow.scrollViewToCenter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed) {
|
public final void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed) {
|
||||||
if (myWindow != null) {
|
if (myWindow != null) {
|
||||||
myWindow.startViewAutoScrolling(pageIndex, direction, speed);
|
myWindow.startViewAutoScrolling(pageIndex, direction, speed);
|
||||||
|
|
|
@ -35,9 +35,9 @@ abstract public class ZLApplicationWindow {
|
||||||
|
|
||||||
abstract protected void refreshMenu();
|
abstract protected void refreshMenu();
|
||||||
|
|
||||||
|
abstract protected void resetView();
|
||||||
abstract protected void repaintView();
|
abstract protected void repaintView();
|
||||||
abstract protected void scrollViewManually(int startX, int startY, int endX, int endY, ZLView.Direction direction);
|
abstract protected void scrollViewManually(int startX, int startY, int endX, int endY, ZLView.Direction direction);
|
||||||
abstract protected void scrollViewToCenter();
|
|
||||||
abstract protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed);
|
abstract protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed);
|
||||||
abstract protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int x, int y, int speed);
|
abstract protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int x, int y, int speed);
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,29 @@ abstract public class ZLView {
|
||||||
abstract public FooterArea getFooterArea();
|
abstract public FooterArea getFooterArea();
|
||||||
|
|
||||||
public static enum PageIndex {
|
public static enum PageIndex {
|
||||||
current, previous, next
|
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 {
|
public static enum Direction {
|
||||||
leftToRight(true), rightToLeft(true), up(false), down(false);
|
leftToRight(true), rightToLeft(true), up(false), down(false);
|
||||||
|
|
|
@ -74,6 +74,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
myCurrentPage.moveStartCursor(ZLTextParagraphCursor.cursor(myModel, 0));
|
myCurrentPage.moveStartCursor(ZLTextParagraphCursor.cursor(myModel, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ZLApplication.Instance().resetView();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLTextModel getModel() {
|
public ZLTextModel getModel() {
|
||||||
|
@ -126,6 +127,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
if (myCurrentPage.StartCursor.isNull()) {
|
if (myCurrentPage.StartCursor.isNull()) {
|
||||||
preparePaintInfo(myCurrentPage);
|
preparePaintInfo(myCurrentPage);
|
||||||
}
|
}
|
||||||
|
ZLApplication.Instance().resetView();
|
||||||
ZLApplication.Instance().repaintView();
|
ZLApplication.Instance().repaintView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,6 +152,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
(backward ? myModel.getLastMark() : myModel.getFirstMark()) :
|
(backward ? myModel.getLastMark() : myModel.getFirstMark()) :
|
||||||
(backward ? myModel.getPreviousMark(mark) : myModel.getNextMark(mark)));
|
(backward ? myModel.getPreviousMark(mark) : myModel.getNextMark(mark)));
|
||||||
}
|
}
|
||||||
|
ZLApplication.Instance().resetView();
|
||||||
ZLApplication.Instance().repaintView();
|
ZLApplication.Instance().repaintView();
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
|
@ -183,6 +186,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
if (!findResultsAreEmpty()) {
|
if (!findResultsAreEmpty()) {
|
||||||
myModel.removeAllMarks();
|
myModel.removeAllMarks();
|
||||||
rebuildPaintInfo();
|
rebuildPaintInfo();
|
||||||
|
ZLApplication.Instance().resetView();
|
||||||
ZLApplication.Instance().repaintView();
|
ZLApplication.Instance().repaintView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1285,6 +1289,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
@Override
|
@Override
|
||||||
public boolean onFingerMove(int x, int y) {
|
public boolean onFingerMove(int x, int y) {
|
||||||
if (mySelectionModel.extendTo(x, y)) {
|
if (mySelectionModel.extendTo(x, y)) {
|
||||||
|
ZLApplication.Instance().resetView();
|
||||||
ZLApplication.Instance().repaintView();
|
ZLApplication.Instance().repaintView();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1299,12 +1304,15 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
|
|
||||||
protected abstract boolean isSelectionEnabled();
|
protected abstract boolean isSelectionEnabled();
|
||||||
|
|
||||||
|
/*
|
||||||
protected void activateSelection(int x, int y) {
|
protected void activateSelection(int x, int y) {
|
||||||
if (isSelectionEnabled()) {
|
if (isSelectionEnabled()) {
|
||||||
mySelectionModel.activate(x, y);
|
mySelectionModel.activate(x, y);
|
||||||
|
ZLApplication.Instance().resetView();
|
||||||
ZLApplication.Instance().repaintView();
|
ZLApplication.Instance().repaintView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
private ZLTextElementRegion mySelectedRegion;
|
private ZLTextElementRegion mySelectedRegion;
|
||||||
private boolean myHighlightSelectedRegion = true;
|
private boolean myHighlightSelectedRegion = true;
|
||||||
|
|
|
@ -67,6 +67,13 @@ public final class ZLAndroidApplicationWindow extends ZLApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void resetView() {
|
||||||
|
final ZLAndroidWidget widget =
|
||||||
|
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
||||||
|
// I'm not sure about threads, so postInvalidate() is used instead of invalidate()
|
||||||
|
widget.resetBitmaps();
|
||||||
|
}
|
||||||
|
|
||||||
protected void repaintView() {
|
protected void repaintView() {
|
||||||
final ZLAndroidWidget widget =
|
final ZLAndroidWidget widget =
|
||||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
||||||
|
@ -81,13 +88,6 @@ public final class ZLAndroidApplicationWindow extends ZLApplicationWindow {
|
||||||
widget.scrollManually(startX, startY, endX, endY, direction);
|
widget.scrollManually(startX, startY, endX, endY, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void scrollViewToCenter() {
|
|
||||||
final ZLAndroidWidget widget =
|
|
||||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
|
||||||
widget.scrollToCenter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed) {
|
protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed) {
|
||||||
final ZLAndroidWidget widget =
|
final ZLAndroidWidget widget =
|
||||||
|
|
|
@ -41,7 +41,7 @@ abstract class AnimationProvider {
|
||||||
}
|
}
|
||||||
private Mode myMode = Mode.NoScrolling;
|
private Mode myMode = Mode.NoScrolling;
|
||||||
|
|
||||||
protected final Paint myPaint;
|
private final BitmapManager myBitmapManager;
|
||||||
protected int myStartX;
|
protected int myStartX;
|
||||||
protected int myStartY;
|
protected int myStartY;
|
||||||
protected int myEndX;
|
protected int myEndX;
|
||||||
|
@ -52,8 +52,8 @@ abstract class AnimationProvider {
|
||||||
protected int myWidth;
|
protected int myWidth;
|
||||||
protected int myHeight;
|
protected int myHeight;
|
||||||
|
|
||||||
protected AnimationProvider(Paint paint) {
|
protected AnimationProvider(BitmapManager bitmapManager) {
|
||||||
myPaint = paint;
|
myBitmapManager = bitmapManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mode getMode() {
|
Mode getMode() {
|
||||||
|
@ -168,16 +168,24 @@ abstract class AnimationProvider {
|
||||||
}
|
}
|
||||||
final private List<DrawInfo> myDrawInfos = new LinkedList<DrawInfo>();
|
final private List<DrawInfo> myDrawInfos = new LinkedList<DrawInfo>();
|
||||||
|
|
||||||
final void draw(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
final void draw(Canvas canvas) {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
drawInternal(canvas, bgBitmap, fgBitmap);
|
drawInternal(canvas);
|
||||||
myDrawInfos.add(new DrawInfo(myEndX, myEndY, start, System.currentTimeMillis()));
|
myDrawInfos.add(new DrawInfo(myEndX, myEndY, start, System.currentTimeMillis()));
|
||||||
if (myDrawInfos.size() > 3) {
|
if (myDrawInfos.size() > 3) {
|
||||||
myDrawInfos.remove(0);
|
myDrawInfos.remove(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void drawInternal(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap);
|
protected abstract void drawInternal(Canvas canvas);
|
||||||
|
|
||||||
abstract ZLView.PageIndex getPageToScrollTo();
|
abstract ZLView.PageIndex getPageToScrollTo();
|
||||||
|
|
||||||
|
protected Bitmap getBitmapFrom() {
|
||||||
|
return myBitmapManager.getBitmap(ZLView.PageIndex.current);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Bitmap getBitmapTo() {
|
||||||
|
return myBitmapManager.getBitmap(getPageToScrollTo());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007-2011 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.ui.android.view;
|
||||||
|
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
|
||||||
|
import org.geometerplus.zlibrary.core.view.ZLView;
|
||||||
|
|
||||||
|
class BitmapManager {
|
||||||
|
private final int SIZE = 2;
|
||||||
|
private final Bitmap[] myBitmaps = new Bitmap[SIZE];
|
||||||
|
private final ZLView.PageIndex[] myIndexes = new ZLView.PageIndex[SIZE];
|
||||||
|
|
||||||
|
private int myWidth;
|
||||||
|
private int myHeight;
|
||||||
|
|
||||||
|
private final ZLAndroidWidget myWidget;
|
||||||
|
|
||||||
|
BitmapManager(ZLAndroidWidget widget) {
|
||||||
|
myWidget = widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSize(int w, int h) {
|
||||||
|
if (myWidth != w || myHeight != h) {
|
||||||
|
myWidth = w;
|
||||||
|
myHeight = h;
|
||||||
|
for (int i = 0; i < SIZE; ++i) {
|
||||||
|
myBitmaps[i] = null;
|
||||||
|
myIndexes[i] = null;
|
||||||
|
}
|
||||||
|
System.gc();
|
||||||
|
System.gc();
|
||||||
|
System.gc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Bitmap getBitmap(ZLView.PageIndex index) {
|
||||||
|
for (int i = 0; i < SIZE; ++i) {
|
||||||
|
if (index == myIndexes[i]) {
|
||||||
|
return myBitmaps[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final int iIndex = getInternalIndex(index);
|
||||||
|
myIndexes[iIndex] = index;
|
||||||
|
if (myBitmaps[iIndex] == null) {
|
||||||
|
myBitmaps[iIndex] = Bitmap.createBitmap(myWidth, myHeight, Bitmap.Config.RGB_565);
|
||||||
|
}
|
||||||
|
myWidget.drawOnBitmap(myBitmaps[iIndex], index);
|
||||||
|
return myBitmaps[iIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
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] != ZLView.PageIndex.current) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException("That's impossible");
|
||||||
|
}
|
||||||
|
|
||||||
|
void reset() {
|
||||||
|
for (int i = 0; i < SIZE; ++i) {
|
||||||
|
myIndexes[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void shift(boolean forward) {
|
||||||
|
for (int i = 0; i < SIZE; ++i) {
|
||||||
|
if (myIndexes[i] == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
myIndexes[i] = forward ? myIndexes[i].getPrevious() : myIndexes[i].getNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,6 +25,7 @@ import android.util.FloatMath;
|
||||||
import org.geometerplus.zlibrary.core.view.ZLView;
|
import org.geometerplus.zlibrary.core.view.ZLView;
|
||||||
|
|
||||||
class CurlAnimationProvider extends AnimationProvider {
|
class CurlAnimationProvider extends AnimationProvider {
|
||||||
|
private final Paint myPaint = new Paint();
|
||||||
private final Paint myBackPaint = new Paint();
|
private final Paint myBackPaint = new Paint();
|
||||||
private final Paint myEdgePaint = new Paint();
|
private final Paint myEdgePaint = new Paint();
|
||||||
|
|
||||||
|
@ -33,8 +34,8 @@ class CurlAnimationProvider extends AnimationProvider {
|
||||||
|
|
||||||
private float mySpeedFactor;
|
private float mySpeedFactor;
|
||||||
|
|
||||||
CurlAnimationProvider(Paint paint) {
|
CurlAnimationProvider(BitmapManager bitmapManager) {
|
||||||
super(paint);
|
super(bitmapManager);
|
||||||
|
|
||||||
myBackPaint.setAntiAlias(true);
|
myBackPaint.setAntiAlias(true);
|
||||||
myBackPaint.setAlpha(0x40);
|
myBackPaint.setAlpha(0x40);
|
||||||
|
@ -45,8 +46,9 @@ class CurlAnimationProvider extends AnimationProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawInternal(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
protected void drawInternal(Canvas canvas) {
|
||||||
canvas.drawBitmap(bgBitmap, 0, 0, myPaint);
|
canvas.drawBitmap(getBitmapTo(), 0, 0, myPaint);
|
||||||
|
final Bitmap fgBitmap = getBitmapFrom();
|
||||||
|
|
||||||
final int cornerX = myStartX > myWidth / 2 ? myWidth : 0;
|
final int cornerX = myStartX > myWidth / 2 ? myWidth : 0;
|
||||||
final int cornerY = myStartY > myHeight / 2 ? myHeight : 0;
|
final int cornerY = myStartY > myHeight / 2 ? myHeight : 0;
|
||||||
|
|
|
@ -22,12 +22,21 @@ package org.geometerplus.zlibrary.ui.android.view;
|
||||||
import android.graphics.*;
|
import android.graphics.*;
|
||||||
|
|
||||||
class NoneAnimationProvider extends SimpleAnimationProvider {
|
class NoneAnimationProvider extends SimpleAnimationProvider {
|
||||||
NoneAnimationProvider(Paint paint) {
|
private final Paint myPaint = new Paint();
|
||||||
super(paint);
|
|
||||||
|
NoneAnimationProvider(BitmapManager bitmapManager) {
|
||||||
|
super(bitmapManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawInternal(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
protected void drawInternal(Canvas canvas) {
|
||||||
canvas.drawBitmap(fgBitmap, 0, 0, myPaint);
|
canvas.drawBitmap(getBitmapFrom(), 0, 0, myPaint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void doStep() {
|
||||||
|
if (getMode().Auto) {
|
||||||
|
terminate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,17 +22,19 @@ package org.geometerplus.zlibrary.ui.android.view;
|
||||||
import android.graphics.*;
|
import android.graphics.*;
|
||||||
|
|
||||||
class ShiftAnimationProvider extends SimpleAnimationProvider {
|
class ShiftAnimationProvider extends SimpleAnimationProvider {
|
||||||
ShiftAnimationProvider(Paint paint) {
|
private final Paint myPaint = new Paint();
|
||||||
super(paint);
|
|
||||||
|
ShiftAnimationProvider(BitmapManager bitmapManager) {
|
||||||
|
super(bitmapManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawInternal(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
protected void drawInternal(Canvas canvas) {
|
||||||
myPaint.setColor(Color.rgb(127, 127, 127));
|
myPaint.setColor(Color.rgb(127, 127, 127));
|
||||||
if (myDirection.IsHorizontal) {
|
if (myDirection.IsHorizontal) {
|
||||||
final int dX = myEndX - myStartX;
|
final int dX = myEndX - myStartX;
|
||||||
canvas.drawBitmap(bgBitmap, dX > 0 ? dX - myWidth : dX + myWidth, 0, myPaint);
|
canvas.drawBitmap(getBitmapTo(), dX > 0 ? dX - myWidth : dX + myWidth, 0, myPaint);
|
||||||
canvas.drawBitmap(fgBitmap, dX, 0, myPaint);
|
canvas.drawBitmap(getBitmapFrom(), dX, 0, myPaint);
|
||||||
if (dX > 0 && dX < myWidth) {
|
if (dX > 0 && dX < myWidth) {
|
||||||
canvas.drawLine(dX, 0, dX, myHeight + 1, myPaint);
|
canvas.drawLine(dX, 0, dX, myHeight + 1, myPaint);
|
||||||
} else if (dX < 0 && dX > -myWidth) {
|
} else if (dX < 0 && dX > -myWidth) {
|
||||||
|
@ -40,8 +42,8 @@ class ShiftAnimationProvider extends SimpleAnimationProvider {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final int dY = myEndY - myStartY;
|
final int dY = myEndY - myStartY;
|
||||||
canvas.drawBitmap(bgBitmap, 0, dY > 0 ? dY - myHeight : dY + myHeight, myPaint);
|
canvas.drawBitmap(getBitmapTo(), 0, dY > 0 ? dY - myHeight : dY + myHeight, myPaint);
|
||||||
canvas.drawBitmap(fgBitmap, 0, dY, myPaint);
|
canvas.drawBitmap(getBitmapFrom(), 0, dY, myPaint);
|
||||||
if (dY > 0 && dY < myHeight) {
|
if (dY > 0 && dY < myHeight) {
|
||||||
canvas.drawLine(0, dY, myWidth + 1, dY, myPaint);
|
canvas.drawLine(0, dY, myWidth + 1, dY, myPaint);
|
||||||
} else if (dY < 0 && dY > -myHeight) {
|
} else if (dY < 0 && dY > -myHeight) {
|
||||||
|
|
|
@ -19,15 +19,13 @@
|
||||||
|
|
||||||
package org.geometerplus.zlibrary.ui.android.view;
|
package org.geometerplus.zlibrary.ui.android.view;
|
||||||
|
|
||||||
import android.graphics.Paint;
|
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.view.ZLView;
|
import org.geometerplus.zlibrary.core.view.ZLView;
|
||||||
|
|
||||||
abstract class SimpleAnimationProvider extends AnimationProvider {
|
abstract class SimpleAnimationProvider extends AnimationProvider {
|
||||||
private float mySpeedFactor;
|
private float mySpeedFactor;
|
||||||
|
|
||||||
SimpleAnimationProvider(Paint paint) {
|
SimpleAnimationProvider(BitmapManager bitmapManager) {
|
||||||
super(paint);
|
super(bitmapManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,17 +22,19 @@ package org.geometerplus.zlibrary.ui.android.view;
|
||||||
import android.graphics.*;
|
import android.graphics.*;
|
||||||
|
|
||||||
class SlideAnimationProvider extends SimpleAnimationProvider {
|
class SlideAnimationProvider extends SimpleAnimationProvider {
|
||||||
SlideAnimationProvider(Paint paint) {
|
private final Paint myPaint = new Paint();
|
||||||
super(paint);
|
|
||||||
|
SlideAnimationProvider(BitmapManager bitmapManager) {
|
||||||
|
super(bitmapManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawInternal(Canvas canvas, Bitmap bgBitmap, Bitmap fgBitmap) {
|
protected void drawInternal(Canvas canvas) {
|
||||||
canvas.drawBitmap(bgBitmap, 0, 0, myPaint);
|
canvas.drawBitmap(getBitmapTo(), 0, 0, myPaint);
|
||||||
myPaint.setColor(Color.rgb(127, 127, 127));
|
myPaint.setColor(Color.rgb(127, 127, 127));
|
||||||
if (myDirection.IsHorizontal) {
|
if (myDirection.IsHorizontal) {
|
||||||
final int dX = myEndX - myStartX;
|
final int dX = myEndX - myStartX;
|
||||||
canvas.drawBitmap(fgBitmap, dX, 0, myPaint);
|
canvas.drawBitmap(getBitmapFrom(), dX, 0, myPaint);
|
||||||
if (dX > 0 && dX < myWidth) {
|
if (dX > 0 && dX < myWidth) {
|
||||||
canvas.drawLine(dX, 0, dX, myHeight + 1, myPaint);
|
canvas.drawLine(dX, 0, dX, myHeight + 1, myPaint);
|
||||||
} else if (dX < 0 && dX > -myWidth) {
|
} else if (dX < 0 && dX > -myWidth) {
|
||||||
|
@ -40,7 +42,7 @@ class SlideAnimationProvider extends SimpleAnimationProvider {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final int dY = myEndY - myStartY;
|
final int dY = myEndY - myStartY;
|
||||||
canvas.drawBitmap(fgBitmap, 0, dY, myPaint);
|
canvas.drawBitmap(getBitmapFrom(), 0, dY, myPaint);
|
||||||
if (dY > 0 && dY < myHeight) {
|
if (dY > 0 && dY < myHeight) {
|
||||||
canvas.drawLine(0, dY, myWidth + 1, dY, myPaint);
|
canvas.drawLine(0, dY, myWidth + 1, dY, myPaint);
|
||||||
} else if (dY < 0 && dY > -myHeight) {
|
} else if (dY < 0 && dY > -myHeight) {
|
||||||
|
|
|
@ -32,9 +32,7 @@ import org.geometerplus.zlibrary.ui.android.util.ZLAndroidKeyUtil;
|
||||||
|
|
||||||
public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
private final Paint myPaint = new Paint();
|
private final Paint myPaint = new Paint();
|
||||||
private Bitmap myMainBitmap;
|
private final BitmapManager myBitmapManager = new BitmapManager(this);
|
||||||
private Bitmap mySecondaryBitmap;
|
|
||||||
private boolean mySecondaryBitmapIsUpToDate;
|
|
||||||
private Bitmap myFooterBitmap;
|
private Bitmap myFooterBitmap;
|
||||||
|
|
||||||
private ZLView.PageIndex myPageToScrollTo = ZLView.PageIndex.current;
|
private ZLView.PageIndex myPageToScrollTo = ZLView.PageIndex.current;
|
||||||
|
@ -72,6 +70,7 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
view.onScrollingFinished(ZLView.PageIndex.current);
|
view.onScrollingFinished(ZLView.PageIndex.current);
|
||||||
setPageToScrollTo(ZLView.PageIndex.current);
|
setPageToScrollTo(ZLView.PageIndex.current);
|
||||||
}
|
}
|
||||||
|
myBitmapManager.setSize(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,21 +86,6 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
final int w = getWidth();
|
final int w = getWidth();
|
||||||
final int h = getMainAreaHeight();
|
final int h = getMainAreaHeight();
|
||||||
|
|
||||||
if (myMainBitmap != null &&
|
|
||||||
(myMainBitmap.getWidth() != w || myMainBitmap.getHeight() != h)) {
|
|
||||||
myMainBitmap = null;
|
|
||||||
mySecondaryBitmap = null;
|
|
||||||
System.gc();
|
|
||||||
System.gc();
|
|
||||||
System.gc();
|
|
||||||
}
|
|
||||||
if (myMainBitmap == null) {
|
|
||||||
myMainBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);
|
|
||||||
mySecondaryBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565);
|
|
||||||
mySecondaryBitmapIsUpToDate = false;
|
|
||||||
drawOnBitmap(myMainBitmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getAnimationProvider().inProgress()) {
|
if (getAnimationProvider().inProgress()) {
|
||||||
onDrawInScrolling(canvas);
|
onDrawInScrolling(canvas);
|
||||||
} else {
|
} else {
|
||||||
|
@ -118,16 +102,16 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
myAnimationType = type;
|
myAnimationType = type;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case none:
|
case none:
|
||||||
myAnimationProvider = new NoneAnimationProvider(myPaint);
|
myAnimationProvider = new NoneAnimationProvider(myBitmapManager);
|
||||||
break;
|
break;
|
||||||
case curl:
|
case curl:
|
||||||
myAnimationProvider = new CurlAnimationProvider(myPaint);
|
myAnimationProvider = new CurlAnimationProvider(myBitmapManager);
|
||||||
break;
|
break;
|
||||||
case slide:
|
case slide:
|
||||||
myAnimationProvider = new SlideAnimationProvider(myPaint);
|
myAnimationProvider = new SlideAnimationProvider(myBitmapManager);
|
||||||
break;
|
break;
|
||||||
case shift:
|
case shift:
|
||||||
myAnimationProvider = new ShiftAnimationProvider(myPaint);
|
myAnimationProvider = new ShiftAnimationProvider(myBitmapManager);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +128,7 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
final AnimationProvider.Mode oldMode = animator.getMode();
|
final AnimationProvider.Mode oldMode = animator.getMode();
|
||||||
animator.doStep();
|
animator.doStep();
|
||||||
if (animator.inProgress()) {
|
if (animator.inProgress()) {
|
||||||
animator.draw(canvas, mySecondaryBitmap, myMainBitmap);
|
animator.draw(canvas);
|
||||||
if (animator.getMode().Auto) {
|
if (animator.getMode().Auto) {
|
||||||
postInvalidate();
|
postInvalidate();
|
||||||
}
|
}
|
||||||
|
@ -153,9 +137,7 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
switch (oldMode) {
|
switch (oldMode) {
|
||||||
case AutoScrollingForward:
|
case AutoScrollingForward:
|
||||||
{
|
{
|
||||||
final Bitmap swap = myMainBitmap;
|
myBitmapManager.shift(animator.getPageToScrollTo() == ZLView.PageIndex.next);
|
||||||
myMainBitmap = mySecondaryBitmap;
|
|
||||||
mySecondaryBitmap = swap;
|
|
||||||
view.onScrollingFinished(myPageToScrollTo);
|
view.onScrollingFinished(myPageToScrollTo);
|
||||||
ZLApplication.Instance().onRepaintFinished();
|
ZLApplication.Instance().onRepaintFinished();
|
||||||
break;
|
break;
|
||||||
|
@ -170,45 +152,28 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPageToScrollTo(ZLView.PageIndex pageIndex) {
|
private void setPageToScrollTo(ZLView.PageIndex pageIndex) {
|
||||||
if (myPageToScrollTo != pageIndex) {
|
myPageToScrollTo = pageIndex;
|
||||||
myPageToScrollTo = pageIndex;
|
}
|
||||||
mySecondaryBitmapIsUpToDate = false;
|
|
||||||
}
|
public void resetBitmaps() {
|
||||||
|
myBitmapManager.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollManually(int startX, int startY, int endX, int endY, ZLView.Direction direction) {
|
public void scrollManually(int startX, int startY, int endX, int endY, ZLView.Direction direction) {
|
||||||
if (myMainBitmap == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final AnimationProvider animator = getAnimationProvider();
|
final AnimationProvider animator = getAnimationProvider();
|
||||||
if (!animator.inProgress()) {
|
if (!animator.inProgress()) {
|
||||||
getAnimationProvider().startManualScrolling(
|
animator.startManualScrolling(
|
||||||
startX, startY,
|
startX, startY,
|
||||||
direction,
|
direction,
|
||||||
getWidth(), getMainAreaHeight()
|
getWidth(), getMainAreaHeight()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
getAnimationProvider().scrollTo(endX, endY);
|
animator.scrollTo(endX, endY);
|
||||||
setPageToScrollTo(getAnimationProvider().getPageToScrollTo());
|
setPageToScrollTo(animator.getPageToScrollTo());
|
||||||
drawOnBitmap(mySecondaryBitmap);
|
|
||||||
postInvalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void scrollToCenter() {
|
|
||||||
getAnimationProvider().terminate();
|
|
||||||
if (myMainBitmap == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setPageToScrollTo(ZLView.PageIndex.current);
|
|
||||||
drawOnBitmap(mySecondaryBitmap);
|
|
||||||
postInvalidate();
|
postInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
if (myMainBitmap == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final AnimationProvider animator = getAnimationProvider();
|
final AnimationProvider animator = getAnimationProvider();
|
||||||
final int w = getWidth();
|
final int w = getWidth();
|
||||||
final int h = getMainAreaHeight();
|
final int h = getMainAreaHeight();
|
||||||
|
@ -235,34 +200,22 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
setPageToScrollTo(pageIndex);
|
setPageToScrollTo(pageIndex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
drawOnBitmap(mySecondaryBitmap);
|
|
||||||
postInvalidate();
|
postInvalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawOnBitmap(Bitmap bitmap) {
|
void drawOnBitmap(Bitmap bitmap, ZLView.PageIndex index) {
|
||||||
final ZLView view = ZLApplication.Instance().getCurrentView();
|
final ZLView view = ZLApplication.Instance().getCurrentView();
|
||||||
if (view == null) {
|
if (view == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bitmap == myMainBitmap) {
|
|
||||||
mySecondaryBitmapIsUpToDate = false;
|
|
||||||
} else if (mySecondaryBitmapIsUpToDate) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
mySecondaryBitmapIsUpToDate = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ZLAndroidPaintContext context = new ZLAndroidPaintContext(
|
final ZLAndroidPaintContext context = new ZLAndroidPaintContext(
|
||||||
new Canvas(bitmap),
|
new Canvas(bitmap),
|
||||||
getWidth(),
|
getWidth(),
|
||||||
getMainAreaHeight(),
|
getMainAreaHeight(),
|
||||||
view.isScrollbarShown() ? getVerticalScrollbarWidth() : 0
|
view.isScrollbarShown() ? getVerticalScrollbarWidth() : 0
|
||||||
);
|
);
|
||||||
view.paint(
|
view.paint(context, index);
|
||||||
context,
|
|
||||||
bitmap == myMainBitmap ? ZLView.PageIndex.current : myPageToScrollTo
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawFooter(Canvas canvas) {
|
private void drawFooter(Canvas canvas) {
|
||||||
|
@ -293,8 +246,7 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onDrawStatic(Canvas canvas) {
|
private void onDrawStatic(Canvas canvas) {
|
||||||
drawOnBitmap(myMainBitmap);
|
canvas.drawBitmap(myBitmapManager.getBitmap(ZLView.PageIndex.current), 0, 0, myPaint);
|
||||||
canvas.drawBitmap(myMainBitmap, 0, 0, myPaint);
|
|
||||||
drawFooter(canvas);
|
drawFooter(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue