示例#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;
  }
示例#2
0
  @Override
  public void onListItemClick(ListView l, View v, int position, long id) {
    switch (mAdapter.getItemViewType(position)) {
      case BookmarkListAdapter.TYPE_SECTION:
        return;
      case BookmarkListAdapter.TYPE_BOOKMARK:
        final Bookmark bookmark = (Bookmark) mAdapter.getItem(position);
        BookmarkManager.INSTANCE.nativeShowBookmarkOnMap(mCategoryIndex, bookmark.getBookmarkId());
        break;
      case BookmarkListAdapter.TYPE_TRACK:
        final Track track = (Track) mAdapter.getItem(position);
        Framework.nativeShowTrackRect(track.getCategoryId(), track.getTrackId());
        break;
    }

    final Intent i = new Intent(getActivity(), MwmActivity.class);
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(i);
  }
示例#3
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;
  }