示例#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
 @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);
 }
示例#3
0
  @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());
  }
示例#4
0
 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);
   }
 }
示例#5
0
 @Override
 public void onDestroy() {
   myCollection.unbind();
   System.err.println("SYNCHRONIZER UNBINDED FROM LIBRARY");
   super.onDestroy();
 }
示例#6
0
 @Override
 public IBinder onBind(Intent intent) {
   myCollection.bindToService(this, this);
   return null;
 }
示例#7
0
 @Override
 protected void onStop() {
   myCollection.unbind();
   super.onStop();
 }