private void addBookmark() { final FBReader fbreader = (FBReader) FBReader.Instance(); final ZLTextView textView = fbreader.getTextView(); final ZLTextWordCursor cursor = textView.getStartCursor(); if (cursor.isNull()) { // TODO: implement return; } // TODO: text edit dialog final Bookmark bookmark = new Bookmark( fbreader.Model.Book, createBookmarkText(cursor), textView.getModel().getId(), cursor); myThisBookBookmarks.add(0, bookmark); AllBooksBookmarks.add(0, bookmark); invalidateAllViews(); }
private void gotoBookmark(Bookmark bookmark) { bookmark.onOpen(); final FBReader fbreader = (FBReader) FBReader.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); } else { Toast.makeText( this, ZLResource.resource("errorMessage").getResource("cannotOpenBook").getValue(), Toast.LENGTH_SHORT) .show(); } } else { finish(); fbreader.gotoBookmark(bookmark); } }
@Override public void onCreate(Bundle bundle) { super.onCreate(bundle); Thread.setDefaultUncaughtExceptionHandler( new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this)); // requestWindowFeature(Window.FEATURE_NO_TITLE); setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); final TabHost host = getTabHost(); LayoutInflater.from(this).inflate(R.layout.bookmarks, host.getTabContentView(), true); AllBooksBookmarks = Bookmark.bookmarks(); Collections.sort(AllBooksBookmarks, new Bookmark.ByTimeComparator()); final FBReader fbreader = (FBReader) FBReader.Instance(); if (fbreader.Model != null) { final long bookId = fbreader.Model.Book.getId(); for (Bookmark bookmark : AllBooksBookmarks) { if (bookmark.getBookId() == bookId) { myThisBookBookmarks.add(bookmark); } } myThisBookView = createTab("thisBook", R.id.this_book); new BookmarksAdapter(myThisBookView, myThisBookBookmarks, true); } else { findViewById(R.id.this_book).setVisibility(View.GONE); } myAllBooksView = createTab("allBooks", R.id.all_books); new BookmarksAdapter(myAllBooksView, AllBooksBookmarks, false); findViewById(R.id.search_results).setVisibility(View.GONE); }
@Override public boolean onSearchRequested() { final FBReader fbreader = (FBReader) FBReader.Instance(); startSearch(fbreader.BookmarkSearchPatternOption.getValue(), true, null, false); return true; }