1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-06 03:50:19 +02:00

FBReader stores position every time after page change

This commit is contained in:
Nikolay Pultsin 2014-04-13 16:14:19 +01:00
parent 7907a9a13b
commit 151355a405
11 changed files with 31 additions and 21 deletions

View file

@ -1,4 +1,5 @@
===== 1.10 (Apr ??, 2014) ===== ===== 1.10 (Apr ??, 2014) =====
* Fixed current position storing
* Experimental video support * Experimental video support
* CSS parsing optimization for ePubs (do not parse css files multiple times) * CSS parsing optimization for ePubs (do not parse css files multiple times)
* CSS support improvement: added support for space-separated classes list * CSS support improvement: added support for space-separated classes list

View file

@ -90,9 +90,14 @@ abstract class PopupPanel extends ZLApplication.PopupPanel {
} }
public final void storePosition() { public final void storePosition() {
if (StartPosition != null && if (StartPosition == null) {
!StartPosition.equals(getReader().getTextView().getStartCursor())) { return;
getReader().addInvisibleBookmark(StartPosition); }
final FBReaderApp reader = getReader();
if (!StartPosition.equals(reader.getTextView().getStartCursor())) {
reader.addInvisibleBookmark(StartPosition);
reader.storePosition();
} }
} }

View file

@ -127,6 +127,7 @@ public class TOCActivity extends ListActivity {
fbreader.addInvisibleBookmark(); fbreader.addInvisibleBookmark();
fbreader.BookTextView.gotoPosition(reference.ParagraphIndex, 0, 0); fbreader.BookTextView.gotoPosition(reference.ParagraphIndex, 0, 0);
fbreader.showBookTextView(); fbreader.showBookTextView();
fbreader.storePosition();
} }
} }

View file

@ -145,7 +145,7 @@ public class LibraryService extends Service {
} }
public void close() { public void close() {
myDatabase.close(); ((SQLiteBooksDatabase)myDatabase).close();
} }
public String status() { public String status() {

View file

@ -1012,7 +1012,7 @@ final class SQLiteBooksDatabase extends BooksDatabase {
myStorePositionStatement.bindLong(2, position.getParagraphIndex()); myStorePositionStatement.bindLong(2, position.getParagraphIndex());
myStorePositionStatement.bindLong(3, position.getElementIndex()); myStorePositionStatement.bindLong(3, position.getElementIndex());
myStorePositionStatement.bindLong(4, position.getCharIndex()); myStorePositionStatement.bindLong(4, position.getCharIndex());
myStorePositionStatement.execute(); myStorePositionStatement.executeInsert();
} }
private SQLiteStatement myDeleteVisitedHyperlinksStatement; private SQLiteStatement myDeleteVisitedHyperlinksStatement;

View file

@ -167,6 +167,7 @@ public final class FBReaderApp extends ZLApplication {
FootnoteView.gotoPosition(label.ParagraphIndex, 0, 0); FootnoteView.gotoPosition(label.ParagraphIndex, 0, 0);
} }
getViewWidget().repaint(); getViewWidget().repaint();
storePosition();
} }
} }
} }
@ -358,6 +359,7 @@ public final class FBReaderApp extends ZLApplication {
setView(FootnoteView); setView(FootnoteView);
} }
getViewWidget().repaint(); getViewWidget().repaint();
storePosition();
} }
public void showBookTextView() { public void showBookTextView() {
@ -493,9 +495,4 @@ public final class FBReaderApp extends ZLApplication {
getViewWidget().repaint(); getViewWidget().repaint();
} }
} }
public void onRepaintFinished() {
super.onRepaintFinished();
storePosition();
}
} }

View file

@ -678,4 +678,10 @@ public final class FBView extends ZLTextView {
return ZLPaintContext.ColorAdjustingMode.NONE; return ZLPaintContext.ColorAdjustingMode.NONE;
} }
} }
@Override
public synchronized void onScrollingFinished(PageIndex pageIndex) {
super.onScrollingFinished(pageIndex);
myReader.storePosition();
}
} }

View file

@ -44,10 +44,10 @@ class MoveCursorAction extends FBAction {
} else { } else {
switch (myDirection) { switch (myDirection) {
case down: case down:
fbView.scrollPage(true, FBView.ScrollingMode.SCROLL_LINES, 1); fbView.turnPage(true, FBView.ScrollingMode.SCROLL_LINES, 1);
break; break;
case up: case up:
fbView.scrollPage(false, FBView.ScrollingMode.SCROLL_LINES, 1); fbView.turnPage(false, FBView.ScrollingMode.SCROLL_LINES, 1);
break; break;
} }
} }

View file

@ -103,7 +103,7 @@ public abstract class ZLApplication {
return myWindow != null ? myWindow.getViewWidget() : null; return myWindow != null ? myWindow.getViewWidget() : null;
} }
public void onRepaintFinished() { public final void onRepaintFinished() {
if (myWindow != null) { if (myWindow != null) {
myWindow.refresh(); myWindow.refresh();
} }

View file

@ -166,13 +166,13 @@ class ZLTextSelection extends ZLTextHighlighting {
if (myCursorInMovement == ZLTextSelectionCursor.Right) { if (myCursorInMovement == ZLTextSelectionCursor.Right) {
if (hasPartAfterPage(page)) { if (hasPartAfterPage(page)) {
myView.scrollPage(true, ZLTextView.ScrollingMode.SCROLL_LINES, 1); myView.turnPage(true, ZLTextView.ScrollingMode.SCROLL_LINES, 1);
myView.Application.getViewWidget().reset(); myView.Application.getViewWidget().reset();
myView.preparePaintInfo(); myView.preparePaintInfo();
} }
} else { } else {
if (hasPartBeforePage(page)) { if (hasPartBeforePage(page)) {
myView.scrollPage(false, ZLTextView.ScrollingMode.SCROLL_LINES, 1); myView.turnPage(false, ZLTextView.ScrollingMode.SCROLL_LINES, 1);
myView.Application.getViewWidget().reset(); myView.Application.getViewWidget().reset();
myView.preparePaintInfo(); myView.preparePaintInfo();
} }
@ -298,7 +298,7 @@ class ZLTextSelection extends ZLTextHighlighting {
} }
public void run() { public void run() {
myView.scrollPage(myScrollForward, ZLTextView.ScrollingMode.SCROLL_LINES, 1); myView.turnPage(myScrollForward, ZLTextView.ScrollingMode.SCROLL_LINES, 1);
myView.preparePaintInfo(); myView.preparePaintInfo();
expandTo(myPage, myX, myY); expandTo(myPage, myX, myY);
myView.Application.getViewWidget().reset(); myView.Application.getViewWidget().reset();

View file

@ -131,7 +131,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
} }
while (mark.compareTo(myCurrentPage.EndCursor.getMark()) > 0) { while (mark.compareTo(myCurrentPage.EndCursor.getMark()) > 0) {
doRepaint = true; doRepaint = true;
scrollPage(true, ScrollingMode.NO_OVERLAPPING, 0); turnPage(true, ScrollingMode.NO_OVERLAPPING, 0);
preparePaintInfo(myCurrentPage); preparePaintInfo(myCurrentPage);
} }
if (doRepaint) { if (doRepaint) {
@ -163,7 +163,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
} }
while (!highlighting.intersects(myCurrentPage)) { while (!highlighting.intersects(myCurrentPage)) {
doRepaint = true; doRepaint = true;
scrollPage(true, ScrollingMode.NO_OVERLAPPING, 0); turnPage(true, ScrollingMode.NO_OVERLAPPING, 0);
preparePaintInfo(myCurrentPage); preparePaintInfo(myCurrentPage);
} }
if (doRepaint) { if (doRepaint) {
@ -1321,7 +1321,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
} }
} }
public synchronized final void scrollPage(boolean forward, int scrollingMode, int value) { public synchronized final void turnPage(boolean forward, int scrollingMode, int value) {
preparePaintInfo(myCurrentPage); preparePaintInfo(myCurrentPage);
myPreviousPage.reset(); myPreviousPage.reset();
myNextPage.reset(); myNextPage.reset();
@ -1346,7 +1346,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
myNextPage.reset(); myNextPage.reset();
preparePaintInfo(myCurrentPage); preparePaintInfo(myCurrentPage);
if (myCurrentPage.isEmptyPage()) { if (myCurrentPage.isEmptyPage()) {
scrollPage(true, ScrollingMode.NO_OVERLAPPING, 0); turnPage(true, ScrollingMode.NO_OVERLAPPING, 0);
} }
} }
} }
@ -1358,7 +1358,7 @@ public abstract class ZLTextView extends ZLTextViewBase {
myNextPage.reset(); myNextPage.reset();
preparePaintInfo(myCurrentPage); preparePaintInfo(myCurrentPage);
if (myCurrentPage.isEmptyPage()) { if (myCurrentPage.isEmptyPage()) {
scrollPage(false, ScrollingMode.NO_OVERLAPPING, 0); turnPage(false, ScrollingMode.NO_OVERLAPPING, 0);
} }
} }
} }