Ejemplo n.º 1
0
  @Override
  public boolean onMenuItemClick(MenuItem menuItem) {
    Bookmark item = (Bookmark) mAdapter.getItem(mSelectedPosition);

    switch (menuItem.getItemId()) {
      case R.id.share_message:
        ShareOption.SMS.shareMapObject(getActivity(), item);
        break;

      case R.id.share_email:
        ShareOption.EMAIL.shareMapObject(getActivity(), item);
        break;

      case R.id.share:
        ShareOption.ANY.shareMapObject(getActivity(), item);
        break;

      case R.id.edit:
        editBookmark(mCategory.getId(), item.getBookmarkId());
        break;

      case R.id.delete:
        BookmarkManager.INSTANCE.deleteBookmark(item);
        mAdapter.notifyDataSetChanged();
        break;
    }
    return false;
  }
Ejemplo n.º 2
0
  @Override
  public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    mSelectedPosition = position;
    final Object item = mAdapter.getItem(mSelectedPosition);
    int type = mAdapter.getItemViewType(mSelectedPosition);

    switch (type) {
      case BookmarkListAdapter.TYPE_SECTION:
        // Do nothing here?
        break;

      case BookmarkListAdapter.TYPE_BOOKMARK:
        BottomSheetHelper.Builder bs =
            BottomSheetHelper.create(getActivity(), ((Bookmark) item).getTitle())
                .sheet(R.menu.menu_bookmarks)
                .listener(this);
        if (!ShareOption.SMS.isSupported(getActivity()))
          bs.getMenu().removeItem(R.id.share_message);

        if (!ShareOption.EMAIL.isSupported(getActivity()))
          bs.getMenu().removeItem(R.id.share_email);

        bs.tint().show();
        break;

      case BookmarkListAdapter.TYPE_TRACK:
        BottomSheetHelper.create(getActivity(), ((Track) item).getName())
            .sheet(Menu.NONE, R.drawable.ic_delete, R.string.delete)
            .listener(
                new MenuItem.OnMenuItemClickListener() {
                  @Override
                  public boolean onMenuItemClick(MenuItem menuItem) {
                    BookmarkManager.INSTANCE.deleteTrack((Track) item);
                    mAdapter.notifyDataSetChanged();
                    return false;
                  }
                })
            .tint()
            .show();
        break;
    }

    return true;
  }