Example usage for android.view MenuItem getIcon

List of usage examples for android.view MenuItem getIcon

Introduction

In this page you can find the example usage for android.view MenuItem getIcon.

Prototype

public Drawable getIcon();

Source Link

Document

Returns the icon for this item as a Drawable (getting it from resources if it hasn't been loaded before).

Usage

From source file:com.xandy.calendar.AllInOneActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    mOptionsMenu = menu;/*from  www  .  j a  v a  2 s  .co m*/
    getMenuInflater().inflate(R.menu.all_in_one_title_bar, menu);

    // Add additional options (if any).
    Integer extensionMenuRes = mExtensions.getExtensionMenuResource(menu);
    if (extensionMenuRes != null) {
        getMenuInflater().inflate(extensionMenuRes, menu);
    }

    mSearchMenu = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) mSearchMenu.getActionView();
    if (mSearchView != null) {
        Utils.setUpSearchView(mSearchView, this);
        mSearchView.setOnQueryTextListener(this);
        mSearchView.setOnSuggestionListener(this);
    }

    // Hide the "show/hide controls" button if this is a phone
    // or the view type is "Month" or "Agenda".

    mControlsMenu = menu.findItem(R.id.action_hide_controls);
    if (!mShowCalendarControls) {
        if (mControlsMenu != null) {
            mControlsMenu.setVisible(false);
            mControlsMenu.setEnabled(false);
        }
    } else if (mControlsMenu != null && mController != null
            && (mController.getViewType() == ViewType.MONTH || mController.getViewType() == ViewType.AGENDA)) {
        mControlsMenu.setVisible(false);
        mControlsMenu.setEnabled(false);
    } else if (mControlsMenu != null) {
        mControlsMenu.setTitle(mHideControls ? mShowString : mHideString);
    }

    MenuItem menuItem = menu.findItem(R.id.action_today);
    if (Utils.isJellybeanOrLater()) {
        // replace the default top layer drawable of the today icon with a
        // custom drawable that shows the day of the month of today
        LayerDrawable icon = (LayerDrawable) menuItem.getIcon();
        Utils.setTodayIcon(icon, this, mTimeZone);
    } else {
        menuItem.setIcon(R.drawable.ic_menu_today_no_date_holo_light);
    }
    return true;
}

From source file:de.vanita5.twittnuker.activity.support.ComposeActivity.java

private void setCommonMenu(final Menu menu) {
    final boolean hasMedia = hasMedia();
    final int activatedColor = getUserThemeColor(this);
    final MenuItem itemAddImageSubmenu = menu.findItem(R.id.add_image_submenu);
    if (itemAddImageSubmenu != null) {
        final Drawable iconAddImage = itemAddImageSubmenu.getIcon();
        iconAddImage.mutate();/*from   w ww.ja  v  a2s  . c o m*/
        if (hasMedia) {
            iconAddImage.setColorFilter(activatedColor, Mode.SRC_ATOP);
        } else {
            iconAddImage.clearColorFilter();
        }
    }
    final MenuItem itemAttachLocation = menu.findItem(MENU_ADD_LOCATION);
    if (itemAttachLocation != null) {
        final Drawable iconAttachLocation = itemAttachLocation.getIcon().mutate();
        final boolean attachLocation = mPreferences.getBoolean(KEY_ATTACH_LOCATION, false);
        if (attachLocation && getLocation()) {
            iconAttachLocation.setColorFilter(activatedColor, Mode.SRC_ATOP);
            itemAttachLocation.setTitle(R.string.remove_location);
            itemAttachLocation.setChecked(true);
        } else {
            setProgressVisibility(false);
            mPreferences.edit().putBoolean(KEY_ATTACH_LOCATION, false).commit();
            iconAttachLocation.clearColorFilter();
            itemAttachLocation.setTitle(R.string.add_location);
            itemAttachLocation.setChecked(false);
        }
    }
    final MenuItem viewItem = menu.findItem(MENU_VIEW);
    if (viewItem != null) {
        viewItem.setVisible(mInReplyToStatus != null);
    }
    final MenuItem itemToggleSensitive = menu.findItem(MENU_TOGGLE_SENSITIVE);
    if (itemToggleSensitive != null) {
        itemToggleSensitive.setVisible(hasMedia);
        itemToggleSensitive.setEnabled(hasMedia);
        itemToggleSensitive.setChecked(hasMedia && mIsPossiblySensitive);
        if (hasMedia) {
            final Drawable iconToggleSensitive = itemToggleSensitive.getIcon().mutate();
            if (mIsPossiblySensitive) {
                itemToggleSensitive.setTitle(R.string.remove_sensitive_mark);
                iconToggleSensitive.setColorFilter(activatedColor, Mode.SRC_ATOP);
            } else {
                itemToggleSensitive.setTitle(R.string.mark_as_sensitive);
                iconToggleSensitive.clearColorFilter();
            }
        }
    }
}

From source file:com.android.calendar.AllInOneActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    mOptionsMenu = menu;/*  w  w  w .  j  a  v a  2s.co m*/
    getMenuInflater().inflate(R.menu.all_in_one_title_bar, menu);

    // Add additional options (if any).
    Integer extensionMenuRes = mExtensions.getExtensionMenuResource(menu);
    if (extensionMenuRes != null) {
        getMenuInflater().inflate(extensionMenuRes, menu);
    }

    MenuItem item = menu.findItem(R.id.action_import);
    item.setVisible(ImportActivity.hasThingsToImport(this));

    mSearchMenu = menu.findItem(R.id.action_search);
    mSearchView = (SearchView) MenuItemCompat.getActionView(mSearchMenu);
    if (mSearchView != null) {
        Utils.setUpSearchView(mSearchView, this);
        mSearchView.setOnQueryTextListener(this);
        mSearchView.setOnSuggestionListener(this);
    }

    // Hide the "show/hide controls" button if this is a phone
    // or the view type is "Month" or "Agenda".

    mControlsMenu = menu.findItem(R.id.action_hide_controls);
    if (!mShowCalendarControls) {
        if (mControlsMenu != null) {
            mControlsMenu.setVisible(false);
            mControlsMenu.setEnabled(false);
        }
    } else if (mControlsMenu != null && mController != null
            && (mController.getViewType() == ViewType.MONTH || mController.getViewType() == ViewType.AGENDA)) {
        mControlsMenu.setVisible(false);
        mControlsMenu.setEnabled(false);
    } else if (mControlsMenu != null) {
        mControlsMenu.setTitle(mHideControls ? mShowString : mHideString);
    }

    MenuItem menuItem = menu.findItem(R.id.action_today);
    if (Utils.isJellybeanOrLater()) {
        // replace the default top layer drawable of the today icon with a
        // custom drawable that shows the day of the month of today
        LayerDrawable icon = (LayerDrawable) menuItem.getIcon();
        Utils.setTodayIcon(icon, this, mTimeZone);
    } else {
        menuItem.setIcon(R.drawable.ic_menu_today_no_date_holo_light);
    }
    return true;
}

From source file:com.irccloud.android.activity.VideoPlayerActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_videoplayer, menu);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M && getIntent() != null
            && getIntent().getDataString() != null) {
        Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse(
                getIntent().getDataString().replace(getResources().getString(R.string.VIDEO_SCHEME), "http")));
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT,
                getIntent().getDataString().replace(getResources().getString(R.string.VIDEO_SCHEME), "http"));
        intent.putExtra(ShareCompat.EXTRA_CALLING_PACKAGE, getPackageName());
        intent.putExtra(ShareCompat.EXTRA_CALLING_ACTIVITY,
                getPackageManager().getLaunchIntentForPackage(getPackageName()).getComponent());
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_TASK);

        MenuItem shareItem = menu.findItem(R.id.action_share);
        share = (ShareActionProviderHax) MenuItemCompat.getActionProvider(shareItem);
        share.onShareActionProviderSubVisibilityChangedListener = this;
        share.setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {
            @Override/* w  w  w  . j a  v a 2s  .c  o  m*/
            public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
                String name = intent.getComponent().getPackageName();
                try {
                    name = String.valueOf(getPackageManager().getActivityInfo(intent.getComponent(), 0)
                            .loadLabel(getPackageManager()));
                } catch (PackageManager.NameNotFoundException e) {
                    NetworkConnection.printStackTraceToCrashlytics(e);
                }
                Answers.getInstance().logShare(new ShareEvent().putContentType("Video").putMethod(name));
                return false;
            }
        });
        share.setShareIntent(intent);
    } else {
        MenuItem shareItem = menu.findItem(R.id.action_share);
        if (shareItem != null && shareItem.getIcon() != null)
            shareItem.getIcon().mutate().setColorFilter(0xFFCCCCCC, PorterDuff.Mode.SRC_ATOP);
    }
    return true;
}

From source file:com.agenmate.lollipop.addedit.AddEditFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        getActivity().onBackPressed();/*w  ww. ja va 2s.  c  o m*/
        return true;
    case R.id.action_save:
        String title = emptyStringChecker(titleEdit.getText().toString());
        if (title == null) {
            Snackbar.make(background, "Title can't be Empty", Snackbar.LENGTH_LONG).show();
            return true;
        }
        String description = emptyStringChecker(descEdit.getText().toString());
        int priority = getPriority();

        long dueAt = getDueDate();
        if (dueAt < 0) {
            Snackbar.make(background, "Not enough time to complete task at due date", Snackbar.LENGTH_LONG)
                    .show();
            return true;
        }

        presenter.saveTask(title, description, priority, selectedColor, dueAt, hasAlarm, isCompleted);

        return true;
    case R.id.action_alarm:
        if (!hasAlarm) {
            if (getDueDate() < 0) {
                Snackbar.make(background, "Not enough time to complete task at due date", Snackbar.LENGTH_LONG)
                        .show();
                return true;
            }
        }
        boolean setWhite = selectedColor == 0 || selectedColor == 5 || selectedColor == 6;
        item.setIcon(hasAlarm ? R.drawable.ic_alarm_off : R.drawable.ic_alarm_on);
        Drawable drawable = item.getIcon();
        drawable.mutate();
        drawable.setColorFilter(setWhite ? Color.WHITE : Color.BLACK, PorterDuff.Mode.SRC_ATOP);
        hasAlarm = !hasAlarm;
        return true;

    case R.id.action_delete:
        presenter.deleteTask();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.dwdesign.tweetings.activity.ComposeActivity.java

private void setMenu() {
    final Menu menu = mMenuBar.getMenu();
    final int activated_color = getResources().getColor(R.color.holo_blue_bright);
    final MenuItem itemAddImage = menu.findItem(MENU_ADD_IMAGE);
    final MenuItem itemLibrary = menu.findItem(MENU_LIBRARY_MENU);
    final Drawable iconAddImage = itemAddImage.getIcon().mutate();
    final Drawable iconLibrary = itemLibrary.getIcon().mutate();
    boolean menuSelected = false;
    if (mIsImageAttached && !mIsPhotoAttached) {
        iconAddImage.setColorFilter(activated_color, Mode.MULTIPLY);
        itemAddImage.setTitle(R.string.remove_image);
        menuSelected = true;// w  ww .  j  a v a 2 s  . c o  m
    } else {
        iconAddImage.clearColorFilter();
        itemAddImage.setTitle(R.string.add_image);
    }
    final MenuItem itemTakePhoto = menu.findItem(MENU_TAKE_PHOTO);
    final Drawable iconTakePhoto = itemTakePhoto.getIcon().mutate();
    if (!mIsImageAttached && mIsPhotoAttached) {
        iconTakePhoto.setColorFilter(activated_color, Mode.MULTIPLY);
        itemTakePhoto.setTitle(R.string.remove_photo);
        menuSelected = true;
    } else {
        iconTakePhoto.clearColorFilter();
        itemTakePhoto.setTitle(R.string.take_photo);
    }
    if (menuSelected == true) {
        iconLibrary.setColorFilter(activated_color, Mode.MULTIPLY);
    } else {
        iconLibrary.clearColorFilter();
    }
    final MenuItem itemAttachLocation = menu.findItem(MENU_ADD_LOCATION);
    final Drawable iconAttachLocation = itemAttachLocation.getIcon().mutate();
    final boolean attach_location = mPreferences.getBoolean(PREFERENCE_KEY_ATTACH_LOCATION, false);
    if (attach_location && getLocation()) {
        iconAttachLocation.setColorFilter(activated_color, Mode.MULTIPLY);
        itemAttachLocation.setTitle(R.string.remove_location);
    } else {
        mPreferences.edit().putBoolean(PREFERENCE_KEY_ATTACH_LOCATION, false).commit();
        iconAttachLocation.clearColorFilter();
        itemAttachLocation.setTitle(R.string.add_location);
    }
    final MenuItem itemMore = menu.findItem(R.id.more_submenu);

    boolean moreHighlighted = false;
    if (itemMore != null) {
        final MenuItem itemDrafts = menu.findItem(R.id.drafts);
        final MenuItem itemToggleSensitive = menu.findItem(MENU_TOGGLE_SENSITIVE);
        if (itemMore != null) {
            if (itemDrafts != null) {
                final Cursor drafts_cur = getContentResolver().query(Drafts.CONTENT_URI, new String[0], null,
                        null, null);
                final Drawable iconMore = itemMore.getIcon().mutate();
                final Drawable iconDrafts = itemDrafts.getIcon().mutate();
                if (drafts_cur.getCount() > 0) {
                    moreHighlighted = true;
                    iconDrafts.setColorFilter(activated_color, Mode.MULTIPLY);
                } else {
                    iconDrafts.clearColorFilter();
                }
                drafts_cur.close();
            }
            if (itemToggleSensitive != null) {
                final boolean has_media = (mIsImageAttached || mIsPhotoAttached) && mImageUri != null;
                if (has_media && isNullOrEmpty(mUploadProvider)) {
                    itemToggleSensitive.setVisible(true);
                } else {
                    itemToggleSensitive.setVisible(false);
                }
                if (has_media && isNullOrEmpty(mUploadProvider)) {
                    final Drawable iconToggleSensitive = itemToggleSensitive.getIcon().mutate();
                    if (mIsPossiblySensitive) {
                        moreHighlighted = true;
                        iconToggleSensitive.setColorFilter(activated_color, Mode.MULTIPLY);
                    } else {
                        iconToggleSensitive.clearColorFilter();
                    }
                }
            }
        }
    }
    if (mScheduleDate != null) {
        final MenuItem itemSchedule = menu.findItem(R.id.schedule_tweet);
        final Drawable iconSchedule = itemSchedule.getIcon().mutate();
        iconSchedule.setColorFilter(activated_color, Mode.MULTIPLY);
        moreHighlighted = true;
        itemSchedule.setTitle(getString(R.string.schedule_clear));
    } else {
        final MenuItem itemSchedule = menu.findItem(R.id.schedule_tweet);
        final Drawable iconSchedule = itemSchedule.getIcon().mutate();
        iconSchedule.clearColorFilter();
        itemSchedule.setTitle(getString(R.string.schedule_tweet));
    }

    final String consumer_key = mPreferences.getString(PREFERENCE_KEY_CONSUMER_KEY, null);
    final String consumer_secret = mPreferences.getString(PREFERENCE_KEY_CONSUMER_SECRET, null);

    if (!isNullOrEmpty(consumer_key) && !isNullOrEmpty(consumer_secret)) {
        final MenuItem itemSchedule = menu.findItem(R.id.schedule_tweet);

        itemSchedule.setVisible(false);
    }

    final MenuItem bufferItem = menu.findItem(MENU_ADD_TO_BUFFER);
    if (bufferItem != null) {
        final String buffer_authorised = mPreferences.getString(PREFERENCE_KEY_BUFFERAPP_ACCESS_TOKEN, null);
        final Drawable iconBuffer = bufferItem.getIcon().mutate();
        if (buffer_authorised != null && !buffer_authorised.equals("")) {
            bufferItem.setVisible(true);
            if (mIsBuffer) {
                iconBuffer.setColorFilter(activated_color, Mode.MULTIPLY);
                moreHighlighted = true;
            } else {
                iconBuffer.clearColorFilter();
            }
        } else {
            bufferItem.setVisible(false);
            mIsBuffer = false;
        }
    }
    if (itemMore != null) {
        final Drawable iconMore = itemMore.getIcon().mutate();
        if (moreHighlighted == true) {
            iconMore.setColorFilter(activated_color, Mode.MULTIPLY);
        } else {
            iconMore.clearColorFilter();
        }
    }
    mMenuBar.invalidate();
    invalidateSupportOptionsMenu();
}

From source file:com.dwdesign.tweetings.fragment.UserProfileFragment.java

@Override
public void onClick(final View view) {
    switch (view.getId()) {
    case R.id.follow: {
        if (mUser != null && mAccountId != mUser.getId()) {
            mFollowProgress.setVisibility(View.VISIBLE);
            mFollowButton.setVisibility(View.GONE);
            if (mFriendship.isSourceFollowingTarget()) {
                mService.destroyFriendship(mAccountId, mUser.getId());
            } else {
                mService.createFriendship(mAccountId, mUser.getId());
            }//  www  .  j a v  a 2 s  .  c o m
        }
        break;
    }
    case R.id.retry: {
        reloadUserInfo();
        break;
    }
    case R.id.name_container: {
        if (mUser != null) {
        }
        break;
    }
    case R.id.profile_image_container: {
        final String profile_image_url_string = getOriginalTwitterProfileImage(
                parseString(mUser.getProfileImageURL()));
        if (profile_image_url_string == null)
            return;
        final Uri uri = Uri.parse(profile_image_url_string);
        openImage(getActivity(), uri, false);
        break;
    }
    case R.id.tweets_container: {
        if (mUser == null)
            return;
        openUserTimeline(getActivity(), mAccountId, mUser.getId(), mUser.getScreenName());
        break;
    }
    case R.id.followers_container: {
        if (mUser == null)
            return;
        openUserFollowers(getActivity(), mAccountId, mUser.getId(), mUser.getScreenName());
        break;
    }
    case R.id.friends_container: {
        if (mUser == null)
            return;
        openUserFriends(getActivity(), mAccountId, mUser.getId(), mUser.getScreenName());
        break;
    }
    case R.id.more_options: {
        if (mUser == null || mFriendship == null)
            return;
        if (!isMyActivatedAccount(getActivity(), mUser.getId())) {
            mPopupMenu = PopupMenu.getInstance(getActivity(), view);
            mPopupMenu.inflate(R.menu.action_user_profile);
            final Menu menu = mPopupMenu.getMenu();
            final MenuItem blockItem = menu.findItem(MENU_BLOCK);
            final MenuItem trackItem = menu.findItem(MENU_TRACKING);
            if (blockItem != null) {
                final Drawable blockIcon = blockItem.getIcon();
                if (mFriendship.isSourceBlockingTarget()) {
                    blockItem.setTitle(R.string.unblock);
                    blockIcon.mutate().setColorFilter(getResources().getColor(R.color.holo_blue_bright),
                            PorterDuff.Mode.MULTIPLY);
                } else {
                    blockItem.setTitle(R.string.block);
                    blockIcon.clearColorFilter();
                }
            }
            if (trackItem != null) {
                if (mPreferences.getBoolean(com.dwdesign.tweetings.Constants.PREFERENCE_KEY_PUSH_NOTIFICATIONS,
                        false) == false) {
                    trackItem.setVisible(false);
                } else {
                    if (tracking == true) {
                        trackItem.setTitle(R.string.untrack_user);
                    } else {
                        trackItem.setTitle(R.string.track_user);
                    }
                }
            }
            final MenuItem sendDirectMessageItem = menu.findItem(MENU_SEND_DIRECT_MESSAGE);
            if (sendDirectMessageItem != null) {
                sendDirectMessageItem.setVisible(mFriendship.isTargetFollowingSource());
            }
            final MenuItem wantRetweetsItem = menu.findItem(MENU_WANT_RETWEETS);
            if (mFriendship.wantRetweets() == true) {
                wantRetweetsItem.setTitle(R.string.disable_retweet);
            } else {
                wantRetweetsItem.setTitle(R.string.enable_retweet);
            }
            mPopupMenu.setOnMenuItemClickListener(this);
            mPopupMenu.show();
        }
        break;
    }
    }

}

From source file:org.mariotaku.twidere.util.Utils.java

public static void setMenuForStatus(final Context context, final Menu menu, final ParcelableStatus status) {
    if (context == null || menu == null || status == null)
        return;//from www.  j  a v  a  2s .  co  m
    final int activated_color = context.getResources().getColor(R.color.holo_blue_bright);
    final MenuItem delete = menu.findItem(R.id.delete_submenu);
    if (delete != null) {
        delete.setVisible(status.account_id == status.user_id && !isMyRetweet(status));
    }
    final MenuItem retweet = menu.findItem(MENU_RETWEET);
    if (retweet != null) {
        final Drawable icon = retweet.getIcon().mutate();
        retweet.setVisible(!status.is_protected || isMyRetweet(status));
        if (isMyRetweet(status)) {
            icon.setColorFilter(activated_color, Mode.MULTIPLY);
            retweet.setTitle(R.string.cancel_retweet);
        } else {
            icon.clearColorFilter();
            retweet.setTitle(R.string.retweet);
        }
    }
    final MenuItem favorite = menu.findItem(MENU_FAVORITE);
    if (favorite != null) {
        final Drawable icon = favorite.getIcon().mutate();
        if (status.is_favorite) {
            icon.setColorFilter(activated_color, Mode.MULTIPLY);
            favorite.setTitle(R.string.unfavorite);
        } else {
            icon.clearColorFilter();
            favorite.setTitle(R.string.favorite);
        }
    }
    final MenuItem extensions = menu.findItem(MENU_EXTENSIONS_SUBMENU);
    if (extensions != null) {
        final Intent intent = new Intent(INTENT_ACTION_EXTENSION_OPEN_STATUS);
        final Bundle extras = new Bundle();
        extras.putParcelable(INTENT_KEY_STATUS, status);
        intent.putExtras(extras);
        final PackageManager pm = context.getPackageManager();
        final List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0);
        final boolean has_extension = !activities.isEmpty();
        extensions.setVisible(has_extension);
        if (has_extension) {
            addIntentToSubMenu(context, extensions.getSubMenu(), intent);
        }
    }
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void setMenuForStatus(final Context context, final Menu menu, final ParcelableStatus status) {
    if (context == null || menu == null || status == null)
        return;//from www.jav a  2s  .c om
    final int activated_color = context.getResources().getColor(R.color.holo_blue_bright);
    final MenuItem itemDelete = menu.findItem(R.id.delete_submenu);
    if (itemDelete != null) {
        itemDelete.setVisible(status.account_id == status.user_id && !isMyRetweet(status));
    }
    final MenuItem itemRetweet = menu.findItem(MENU_RETWEET);
    if (itemRetweet != null) {
        final Drawable icon = itemRetweet.getIcon().mutate();
        itemRetweet.setVisible(
                (!status.is_protected && status.account_id != status.user_id) || isMyRetweet(status));
        if (isMyRetweet(status)) {
            icon.setColorFilter(activated_color, Mode.MULTIPLY);
            itemRetweet.setTitle(R.string.cancel_retweet);
        } else {
            icon.clearColorFilter();
            itemRetweet.setTitle(R.string.retweet);
        }
    }
    final MenuItem itemFav = menu.findItem(MENU_FAV);
    if (itemFav != null) {
        final Drawable iconFav = itemFav.getIcon().mutate();
        if (status.is_favorite) {
            iconFav.setColorFilter(activated_color, Mode.MULTIPLY);
            itemFav.setTitle(R.string.unfav);
        } else {
            iconFav.clearColorFilter();
            itemFav.setTitle(R.string.fav);
        }
    }
    final MenuItem itemConversation = menu.findItem(MENU_CONVERSATION);
    if (itemConversation != null) {
        itemConversation.setVisible(status.in_reply_to_status_id > 0);
    }
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static void setMenuForStatus(final Context context, final Menu menu, final ParcelableStatus status) {
    if (context == null || menu == null || status == null)
        return;//from   w ww . j  av  a2 s  .c  om
    final int activatedColor = ThemeUtils.getUserThemeColor(context);
    final boolean isMyRetweet = isMyRetweet(status);
    final MenuItem delete = menu.findItem(MENU_DELETE);
    if (delete != null) {
        delete.setVisible(status.account_id == status.user_id && !isMyRetweet);
    }
    final MenuItem retweet = menu.findItem(MENU_RETWEET);
    if (retweet != null) {
        final Drawable icon = retweet.getIcon().mutate();
        retweet.setVisible(!status.user_is_protected || isMyRetweet);
        if (isMyRetweet) {
            icon.setColorFilter(activatedColor, Mode.SRC_ATOP);
            retweet.setTitle(R.string.cancel_retweet);
        } else {
            icon.clearColorFilter();
            retweet.setTitle(R.string.retweet);
        }
    }
    final MenuItem itemRetweetSubmenu = menu.findItem(R.id.retweet_submenu);
    if (itemRetweetSubmenu != null) {
        final Drawable icon = itemRetweetSubmenu.getIcon().mutate();
        if (isMyRetweet) {
            icon.setColorFilter(activatedColor, Mode.SRC_ATOP);
        } else {
            icon.clearColorFilter();
        }
    }
    final MenuItem favorite = menu.findItem(MENU_FAVORITE);
    if (favorite != null) {
        final Drawable icon = favorite.getIcon().mutate();
        if (status.is_favorite) {
            icon.setColorFilter(activatedColor, Mode.SRC_ATOP);
            favorite.setTitle(R.string.unfavorite);
        } else {
            icon.clearColorFilter();
            favorite.setTitle(R.string.favorite);
        }
    }
    final MenuItem love = menu.findItem(MENU_LOVE);
    if (love != null) {
        final Drawable icon = love.getIcon().mutate();
        love.setVisible(!status.user_is_protected || isMyRetweet);
        if (isMyRetweet && status.is_favorite) {
            icon.setColorFilter(activatedColor, Mode.SRC_ATOP);
        } else {
            icon.clearColorFilter();
        }
    }
    final MenuItem translate = menu.findItem(MENU_TRANSLATE);
    if (translate != null) {
        final AccountWithCredentials account = Account.getAccountWithCredentials(context, status.account_id);
        final boolean isOfficialKey = AccountWithCredentials.isOfficialCredentials(context, account);
        setMenuItemAvailability(menu, MENU_TRANSLATE, isOfficialKey);
    }
    final MenuItem shareItem = menu.findItem(R.id.share_submenu);
    final Menu shareSubmenu = shareItem != null && shareItem.hasSubMenu() ? shareItem.getSubMenu() : null;
    if (shareSubmenu != null) {
        final Intent shareIntent = createStatusShareIntent(context, status);
        shareSubmenu.removeGroup(MENU_GROUP_STATUS_SHARE);
        addIntentToMenu(context, shareSubmenu, shareIntent, MENU_GROUP_STATUS_SHARE);
    }
}