Example usage for android.view View getTag

List of usage examples for android.view View getTag

Introduction

In this page you can find the example usage for android.view View getTag.

Prototype

@ViewDebug.ExportedProperty
public Object getTag() 

Source Link

Document

Returns this view's tag.

Usage

From source file:com.mb.kids_mind.Adapter.SimilarListAdapter2.java

@Override
public View getView(final int position, View cView, ViewGroup parent) {
    ViewHolder holder = null;/* w  w  w  . ja  v  a  2 s. c om*/
    final SimilarItem contents = list.get(position);

    final SharedPreferences pref = mContext.getSharedPreferences("pref", mContext.MODE_PRIVATE);
    final SharedPreferences.Editor editor = pref.edit();
    if (cView == null) {
        //cView=View.inflate(mContext, layout,null);
        cView = LayoutInflater.from(mContext).inflate(layout, parent, false);
        holder = new ViewHolder();
        holder.linear = (ImageView) cView.findViewById(R.id.image);
        holder.li = (LinearLayout) cView.findViewById(R.id.LinearLayout1);
        holder.loading = (ImageView) cView.findViewById(R.id.loadingimg);
        holder.loading.setVisibility(View.GONE);
        holder.loading.setBackgroundResource(R.anim.progress);
        holder.loadinglinear = (LinearLayout) cView.findViewById(R.id.loading);
        holder.loadinglinear.setVisibility(View.GONE);
        loadingViewAnim = (AnimationDrawable) holder.loading.getBackground();
        cView.setTag(holder);
        //   Log.v(TAG,"cvew==null");
    } else {

        holder = (ViewHolder) cView.getTag();
        //   Log.v(TAG,"cvew!=null");
    }

    //holder.image.setImageResource(contents.getRes());
    //      String DirPath = Environment.getExternalStorageDirectory()
    //            .getAbsolutePath();
    //      DirPath = DirPath + "/" + "KidsMind2" + "/";
    //
    //      File cameraDir = new File(DirPath);
    //      if (!cameraDir.exists()) {
    //
    //         cameraDir.mkdirs();
    //      }
    //      File f1 = new File(cameraDir, contents.advice_image);
    //      if (f1.exists()) {
    //         BitmapFactory.Options opt=new BitmapFactory.Options();
    //         opt.inSampleSize=2;
    //         Bitmap bm=BitmapFactory.decodeFile(f1.toString(),opt);
    //          //bm=Bitmap.createScaledBitmap(bm,  101,69, true);
    //          BitmapDrawable draw=new BitmapDrawable(bm);
    //          holder.linear.setBackgroundDrawable(draw);
    ////          holder.linear.setImageURI(Uri.fromFile(f1)); 
    //         //mLoader.DisplayImage(f1.getAbsolutePath(), holder.imageView);
    //
    //      } else {
    //         new DownTask().execute(
    //               (Const.IMAGE_LOAD_URL+"/" + contents.advice_image).trim(),f1,holder.linear);
    //
    //         }

    requestMyImage(holder.loading, holder.loadinglinear, holder.linear, contents.advice_image);

    return cView;
}

From source file:com.hybris.mobile.app.commerce.adapter.ProductListAdapterBase.java

@Override
public void bindView(View rowView, final Context context, final Cursor cursor) {

    // When clicking outside a EditText, hide keyboard, remove focus and
    // reset to the default value
    // Clicking on the main view
    rowView.setOnTouchListener(new OnTouchListener() {

        @Override//from  w  w  w. j a v a2 s .  com
        public boolean onTouch(View v, MotionEvent event) {
            UIUtils.hideKeyboard(getContext());
            v.performClick();
            return false;
        }
    });

    final ProductViewHolder productViewHolder = (ProductViewHolder) rowView.getTag();
    final ProductBase product = getData();

    if (mCurrentSelectedPosition == cursor.getPosition()) {
        //TODO when item is in scrapview, index changed and wrong item is opened
        //createExpandedView(mProductViewHolder, cursor.getPosition());
    } else {

        // Populate name and code for a product when row collapsed
        productViewHolder.productName.setText(product.getName());
        productViewHolder.productNo.setText(product.getCode());
        productViewHolder.quantityEditText.setText(getContext().getString(R.string.default_qty));
        String rangeFormattedPrice = product.getPriceRangeFormattedValue();

        if (product.getPriceRange().getMaxPrice() != null) {
            rangeFormattedPrice = StringUtils
                    .isNotBlank(product.getPriceRange().getMaxPrice().getFormattedValue())
                    && StringUtils.isNotBlank(product.getPriceRange().getMinPrice().getFormattedValue())
                            ? product.getPriceRangeFormattedValue()
                            : "";

            if (StringUtils.isBlank(rangeFormattedPrice)) {
                if (product.getPriceRange().getMaxPrice().getValue() != null
                        && product.getPriceRange().getMinPrice().getValue() != null) {

                    rangeFormattedPrice = "$" + product.getPriceRange().getMinPrice().getValue() + ".00 - "
                            + "$" + product.getPriceRange().getMaxPrice().getValue() + ".00";
                }
            }
        }
        productViewHolder.productPrice.setText(rangeFormattedPrice);

        //Rating
        if (product.getAverageRating() != null) {
            productViewHolder.productItemRating.setVisibility(View.VISIBLE);
            productViewHolder.productItemRating.setRating(product.getAverageRating().floatValue());

            productViewHolder.productItemRatingExpanded.setVisibility(View.VISIBLE);
            productViewHolder.productItemRatingExpanded.setRating(product.getAverageRating().floatValue());
        } else {
            productViewHolder.productItemRating.setVisibility(View.GONE);
            productViewHolder.productItemRatingExpanded.setVisibility(View.GONE);
        }

        // Loading the product image
        loadProductImage(product.getImageThumbnailUrl(), productViewHolder.productImage,
                productViewHolder.productImageLoading, product.getCode());
        productViewHolder.collapse();

        if (product.getMultidimensional() != null && product.getMultidimensional()) {
            // Show arrow down with variants
            productViewHolder.productPriceTotal.setVisibility(View.GONE);
            productViewHolder.productImageViewCartIcon.setVisibility(View.GONE);
            productViewHolder.productImageViewExpandIcon.setVisibility(View.VISIBLE);
            productViewHolder.productItemAddQuantityLayout.setVisibility(View.GONE);
            productViewHolder.quantityEditText.setVisibility(View.GONE);
            productViewHolder.productAvailability.setVisibility(View.GONE);
            productViewHolder.productItemInStock.setVisibility(View.GONE);

            productViewHolder.productImageLoadingExpanded.setVisibility(View.VISIBLE);
            productViewHolder.productItemStockLevelLoadingExpanded.setVisibility(View.VISIBLE);
            productViewHolder.productImageExpanded.setVisibility(View.GONE);
            productViewHolder.productAvailabilityExpanded.setVisibility(View.GONE);

            /**
             * Gray out button
             */
            productViewHolder.setAddCartButton(true);
        } else {
            // Show cart icon without variants
            productViewHolder.productItemAddQuantityLayout.setVisibility(View.VISIBLE);
            productViewHolder.productPriceTotal.setVisibility(View.VISIBLE);
            productViewHolder.productPriceTotal.setText(productViewHolder.setTotalPrice(product.getPrice(),
                    productViewHolder.quantityEditText.getText().toString()));
            productViewHolder.productImageViewCartIcon.setVisibility(View.VISIBLE);
            productViewHolder.productImageViewExpandIcon.setVisibility(View.GONE);
            productViewHolder.quantityEditText.setEnabled(true);
            productViewHolder.quantityEditText.setVisibility(View.VISIBLE);
            productViewHolder.productAvailability.setText(product.getStock().getStockLevel() + "");
            productViewHolder.productItemInStock.setVisibility(View.VISIBLE);

            productViewHolder.setAddCartButton(true);

            if (product.isLowStock() || product.isOutOfStock()) {
                productViewHolder.productAvailability
                        .setTextColor(getContext().getResources().getColor(R.color.product_item_low_stock));
                productViewHolder.productItemInStock
                        .setTextColor(getContext().getResources().getColor(R.color.product_item_low_stock));
                productViewHolder.productAvailability
                        .setContentDescription(getContext().getString(R.string.product_item_low_stock));

                if (product.isOutOfStock()) {
                    productViewHolder.quantityEditText.setEnabled(false);
                    productViewHolder.quantityEditText.setText("");

                }

            }

            if (product.isInStock()) {
                productViewHolder.productAvailability.setText("");
                productViewHolder.productItemInStock
                        .setTextColor(getContext().getResources().getColor(R.color.product_item_in_stock));
            }

        }

    }

    /**
     * Product item row is collapsed and user click the arrow down icon to expand
     */
    productViewHolder.productImageViewExpandIcon.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            // Expanded
            getContext().getLoaderManager().restartLoader(0, null, getProductLoaderExpandView(product,
                    getContext(), CommerceApplication.getContentServiceHelper(), new OnRequestListener() {

                        @Override
                        public void beforeRequest() {
                            // Expanded
                            productViewHolder.productImageLoadingExpanded.setVisibility(View.VISIBLE);
                            productViewHolder.productItemStockLevelLoadingExpanded.setVisibility(View.VISIBLE);
                            productViewHolder.productImageExpanded.setVisibility(View.GONE);
                            productViewHolder.productAvailabilityExpanded.setVisibility(View.GONE);
                            UIUtils.showLoadingActionBar(getContext(), true);
                        }

                        @Override
                        public void afterRequestBeforeResponse() {
                            if (mCurrentSelectedViewHolder != null) {
                                mCurrentSelectedViewHolder.collapse();
                            }

                            mCurrentSelectedPosition = cursor.getPosition();
                            mCurrentSelectedViewHolder = productViewHolder;
                        }

                        @Override
                        public void afterRequest(boolean isDataSynced) {
                            productViewHolder.productImageLoadingExpanded.setVisibility(View.GONE);
                            productViewHolder.productItemStockLevelLoadingExpanded.setVisibility(View.GONE);
                            productViewHolder.productImageExpanded.setVisibility(View.VISIBLE);
                            productViewHolder.productAvailabilityExpanded.setVisibility(View.VISIBLE);
                            productViewHolder.productImageLoading.setVisibility(View.GONE);
                            UIUtils.showLoadingActionBar(getContext(), false);

                        }
                    }, new OnProductLoaded() {
                        @Override
                        public void onProductLoaded(ProductBase productBase, String productCodeFirstVariant) {

                            if (productBase != null) {
                                createExpandedView(mCurrentSelectedViewHolder, productBase);

                                if (!mTriggerSpinnerOnChange) {
                                    mNbVariantLevels = populateVariants(mSpinnersVariants, productBase);

                                    if (StringUtils.isNotBlank(productCodeFirstVariant)) {
                                        selectVariant(productCodeFirstVariant);
                                    }
                                }

                            }

                        }
                    }));

        }
    });

    /**
     * Detect when text is changed
     */
    productViewHolder.quantityEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

            try {

                if (cursor.getCount() > cursor.getPosition() && product != null) {
                    if (product.getPrice() != null) {
                        productViewHolder.productPriceTotal.setText(productViewHolder.setTotalPrice(
                                product.getPrice(), productViewHolder.quantityEditText.getText().toString()));
                    }
                }
                productViewHolder.setAddCartButton(true);
            } catch (NumberFormatException e) {
                Log.e(TAG, e.getLocalizedMessage());
            }

        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    /**
     * Detect when text is changed
     */
    productViewHolder.quantityEditTextExpanded.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

            try {
                if (cursor.getCount() > cursor.getPosition() && product.getPrice() != null) {
                    productViewHolder.productPriceTotalExpanded
                            .setText(productViewHolder.setTotalPrice(product.getPrice(),
                                    productViewHolder.quantityEditTextExpanded.getText().toString()));
                }
                productViewHolder.setAddCartButton(true);
            } catch (NumberFormatException e) {
                Log.e(TAG, e.getLocalizedMessage());
            }

        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    /**
     * Add to cart when user click on cartIcon in Product item collapsed row
     */
    productViewHolder.productImageViewCartIcon.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            addToCart(product.getCode(), productViewHolder.quantityEditText.getText().toString(),
                    productViewHolder);
            productViewHolder.quantityEditText.setText(getContext().getString(R.string.default_qty));
        }
    });

    productViewHolder.quantityEditText.setOnEditorActionListener(new SubmitListener() {

        @Override
        public void onSubmitAction() {
            addToCart(product.getCode(), productViewHolder.quantityEditText.getText().toString(),
                    productViewHolder);
            productViewHolder.quantityEditText.setText(getContext().getString(R.string.default_qty));
        }
    });

    /**
     * Product item row is expanded and user click the arrow up icon to collapse
     */
    productViewHolder.productItemButtonCollpaseLayout.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            // collapsed
            productViewHolder.collapse();
            mCurrentSelectedViewHolder.collapse();

        }
    });

    /**
     * Product item row is collapsed and user click on the main part of the row to navigate to the product detail page
     */
    productViewHolder.productItemClickableLayoutCollapsed.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ProductHelper.redirectToProductDetail(getContext(),
                    StringUtils.isNotBlank(getFirstVariantCode(product)) ? getFirstVariantCode(product)
                            : product.getCode());
        }
    });

    /**
     * Product item row is collapsed and user click on the main part of the row to navigate to the product detail page
     */
    productViewHolder.productItemClickableLayoutExpanded.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ProductHelper.redirectToProductDetail(getContext(),
                    StringUtils.isNotBlank(getFirstVariantCode(product)) ? getFirstVariantCode(product)
                            : product.getCode());
        }
    });

}

From source file:com.nttec.everychan.ui.gallery.GalleryActivity.java

private void updateItem() {
    AttachmentModel attachment = attachments.get(currentPosition).getLeft();
    if (settings.scrollThreadFromGallery() && !firstScroll)
        remote.tryScrollParent(attachments.get(currentPosition).getRight());
    firstScroll = false;//  ww  w.j  a  v  a 2 s.c  o m
    String navText = attachment.size == -1 ? (currentPosition + 1) + "/" + attachments.size()
            : (currentPosition + 1) + "/" + attachments.size() + " ("
                    + Attachments.getAttachmentSizeString(attachment, getResources()) + ")";
    navigationInfo.setText(navText);
    setTitle(Attachments.getAttachmentDisplayName(attachment));

    if (previousPosition != -1) {
        View previous = instantiatedViews.get(previousPosition);
        if (previous != null) {
            GalleryItemViewTag tag = (GalleryItemViewTag) previous.getTag();
            tag.thumbnailView.setVisibility(View.VISIBLE);
            tag.layout.setVisibility(View.GONE);
            tag.errorView.setVisibility(View.GONE);
            tag.loadingView.setVisibility(View.GONE);
            recycleTag(tag, true);
        }
    }
    previousPosition = currentPosition;

    GalleryItemViewTag tag = getCurrentTag();
    if (tag == null)
        return;
    currentLoaded = false;
    updateMenu();
    tag.downloadingTask = new AttachmentGetter(tag);
    tag.loadingView.setVisibility(View.VISIBLE);
    hideProgress();
    Async.runAsync((Runnable) tag.downloadingTask);
}

From source file:com.android.launcher3.Folder.java

private View getViewForInfo(ShortcutInfo item) {
    for (int j = 0; j < mContent.getCountY(); j++) {
        for (int i = 0; i < mContent.getCountX(); i++) {
            View v = mContent.getChildAt(i, j);
            //SPRD: bug382214 2014-12-19 Bugfix:View may be empty
            if (v != null && v.getTag() == item) {
                return v;
            }//  w  w w. j  av a2 s.  c  om
        }
    }
    return null;
}

From source file:com.inmobi.ultrapush.AnalyzeActivity.java

private void exec(View v, Visit cmd, String select) {
    if (select == null || select.equals(v.getTag())) {
        cmd.exec(v);
    }
}

From source file:com.aviary.android.feather.sdk.widget.AviaryWorkspace.java

public View getViewForTag(Object tag) {
    int screenCount = mItemCount;
    for (int screen = 0; screen < screenCount; screen++) {
        CellLayout currentScreen = ((CellLayout) getChildAt(screen));
        int count = currentScreen.getChildCount();
        for (int i = 0; i < count; i++) {
            View child = currentScreen.getChildAt(i);
            if (child.getTag() == tag) {
                return child;
            }//from   ww w .j  a  v a2s. com
        }
    }
    return null;
}

From source file:com.andreadec.musicplayer.adapters.BrowserArrayAdapter.java

@Override
public View getView(int position, View view, ViewGroup parent) {
    int type = getItemViewType(position);
    Object value = values.get(position);
    ViewHolder viewHolder;//from   www .  ja v  a  2 s .  c  om
    if (view == null) {
        viewHolder = new ViewHolder();
        if (type == TYPE_ACTION) {
            view = inflater.inflate(R.layout.action_item, parent, false);
            viewHolder.title = (TextView) view.findViewById(R.id.textView);
            viewHolder.title.setTextColor(view.getResources().getColor(R.color.orange1));
            viewHolder.image = (ImageView) view.findViewById(R.id.imageView);
            viewHolder.image.setImageResource(R.drawable.back);
        } else if (type == TYPE_DIRECTORY) {
            view = inflater.inflate(R.layout.folder_item, parent, false);
            viewHolder.title = (TextView) view.findViewById(R.id.textViewFolderItemFolder);
        } else if (type == TYPE_SONG) {
            view = inflater.inflate(R.layout.song_item, parent, false);
            viewHolder.title = (TextView) view.findViewById(R.id.textViewSongItemTitle);
            viewHolder.artist = (TextView) view.findViewById(R.id.textViewSongItemArtist);
            viewHolder.image = (ImageView) view.findViewById(R.id.imageViewItemImage);
            viewHolder.card = view.findViewById(R.id.card);
        }
    } else {
        viewHolder = (ViewHolder) view.getTag();
    }
    if (type == TYPE_ACTION) {
        Action action = (Action) value;
        viewHolder.title.setText(action.msg);
    } else if (type == TYPE_DIRECTORY) {
        File file = (File) value;
        viewHolder.title.setText(file.getName());
    } else if (type == TYPE_SONG) {
        BrowserSong song = (BrowserSong) value;
        String trackNumber = "";
        if (song.getTrackNumber() != null)
            trackNumber = song.getTrackNumber() + ". ";
        viewHolder.title.setText(trackNumber + song.getTitle());
        viewHolder.artist.setText(song.getArtist());
        if (song.equals(playingSong)) {
            viewHolder.card.setBackgroundResource(R.drawable.card_playing);
            viewHolder.image.setImageResource(R.drawable.play_orange);
        } else {
            viewHolder.card.setBackgroundResource(R.drawable.card);
            if (showSongImage) {
                viewHolder.image.setImageDrawable(songImage);
                if (song.hasImage()) {
                    Bitmap image;
                    synchronized (imagesCache) {
                        image = imagesCache.get(song.getUri());
                    }
                    if (image != null) {
                        viewHolder.image.setImageBitmap(image);
                    } else
                        new ImageLoaderTask(song, viewHolder.image, imagesCache, listImageSize).execute();
                }
            }
        }
    }
    view.setTag(viewHolder);
    return view;
}

From source file:com.android.launcher3.Folder.java

public boolean onLongClick(View v) {
    // Return if global dragging is not enabled
    if (!mLauncher.isDraggingEnabled())
        return true;

    Object tag = v.getTag();
    if (tag instanceof ShortcutInfo) {
        ShortcutInfo item = (ShortcutInfo) tag;
        if (!v.isInTouchMode()) {
            return false;
        }/*from ww w.  j  a  va2 s. co m*/

        mLauncher.getWorkspace().beginDragShared(v, this);

        mCurrentDragInfo = item;
        mEmptyCell[0] = item.cellX;
        mEmptyCell[1] = item.cellY;
        mCurrentDragView = v;

        mContent.removeView(mCurrentDragView);
        mInfo.remove(mCurrentDragInfo);
        mDragInProgress = true;
        mItemAddedBackToSelfViaIcon = false;
    }
    return true;
}

From source file:com.digipom.manteresting.android.adapter.NailCursorAdapter.java

/**
 * BindView will also be called after newView. See {@link CursorAdapter}
 *///  w w w  .j a  v  a 2  s  .co m
@Override
public void bindView(View view, Context context, Cursor cursor) {
    try {
        // 84, or 0.825, comes from the margins/paddings around the
        // image. This will need to be changed if the margins/paddings are
        // changed or multi-column mode is used.
        final int approxImageWidthInPixels = (int) (context.getResources().getDisplayMetrics().widthPixels
                * 0.825f);

        // Request a load of the bitmaps on either side, to avoid
        // problems when scrolling up and down.
        final int cursorPosition = cursor.getPosition();

        if (cursorPosition > 0) {
            cursor.moveToPrevious();
            if (cursor.getString(nailObjectColumnIndex) != null) {
                cacheDataAndGet(context, cursor, approxImageWidthInPixels);
            }
            cursor.moveToNext();
        }

        if (cursorPosition < cursor.getCount() - 1) {
            cursor.moveToNext();
            if (cursor.getString(nailObjectColumnIndex) != null) {
                cacheDataAndGet(context, cursor, approxImageWidthInPixels);
            }
            cursor.moveToPrevious();
        }

        final ViewHolder viewHolder = (ViewHolder) view.getTag();

        final CachedData cachedDataForThisNailItem = cacheDataAndGet(context, cursor, approxImageWidthInPixels);

        viewHolder.nailDescription.setText(cachedDataForThisNailItem.nailDescription);
        viewHolder.nailUserAndCategory.setText(cachedDataForThisNailItem.styledUserAndCategory);

        if (failedDownloads.contains(cachedDataForThisNailItem.originalImageUriString)) {
            // This image has failed. The user will have to select to
            // retry this image. INVISIBLE and not GONE so that the view
            // doesn't jump in sizes for couldNotLoadImageIndicator.
            viewHolder.imageLoadingIndicator.setVisibility(View.INVISIBLE);
            viewHolder.couldNotLoadImageIndicator.setVisibility(View.VISIBLE);
            viewHolder.loadedImage.setVisibility(View.GONE);
        } else {
            // Should default to WRAP_CONTENT
            viewHolder.loadedImage.getLayoutParams().height = LayoutParams.WRAP_CONTENT;

            Bitmap bitmap = null;

            if (serviceConnector.getService() != null) {
                bitmap = serviceConnector.getService().getOrLoadLifoAsync(
                        cachedDataForThisNailItem.originalImageUriString, approxImageWidthInPixels,
                        bitmapCompleteReceiver);
            }

            if (bitmap == null) {
                viewHolder.imageLoadingIndicator.setVisibility(View.VISIBLE);
                viewHolder.couldNotLoadImageIndicator.setVisibility(View.INVISIBLE);
                viewHolder.loadedImage.setVisibility(View.GONE);
            } else {
                viewHolder.imageLoadingIndicator.setVisibility(View.GONE);
                viewHolder.couldNotLoadImageIndicator.setVisibility(View.GONE);
                viewHolder.loadedImage.setVisibility(View.VISIBLE);

                viewHolder.loadedImage.setImageBitmap(bitmap);
            }
        }
    } catch (JSONException e) {
        if (LoggerConfig.canLog(Log.ERROR)) {
            Log.e(TAG, "Could not load JSON object from database.", e);
        }
    } catch (Exception e) {
        if (LoggerConfig.canLog(Log.ERROR)) {
            Log.e(TAG, "Error binding view.", e);
        }
    }
}

From source file:com.nttec.everychan.ui.gallery.GalleryActivity.java

private void updateMenu() {
    if (this.menu == null)
        return;//from www .  ja v a  2 s.  c  om
    View current = instantiatedViews.get(currentPosition);
    if (current == null) {
        Logger.e(TAG, "VIEW == NULL");
        return;
    }
    GalleryItemViewTag tag = (GalleryItemViewTag) current.getTag();
    boolean externalVideo = tag.attachmentModel.type == AttachmentModel.TYPE_VIDEO
            && settings.doNotDownloadVideos();
    menu.findItem(R.id.menu_update).setVisible(!currentLoaded);
    menu.findItem(R.id.menu_save_attachment).setVisible(
            externalVideo || (currentLoaded && tag.attachmentModel.type != AttachmentModel.TYPE_OTHER_NOTFILE));
    menu.findItem(R.id.menu_open_external)
            .setVisible(currentLoaded && (tag.attachmentModel.type == AttachmentModel.TYPE_OTHER_FILE
                    || tag.attachmentModel.type == AttachmentModel.TYPE_AUDIO
                    || tag.attachmentModel.type == AttachmentModel.TYPE_VIDEO));
    menu.findItem(R.id.menu_open_external)
            .setTitle(tag.attachmentModel.type != AttachmentModel.TYPE_OTHER_FILE ? R.string.menu_open_player
                    : R.string.menu_open);
    menu.findItem(R.id.menu_share)
            .setVisible(currentLoaded && tag.attachmentModel.type != AttachmentModel.TYPE_OTHER_NOTFILE);
    menu.findItem(R.id.menu_reverse_search)
            .setVisible(tag.attachmentModel.type == AttachmentModel.TYPE_IMAGE_STATIC
                    || tag.attachmentModel.type == AttachmentModel.TYPE_IMAGE_GIF);
}