@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); }
@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; }
void setDistance(Track trk) { distance.setText(mActivity.getString(R.string.length) + " " + trk.getLengthString()); }
void setIcon(Track trk) { final Drawable circle = Graphics.drawCircle(trk.getColor(), R.dimen.track_circle_size, mActivity.getResources()); icon.setImageDrawable(circle); }
void setName(Track trk) { name.setText(trk.getName()); }