mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
refactoring: introduced ZLViewWidget class
This commit is contained in:
parent
90f1be2dd8
commit
744934e3b7
17 changed files with 38 additions and 83 deletions
|
@ -239,7 +239,7 @@ public final class FBReader extends ZLAndroidActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fbreader.clearTextCaches();
|
fbreader.clearTextCaches();
|
||||||
fbreader.repaintView();
|
fbreader.getViewWidget().repaint();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case CANCEL_CODE:
|
case CANCEL_CODE:
|
||||||
|
|
|
@ -82,7 +82,7 @@ final class NavigationButtonPanel extends ControlButtonPanel {
|
||||||
view.gotoPage(page);
|
view.gotoPage(page);
|
||||||
}
|
}
|
||||||
Reader.getViewWidget().reset();
|
Reader.getViewWidget().reset();
|
||||||
Reader.repaintView();
|
Reader.getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ class ProcessHyperlinkAction extends FBAction {
|
||||||
final ZLTextElementRegion region = Reader.getTextView().getSelectedRegion();
|
final ZLTextElementRegion region = Reader.getTextView().getSelectedRegion();
|
||||||
if (region instanceof ZLTextHyperlinkRegion) {
|
if (region instanceof ZLTextHyperlinkRegion) {
|
||||||
Reader.getTextView().hideSelectedRegionBorder();
|
Reader.getTextView().hideSelectedRegionBorder();
|
||||||
Reader.repaintView();
|
Reader.getViewWidget().repaint();
|
||||||
final ZLTextHyperlink hyperlink = ((ZLTextHyperlinkRegion)region).Hyperlink;
|
final ZLTextHyperlink hyperlink = ((ZLTextHyperlinkRegion)region).Hyperlink;
|
||||||
switch (hyperlink.Type) {
|
switch (hyperlink.Type) {
|
||||||
case FBHyperlinkType.EXTERNAL:
|
case FBHyperlinkType.EXTERNAL:
|
||||||
|
@ -71,7 +71,7 @@ class ProcessHyperlinkAction extends FBAction {
|
||||||
}
|
}
|
||||||
} else if (region instanceof ZLTextImageRegion) {
|
} else if (region instanceof ZLTextImageRegion) {
|
||||||
Reader.getTextView().hideSelectedRegionBorder();
|
Reader.getTextView().hideSelectedRegionBorder();
|
||||||
Reader.repaintView();
|
Reader.getViewWidget().repaint();
|
||||||
final String uriString = ((ZLTextImageRegion)region).ImageElement.URI;
|
final String uriString = ((ZLTextImageRegion)region).ImageElement.URI;
|
||||||
if (uriString != null) {
|
if (uriString != null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -35,6 +35,6 @@ class ChangeFontSizeAction extends FBAction {
|
||||||
ZLTextStyleCollection.Instance().getBaseStyle().FontSizeOption;
|
ZLTextStyleCollection.Instance().getBaseStyle().FontSizeOption;
|
||||||
option.setValue(option.getValue() + myDelta);
|
option.setValue(option.getValue() + myDelta);
|
||||||
Reader.clearTextCaches();
|
Reader.clearTextCaches();
|
||||||
Reader.repaintView();
|
Reader.getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,7 +203,7 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
setView(FootnoteView);
|
setView(FootnoteView);
|
||||||
FootnoteView.gotoPosition(label.ParagraphIndex, 0, 0);
|
FootnoteView.gotoPosition(label.ParagraphIndex, 0, 0);
|
||||||
}
|
}
|
||||||
repaintView();
|
getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
Library.addBookToRecentList(book);
|
Library.addBookToRecentList(book);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repaintView();
|
getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void gotoBookmark(Bookmark bookmark) {
|
public void gotoBookmark(Bookmark bookmark) {
|
||||||
|
@ -254,7 +254,7 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
FootnoteView.gotoPosition(bookmark);
|
FootnoteView.gotoPosition(bookmark);
|
||||||
setView(FootnoteView);
|
setView(FootnoteView);
|
||||||
}
|
}
|
||||||
repaintView();
|
getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showBookTextView() {
|
public void showBookTextView() {
|
||||||
|
|
|
@ -89,7 +89,7 @@ public final class FBView extends ZLTextView {
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
selectRegion(region);
|
selectRegion(region);
|
||||||
myReader.getViewWidget().reset();
|
myReader.getViewWidget().reset();
|
||||||
myReader.repaintView();
|
myReader.getViewWidget().repaint();
|
||||||
myReader.doAction(ActionCode.PROCESS_HYPERLINK);
|
myReader.doAction(ActionCode.PROCESS_HYPERLINK);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ public final class FBView extends ZLTextView {
|
||||||
if (isFlickScrollingEnabled()) {
|
if (isFlickScrollingEnabled()) {
|
||||||
final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue();
|
final boolean horizontal = ScrollingPreferences.Instance().HorizontalOption.getValue();
|
||||||
final Direction direction = horizontal ? Direction.rightToLeft : Direction.up;
|
final Direction direction = horizontal ? Direction.rightToLeft : Direction.up;
|
||||||
myReader.scrollViewManually(myStartX, myStartY, x, y, direction);
|
myReader.getViewWidget().scrollManually(myStartX, myStartY, x, y, direction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -197,7 +197,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);
|
||||||
myReader.startViewAutoScrolling(pageIndex, direction, x, y, animationSpeed);
|
myReader.getViewWidget().startAutoScrolling(pageIndex, direction, x, y, animationSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onFingerRelease(int x, int y) {
|
public boolean onFingerRelease(int x, int y) {
|
||||||
|
@ -229,7 +229,7 @@ public final class FBView extends ZLTextView {
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
selectRegion(region);
|
selectRegion(region);
|
||||||
myReader.getViewWidget().reset();
|
myReader.getViewWidget().reset();
|
||||||
myReader.repaintView();
|
myReader.getViewWidget().repaint();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ public final class FBView extends ZLTextView {
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
selectRegion(region);
|
selectRegion(region);
|
||||||
myReader.getViewWidget().reset();
|
myReader.getViewWidget().reset();
|
||||||
myReader.repaintView();
|
myReader.getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -293,7 +293,7 @@ public final class FBView extends ZLTextView {
|
||||||
}
|
}
|
||||||
|
|
||||||
myReader.getViewWidget().reset();
|
myReader.getViewWidget().reset();
|
||||||
myReader.repaintView();
|
myReader.getViewWidget().repaint();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,7 @@ public final class FBView extends ZLTextView {
|
||||||
private class Footer implements FooterArea {
|
private class Footer implements FooterArea {
|
||||||
private Runnable UpdateTask = new Runnable() {
|
private Runnable UpdateTask = new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
myReader.repaintView();
|
myReader.getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ public final class FBView extends ZLTextView {
|
||||||
gotoPage(page);
|
gotoPage(page);
|
||||||
}
|
}
|
||||||
myReader.getViewWidget().reset();
|
myReader.getViewWidget().reset();
|
||||||
myReader.repaintView();
|
myReader.getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,6 @@ class SwitchProfileAction extends FBAction {
|
||||||
public void run() {
|
public void run() {
|
||||||
Reader.setColorProfileName(myProfileName);
|
Reader.setColorProfileName(myProfileName);
|
||||||
Reader.getViewWidget().reset();
|
Reader.getViewWidget().reset();
|
||||||
Reader.repaintView();
|
Reader.getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,17 +41,18 @@ class TurnPageAction extends FBAction {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
||||||
Reader.startViewAutoScrolling(
|
Reader.getViewWidget().startAutoScrolling(
|
||||||
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
||||||
preferences.HorizontalOption.getValue()
|
preferences.HorizontalOption.getValue()
|
||||||
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
||||||
|
null, null,
|
||||||
preferences.AnimationSpeedOption.getValue()
|
preferences.AnimationSpeedOption.getValue()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runWithCoordinates(int x, int y) {
|
public void runWithCoordinates(int x, int y) {
|
||||||
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
||||||
Reader.startViewAutoScrolling(
|
Reader.getViewWidget().startAutoScrolling(
|
||||||
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
myForward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
||||||
preferences.HorizontalOption.getValue()
|
preferences.HorizontalOption.getValue()
|
||||||
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
||||||
|
|
|
@ -41,10 +41,11 @@ class VolumeKeyTurnPageAction extends FBAction {
|
||||||
forward = !forward;
|
forward = !forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reader.startViewAutoScrolling(
|
Reader.getViewWidget().startAutoScrolling(
|
||||||
forward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
forward ? FBView.PageIndex.next : FBView.PageIndex.previous,
|
||||||
preferences.HorizontalOption.getValue()
|
preferences.HorizontalOption.getValue()
|
||||||
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
? FBView.Direction.rightToLeft : FBView.Direction.up,
|
||||||
|
null, null,
|
||||||
preferences.AnimationSpeedOption.getValue()
|
preferences.AnimationSpeedOption.getValue()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,8 @@ public abstract class ZLApplication {
|
||||||
final ZLViewWidget widget = getViewWidget();
|
final ZLViewWidget widget = getViewWidget();
|
||||||
if (widget != null) {
|
if (widget != null) {
|
||||||
widget.reset();
|
widget.reset();
|
||||||
|
widget.repaint();
|
||||||
}
|
}
|
||||||
repaintView();
|
|
||||||
onViewChanged();
|
onViewChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,30 +71,6 @@ public abstract class ZLApplication {
|
||||||
return myWindow != null ? myWindow.getViewWidget() : null;
|
return myWindow != null ? myWindow.getViewWidget() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void repaintView() {
|
|
||||||
if (myWindow != null) {
|
|
||||||
myWindow.repaintView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void scrollViewManually(int startX, int startY, int endX, int endY, ZLView.Direction direction) {
|
|
||||||
if (myWindow != null) {
|
|
||||||
myWindow.scrollViewManually(startX, startY, endX, endY, direction);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed) {
|
|
||||||
if (myWindow != null) {
|
|
||||||
myWindow.startViewAutoScrolling(pageIndex, direction, speed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int x, int y, int speed) {
|
|
||||||
if (myWindow != null) {
|
|
||||||
myWindow.startViewAutoScrolling(pageIndex, direction, x, y, speed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void onRepaintFinished() {
|
public final void onRepaintFinished() {
|
||||||
if (myWindow != null) {
|
if (myWindow != null) {
|
||||||
myWindow.refreshMenu();
|
myWindow.refreshMenu();
|
||||||
|
|
|
@ -38,11 +38,6 @@ abstract public class ZLApplicationWindow {
|
||||||
|
|
||||||
abstract protected ZLViewWidget getViewWidget();
|
abstract protected ZLViewWidget getViewWidget();
|
||||||
|
|
||||||
abstract protected void repaintView();
|
|
||||||
abstract protected void scrollViewManually(int startX, int startY, int endX, int endY, ZLView.Direction direction);
|
|
||||||
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 rotate();
|
abstract protected void rotate();
|
||||||
abstract protected boolean canRotate();
|
abstract protected boolean canRotate();
|
||||||
|
|
||||||
|
|
|
@ -21,4 +21,8 @@ package org.geometerplus.zlibrary.core.view;
|
||||||
|
|
||||||
public interface ZLViewWidget {
|
public interface ZLViewWidget {
|
||||||
void reset();
|
void reset();
|
||||||
|
void repaint();
|
||||||
|
|
||||||
|
void scrollManually(int startX, int startY, int endX, int endY, ZLView.Direction direction);
|
||||||
|
void startAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, Integer x, Integer y, int speed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,7 +273,7 @@ final class ZLTextSelectionModel {
|
||||||
public void run() {
|
public void run() {
|
||||||
myView.scrollPage(forward, ZLTextView.ScrollingMode.SCROLL_LINES, 1);
|
myView.scrollPage(forward, ZLTextView.ScrollingMode.SCROLL_LINES, 1);
|
||||||
myDoUpdate = true;
|
myDoUpdate = true;
|
||||||
ZLApplication.Instance().repaintView();
|
ZLApplication.Instance().getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
myTimer.schedule(myScrollingTask, 200, 400);
|
myTimer.schedule(myScrollingTask, 200, 400);
|
||||||
|
|
|
@ -128,7 +128,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
preparePaintInfo(myCurrentPage);
|
preparePaintInfo(myCurrentPage);
|
||||||
}
|
}
|
||||||
Application.getViewWidget().reset();
|
Application.getViewWidget().reset();
|
||||||
Application.repaintView();
|
Application.getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
(backward ? myModel.getPreviousMark(mark) : myModel.getNextMark(mark)));
|
(backward ? myModel.getPreviousMark(mark) : myModel.getNextMark(mark)));
|
||||||
}
|
}
|
||||||
Application.getViewWidget().reset();
|
Application.getViewWidget().reset();
|
||||||
Application.repaintView();
|
Application.getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
myModel.removeAllMarks();
|
myModel.removeAllMarks();
|
||||||
rebuildPaintInfo();
|
rebuildPaintInfo();
|
||||||
Application.getViewWidget().reset();
|
Application.getViewWidget().reset();
|
||||||
Application.repaintView();
|
Application.getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1261,7 +1261,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
public boolean onFingerMove(int x, int y) {
|
public boolean onFingerMove(int x, int y) {
|
||||||
if (mySelectionModel.extendTo(x, y)) {
|
if (mySelectionModel.extendTo(x, y)) {
|
||||||
Application.getViewWidget().reset();
|
Application.getViewWidget().reset();
|
||||||
Application.repaintView();
|
Application.getViewWidget().repaint();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1280,7 +1280,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
|
||||||
if (isSelectionEnabled()) {
|
if (isSelectionEnabled()) {
|
||||||
mySelectionModel.activate(x, y);
|
mySelectionModel.activate(x, y);
|
||||||
Application.getViewWidget().reset();
|
Application.getViewWidget().reset();
|
||||||
Application.repaintView();
|
Application.getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -72,33 +72,7 @@ public final class ZLAndroidApplicationWindow extends ZLApplicationWindow {
|
||||||
return ((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
return ((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void repaintView() {
|
|
||||||
final ZLAndroidWidget widget =
|
|
||||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
|
||||||
widget.postInvalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void scrollViewManually(int startX, int startY, int endX, int endY, ZLView.Direction direction) {
|
|
||||||
final ZLAndroidWidget widget =
|
|
||||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
|
||||||
widget.scrollManually(startX, startY, endX, endY, direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int speed) {
|
|
||||||
final ZLAndroidWidget widget =
|
|
||||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
|
||||||
widget.startAutoScrolling(pageIndex, direction, null, null, speed);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void startViewAutoScrolling(ZLView.PageIndex pageIndex, ZLView.Direction direction, int x, int y, int speed) {
|
|
||||||
final ZLAndroidWidget widget =
|
|
||||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).getWidget();
|
|
||||||
widget.startAutoScrolling(pageIndex, direction, x, y, speed);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void rotate() {
|
public void rotate() {
|
||||||
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).rotateScreen();
|
((ZLAndroidLibrary)ZLAndroidLibrary.Instance()).rotateScreen();
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ public abstract class ZLAndroidActivity extends Activity {
|
||||||
} else {
|
} else {
|
||||||
ZLApplication.Instance().openFile(fileToOpen);
|
ZLApplication.Instance().openFile(fileToOpen);
|
||||||
}
|
}
|
||||||
ZLApplication.Instance().repaintView();
|
ZLApplication.Instance().getViewWidget().repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -153,6 +153,10 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
|
||||||
myBitmapManager.reset();
|
myBitmapManager.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void repaint() {
|
||||||
|
postInvalidate();
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
final ZLView view = ZLApplication.Instance().getCurrentView();
|
final ZLView view = ZLApplication.Instance().getCurrentView();
|
||||||
final int diff = direction.IsHorizontal ? endX - startX : endY - startY;
|
final int diff = direction.IsHorizontal ? endX - startX : endY - startY;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue