예제 #1
0
 private void gotoBookmark(Bookmark bookmark) {
   bookmark.markAsAccessed();
   myCollection.saveBookmark(bookmark);
   final Book book = myCollection.getBookById(bookmark.getBookId());
   if (book != null) {
     FBReader.openBookActivity(this, book, bookmark);
   } else {
     UIUtil.showErrorMessage(this, "cannotOpenBook");
   }
 }
예제 #2
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);
   }
 }
  @Override
  protected long saveBookmark(Bookmark bookmark) {
    SQLiteStatement statement;
    if (bookmark.getId() == -1) {
      if (myInsertBookmarkStatement == null) {
        myInsertBookmarkStatement =
            myDatabase.compileStatement(
                "INSERT OR IGNORE INTO Bookmarks (book_id,bookmark_text,creation_time,modification_time,access_time,access_counter,model_id,paragraph,word,char,visible) VALUES (?,?,?,?,?,?,?,?,?,?,?)");
      }
      statement = myInsertBookmarkStatement;
    } else {
      if (myUpdateBookmarkStatement == null) {
        myUpdateBookmarkStatement =
            myDatabase.compileStatement(
                "UPDATE Bookmarks SET book_id = ?, bookmark_text = ?, creation_time =?, modification_time = ?,access_time = ?, access_counter = ?, model_id = ?, paragraph = ?, word = ?, char = ?, visible = ? WHERE bookmark_id = ?");
      }
      statement = myUpdateBookmarkStatement;
    }

    statement.bindLong(1, bookmark.getBookId());
    statement.bindString(2, bookmark.getText());
    SQLiteUtil.bindDate(statement, 3, bookmark.getTime(Bookmark.CREATION));
    SQLiteUtil.bindDate(statement, 4, bookmark.getTime(Bookmark.MODIFICATION));
    SQLiteUtil.bindDate(statement, 5, bookmark.getTime(Bookmark.ACCESS));
    statement.bindLong(6, bookmark.getAccessCount());
    SQLiteUtil.bindString(statement, 7, bookmark.ModelId);
    statement.bindLong(8, bookmark.ParagraphIndex);
    statement.bindLong(9, bookmark.ElementIndex);
    statement.bindLong(10, bookmark.CharIndex);
    statement.bindLong(11, bookmark.IsVisible ? 1 : 0);

    if (statement == myInsertBookmarkStatement) {
      return statement.executeInsert();
    } else {
      final long id = bookmark.getId();
      statement.bindLong(12, id);
      statement.execute();
      return id;
    }
  }
예제 #4
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);
  }