mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 10:49:24 +02:00
open book from bookmarks view
This commit is contained in:
parent
f17d1f127f
commit
a9d948322c
2 changed files with 44 additions and 52 deletions
|
@ -34,7 +34,6 @@ import org.geometerplus.zlibrary.core.options.ZLStringOption;
|
|||
import org.geometerplus.zlibrary.ui.android.R;
|
||||
|
||||
import org.geometerplus.fbreader.book.*;
|
||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
||||
import org.geometerplus.fbreader.library.Library;
|
||||
|
||||
import org.geometerplus.android.util.UIUtil;
|
||||
|
@ -228,19 +227,11 @@ public class BookmarksActivity extends TabActivity implements MenuItem.OnMenuIte
|
|||
|
||||
private void gotoBookmark(Bookmark bookmark) {
|
||||
bookmark.onOpen();
|
||||
final FBReaderApp fbreader = (FBReaderApp)FBReaderApp.Instance();
|
||||
final long bookId = bookmark.getBookId();
|
||||
if ((fbreader.Model == null) || (fbreader.Model.Book.getId() != bookId)) {
|
||||
final Book book = Book.getById(bookId);
|
||||
if (book != null) {
|
||||
finish();
|
||||
fbreader.openBook(book, bookmark, null);
|
||||
} else {
|
||||
UIUtil.showErrorMessage(this, "cannotOpenBook");
|
||||
}
|
||||
final Book book = Book.getById(bookmark.getBookId());
|
||||
if (book != null) {
|
||||
FBReader.openBookActivity(this, book, bookmark);
|
||||
} else {
|
||||
finish();
|
||||
fbreader.gotoBookmark(bookmark);
|
||||
UIUtil.showErrorMessage(this, "cannotOpenBook");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ public final class FBReaderApp extends ZLApplication {
|
|||
}, postAction);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void reloadBook() {
|
||||
if (Model != null && Model.Book != null) {
|
||||
Model.Book.reloadInfoFromDatabase();
|
||||
|
@ -235,48 +235,49 @@ public final class FBReaderApp extends ZLApplication {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (!force && Model != null && bookmark == null
|
||||
&& book.File.getPath().equals(Model.Book.File.getPath())) {
|
||||
if (!force && Model != null && book.equals(Model.Book)) {
|
||||
if (bookmark != null) {
|
||||
gotoBookmark(bookmark);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (book != null) {
|
||||
onViewChanged();
|
||||
onViewChanged();
|
||||
|
||||
storePosition();
|
||||
BookTextView.setModel(null);
|
||||
FootnoteView.setModel(null);
|
||||
clearTextCaches();
|
||||
storePosition();
|
||||
BookTextView.setModel(null);
|
||||
FootnoteView.setModel(null);
|
||||
clearTextCaches();
|
||||
|
||||
Model = null;
|
||||
System.gc();
|
||||
System.gc();
|
||||
try {
|
||||
Model = BookModel.createModel(book);
|
||||
ZLTextHyphenator.Instance().load(book.getLanguage());
|
||||
BookTextView.setModel(Model.getTextModel());
|
||||
BookTextView.gotoPosition(book.getStoredPosition());
|
||||
if (bookmark == null) {
|
||||
setView(BookTextView);
|
||||
} else {
|
||||
gotoBookmark(bookmark);
|
||||
}
|
||||
Library.Instance().addBookToRecentList(book);
|
||||
final StringBuilder title = new StringBuilder(book.getTitle());
|
||||
if (!book.authors().isEmpty()) {
|
||||
boolean first = true;
|
||||
for (Author a : book.authors()) {
|
||||
title.append(first ? " (" : ", ");
|
||||
title.append(a.DisplayName);
|
||||
first = false;
|
||||
}
|
||||
title.append(")");
|
||||
}
|
||||
setTitle(title.toString());
|
||||
} catch (BookReadingException e) {
|
||||
processException(e);
|
||||
Model = null;
|
||||
System.gc();
|
||||
System.gc();
|
||||
try {
|
||||
Model = BookModel.createModel(book);
|
||||
ZLTextHyphenator.Instance().load(book.getLanguage());
|
||||
BookTextView.setModel(Model.getTextModel());
|
||||
BookTextView.gotoPosition(book.getStoredPosition());
|
||||
if (bookmark == null) {
|
||||
setView(BookTextView);
|
||||
} else {
|
||||
gotoBookmark(bookmark);
|
||||
}
|
||||
Library.Instance().addBookToRecentList(book);
|
||||
final StringBuilder title = new StringBuilder(book.getTitle());
|
||||
if (!book.authors().isEmpty()) {
|
||||
boolean first = true;
|
||||
for (Author a : book.authors()) {
|
||||
title.append(first ? " (" : ", ");
|
||||
title.append(a.DisplayName);
|
||||
first = false;
|
||||
}
|
||||
title.append(")");
|
||||
}
|
||||
setTitle(title.toString());
|
||||
} catch (BookReadingException e) {
|
||||
processException(e);
|
||||
}
|
||||
|
||||
getViewWidget().reset();
|
||||
getViewWidget().repaint();
|
||||
}
|
||||
|
@ -313,7 +314,7 @@ public final class FBReaderApp extends ZLApplication {
|
|||
}
|
||||
}
|
||||
|
||||
public void gotoBookmark(Bookmark bookmark) {
|
||||
private void gotoBookmark(Bookmark bookmark) {
|
||||
final String modelId = bookmark.ModelId;
|
||||
if (modelId == null) {
|
||||
addInvisibleBookmark();
|
||||
|
@ -364,7 +365,7 @@ public final class FBReaderApp extends ZLApplication {
|
|||
|
||||
private static class BookmarkDescription extends CancelActionDescription {
|
||||
final Bookmark Bookmark;
|
||||
|
||||
|
||||
BookmarkDescription(Bookmark b) {
|
||||
super(CancelActionType.returnTo, b.getText());
|
||||
Bookmark = b;
|
||||
|
@ -492,7 +493,7 @@ public final class FBReaderApp extends ZLApplication {
|
|||
return null;
|
||||
}
|
||||
|
||||
int index = cursor.getParagraphIndex();
|
||||
int index = cursor.getParagraphIndex();
|
||||
if (cursor.isEndOfParagraph()) {
|
||||
++index;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue