コード例 #1
0
 private void createBookContextMenu(ContextMenu menu, Book book) {
   final ZLResource resource = Library.resource();
   menu.setHeaderTitle(book.getTitle());
   menu.add(0, OPEN_BOOK_ITEM_ID, 0, resource.getResource("openBook").getValue());
   menu.add(0, SHOW_BOOK_INFO_ITEM_ID, 0, resource.getResource("showBookInfo").getValue());
   if (myLibrary.isBookInFavorites(book)) {
     menu.add(
         0,
         REMOVE_FROM_FAVORITES_ITEM_ID,
         0,
         resource.getResource("removeFromFavorites").getValue());
   } else {
     menu.add(0, ADD_TO_FAVORITES_ITEM_ID, 0, resource.getResource("addToFavorites").getValue());
   }
   if ((myLibrary.getRemoveBookMode(book) & Library.REMOVE_FROM_DISK) != 0) {
     menu.add(0, DELETE_BOOK_ITEM_ID, 0, resource.getResource("deleteBook").getValue());
   }
 }
コード例 #2
0
  @Override
  protected void onListItemClick(ListView listView, View view, int position, long rowId) {
    final LibraryTree tree = (LibraryTree) getListAdapter().getItem(position);
    final Book book = tree.getBook();
    mySelectedBook = book;
    if (book != null) {
      if (!accessibilityManager.isEnabled()) {
        showBookInfo(book);
      } else {

        ArrayList<Object> listItems = new ArrayList<Object>();
        listItems.add(resource.getResource("openBook").getValue());
        if (myLibrary.isBookInFavorites(book)) {
          listItems.add(resource.getResource("removeFromFavorites").getValue());
        } else {
          listItems.add(resource.getResource("addToFavorites").getValue());
        }
        if ((myLibrary.getRemoveBookMode(book) & Library.REMOVE_FROM_DISK) != 0) {
          listItems.add(resource.getResource("deleteBook").getValue());
        }

        LabelsListAdapter adapter = new LabelsListAdapter(listItems, this);
        list.setAdapter(adapter);
        list.setOnItemClickListener(new MenuClickListener(book));

        dialog.show();
      }
    } else {
      String id = tree.getUniqueKey().Id;
      if (id.equals(Library.ROOT_SEARCH)) {
        onSearchRequested();
      } else {
        openTree(tree);
      }
    }
  }