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"); } }
@Override public boolean onContextItemSelected(MenuItem item) { final int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position; final ListView view = (ListView) getTabHost().getCurrentView(); final Bookmark bookmark = ((BookmarksAdapter) view.getAdapter()).getItem(position); switch (item.getItemId()) { case OPEN_ITEM_ID: gotoBookmark(bookmark); return true; case EDIT_ITEM_ID: final Intent intent = new Intent(this, BookmarkEditActivity.class); OrientationUtil.startActivityForResult(this, intent, 1); // TODO: implement return true; case DELETE_ITEM_ID: myCollection.deleteBookmark(bookmark); if (myThisBookAdapter != null) { myThisBookAdapter.remove(bookmark); } if (myAllBooksAdapter != null) { myAllBooksAdapter.remove(bookmark); } if (mySearchResultsAdapter != null) { mySearchResultsAdapter.remove(bookmark); } return true; } return super.onContextItemSelected(item); }
@Override protected void onStart() { super.onStart(); runOnUiThread( new Runnable() { public void run() { setProgressBarIndeterminateVisibility(true); } }); myCollection.bindToService( this, new Runnable() { public void run() { if (myAllBooksAdapter != null) { return; } if (myBook != null) { myThisBookAdapter = new BookmarksAdapter(createTab("thisBook", R.id.this_book), true); } else { findViewById(R.id.this_book).setVisibility(View.GONE); } myAllBooksAdapter = new BookmarksAdapter(createTab("allBooks", R.id.all_books), false); findViewById(R.id.search_results).setVisibility(View.GONE); new Thread(new Initializer()).start(); } }); OrientationUtil.setOrientation(this, getIntent()); }
private void addBookmark() { final Bookmark bookmark = SerializerUtil.deserializeBookmark(getIntent().getStringExtra(FBReader.BOOKMARK_KEY)); if (bookmark != null) { myCollection.saveBookmark(bookmark); myThisBookAdapter.add(bookmark); myAllBooksAdapter.add(bookmark); } }
@Override public void onDestroy() { myCollection.unbind(); System.err.println("SYNCHRONIZER UNBINDED FROM LIBRARY"); super.onDestroy(); }
@Override public IBinder onBind(Intent intent) { myCollection.bindToService(this, this); return null; }
@Override protected void onStop() { myCollection.unbind(); super.onStop(); }