Exemple #1
0
 @Override
 public void onCreateContextMenu(ContextMenu menu, View v, int position, View targetView) {
   PageHolder pageHolder = getPageHolder();
   String boardName = getAdapter().getItem(position).boardName;
   if (boardName != null) {
     menu.add(0, CONTEXT_MENU_COPY_LINK, 0, R.string.action_copy_link);
     if (!FavoritesStorage.getInstance().hasFavorite(pageHolder.chanName, boardName, null)) {
       menu.add(0, CONTEXT_MENU_ADD_FAVORITES, 0, R.string.action_add_to_favorites);
     }
   }
 }
Exemple #2
0
 @Override
 public boolean onContextItemSelected(MenuItem item, int position, View targetView) {
   String boardName = getAdapter().getItem(position).boardName;
   if (boardName != null) {
     switch (item.getItemId()) {
       case CONTEXT_MENU_COPY_LINK:
         {
           Uri uri = getChanLocator().safe(true).createBoardUri(boardName, 0);
           if (uri != null) {
             StringUtils.copyToClipboard(getActivity(), uri.toString());
           }
           return true;
         }
       case CONTEXT_MENU_ADD_FAVORITES:
         {
           FavoritesStorage.getInstance().add(getPageHolder().chanName, boardName);
           return true;
         }
     }
   }
   return false;
 }