Example #1
0
 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);
   }
 }
Example #2
0
  @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);
  }