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.zlibrary.ui.android.R;
|
||||||
|
|
||||||
import org.geometerplus.fbreader.book.*;
|
import org.geometerplus.fbreader.book.*;
|
||||||
import org.geometerplus.fbreader.fbreader.FBReaderApp;
|
|
||||||
import org.geometerplus.fbreader.library.Library;
|
import org.geometerplus.fbreader.library.Library;
|
||||||
|
|
||||||
import org.geometerplus.android.util.UIUtil;
|
import org.geometerplus.android.util.UIUtil;
|
||||||
|
@ -228,19 +227,11 @@ public class BookmarksActivity extends TabActivity implements MenuItem.OnMenuIte
|
||||||
|
|
||||||
private void gotoBookmark(Bookmark bookmark) {
|
private void gotoBookmark(Bookmark bookmark) {
|
||||||
bookmark.onOpen();
|
bookmark.onOpen();
|
||||||
final FBReaderApp fbreader = (FBReaderApp)FBReaderApp.Instance();
|
final Book book = Book.getById(bookmark.getBookId());
|
||||||
final long bookId = bookmark.getBookId();
|
if (book != null) {
|
||||||
if ((fbreader.Model == null) || (fbreader.Model.Book.getId() != bookId)) {
|
FBReader.openBookActivity(this, book, bookmark);
|
||||||
final Book book = Book.getById(bookId);
|
|
||||||
if (book != null) {
|
|
||||||
finish();
|
|
||||||
fbreader.openBook(book, bookmark, null);
|
|
||||||
} else {
|
|
||||||
UIUtil.showErrorMessage(this, "cannotOpenBook");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
finish();
|
UIUtil.showErrorMessage(this, "cannotOpenBook");
|
||||||
fbreader.gotoBookmark(bookmark);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
}, postAction);
|
}, postAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadBook() {
|
public void reloadBook() {
|
||||||
if (Model != null && Model.Book != null) {
|
if (Model != null && Model.Book != null) {
|
||||||
Model.Book.reloadInfoFromDatabase();
|
Model.Book.reloadInfoFromDatabase();
|
||||||
|
@ -235,48 +235,49 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!force && Model != null && bookmark == null
|
if (!force && Model != null && book.equals(Model.Book)) {
|
||||||
&& book.File.getPath().equals(Model.Book.File.getPath())) {
|
if (bookmark != null) {
|
||||||
|
gotoBookmark(bookmark);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (book != null) {
|
onViewChanged();
|
||||||
onViewChanged();
|
|
||||||
|
|
||||||
storePosition();
|
storePosition();
|
||||||
BookTextView.setModel(null);
|
BookTextView.setModel(null);
|
||||||
FootnoteView.setModel(null);
|
FootnoteView.setModel(null);
|
||||||
clearTextCaches();
|
clearTextCaches();
|
||||||
|
|
||||||
Model = null;
|
Model = null;
|
||||||
System.gc();
|
System.gc();
|
||||||
System.gc();
|
System.gc();
|
||||||
try {
|
try {
|
||||||
Model = BookModel.createModel(book);
|
Model = BookModel.createModel(book);
|
||||||
ZLTextHyphenator.Instance().load(book.getLanguage());
|
ZLTextHyphenator.Instance().load(book.getLanguage());
|
||||||
BookTextView.setModel(Model.getTextModel());
|
BookTextView.setModel(Model.getTextModel());
|
||||||
BookTextView.gotoPosition(book.getStoredPosition());
|
BookTextView.gotoPosition(book.getStoredPosition());
|
||||||
if (bookmark == null) {
|
if (bookmark == null) {
|
||||||
setView(BookTextView);
|
setView(BookTextView);
|
||||||
} else {
|
} else {
|
||||||
gotoBookmark(bookmark);
|
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);
|
|
||||||
}
|
}
|
||||||
|
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().reset();
|
||||||
getViewWidget().repaint();
|
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;
|
final String modelId = bookmark.ModelId;
|
||||||
if (modelId == null) {
|
if (modelId == null) {
|
||||||
addInvisibleBookmark();
|
addInvisibleBookmark();
|
||||||
|
@ -364,7 +365,7 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
|
|
||||||
private static class BookmarkDescription extends CancelActionDescription {
|
private static class BookmarkDescription extends CancelActionDescription {
|
||||||
final Bookmark Bookmark;
|
final Bookmark Bookmark;
|
||||||
|
|
||||||
BookmarkDescription(Bookmark b) {
|
BookmarkDescription(Bookmark b) {
|
||||||
super(CancelActionType.returnTo, b.getText());
|
super(CancelActionType.returnTo, b.getText());
|
||||||
Bookmark = b;
|
Bookmark = b;
|
||||||
|
@ -492,7 +493,7 @@ public final class FBReaderApp extends ZLApplication {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = cursor.getParagraphIndex();
|
int index = cursor.getParagraphIndex();
|
||||||
if (cursor.isEndOfParagraph()) {
|
if (cursor.isEndOfParagraph()) {
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue