Example usage for android.view Menu close

List of usage examples for android.view Menu close

Introduction

In this page you can find the example usage for android.view Menu close.

Prototype

public void close();

Source Link

Document

Closes the menu, if open.

Usage

From source file:t0mm13b.dmesglog.ui.DMesgViewer.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Log.d(TAG, "onCreateOptionsMenu - CHECK!");
    getMenuInflater().inflate(R.menu.main_menu, menu);
    if (this.mMIPause == null) {
        this.mMIPause = menu.findItem(R.id.menu_pause);
        if (this.mMIPause != null) {
            Log.d(TAG, "FOUND THE PAUSE MENU! \\o/");
            menu.close();
            return true;
        } else {/*  ww w  . ja  v a2 s.com*/
            Log.d(TAG, "NOT FOUND THE PAUSE MENU! /o\\");
        }

    }
    return super.onCreateOptionsMenu(menu);
}

From source file:org.brandroid.openmanager.activities.OpenExplorer.java

@Override
public boolean onMenuOpened(int featureId, Menu menu) {
    Logger.LogDebug("OpenExplorer.onMenuOpened(0x" + Integer.toHexString(featureId) + "," + menu + ")");
    if (USE_PRETTY_MENUS) {
        if (menu != null && !menu.equals(mMainMenu) && !menu.equals(mOptsMenu))
            menu.close();
        return false;
    }//from   w ww.j  av  a 2 s  .  c  o m
    return super.onMenuOpened(featureId, menu);
}

From source file:com.android.gallery3d.app.PhotoPage.java

private void updateMenuOperations() {
    Menu menu = mActionBar.getMenu();

    // it could be null if onCreateActionBar has not been called yet
    if (menu == null)
        return;//from  w ww. j a  va 2s  .c o m

    MenuItem item = menu.findItem(R.id.action_slideshow);
    if (item != null) {
        item.setVisible((mSecureAlbum == null) && canDoSlideShow());
    }
    if (mCurrentPhoto == null)
        return;

    int supportedOperations = mCurrentPhoto.getSupportedOperations();
    if (mReadOnlyView) {
        /// M: [BUG.MODIFY] @{
        /*supportedOperations ^= MediaObject.SUPPORT_EDIT;*/
        // when mReadOnlyView == true, set SUPPORT_EDIT as false
        supportedOperations &= ~MediaObject.SUPPORT_EDIT;
        /// @}
    }
    if (mSecureAlbum != null) {
        supportedOperations &= MediaObject.SUPPORT_DELETE;
    } else {
        mCurrentPhoto.getPanoramaSupport(mUpdatePanoramaMenuItemsCallback);
        if (!mHaveImageEditor) {
            supportedOperations &= ~MediaObject.SUPPORT_EDIT;
        }
    }
    /// M: [FEATURE.ADD] @{
    if (MediaObject.MEDIA_TYPE_IMAGE == mCurrentPhoto.getMediaType()) {
        if (true == FeatureConfig.SUPPORT_PQ) {
            supportedOperations |= MediaObject.SUPPORT_PQ;
        }
        if (true == FeatureConfig.SUPPORT_IMAGE_DC_ENHANCE) {
            supportedOperations |= MediaObject.SUPPORT_DC;
            MenuItem dcItem = menu.findItem(R.id.m_action_image_dc);
            ImageDC.setMenuItemTile(dcItem);
        }
    }
    /// @}
    /// M: [BUG.ADD] KK native judge mime type, no need AP judge @{
    if (mCurrentPhoto.getMimeType() == null) {
        supportedOperations &= ~MediaObject.SUPPORT_TRIM;
    }
    /// @}
    /// M: [BUG.ADD] @{
    // reget print system operation
    PrintHelper printHelper = new PrintHelper(mActivity.getAndroidContext());
    if (!printHelper.systemSupportsPrint()) {
        supportedOperations &= ~MediaObject.SUPPORT_PRINT;
    }
    /// @}
    /// M: [BUG.ADD] can not set as wallpaper when no thumbnail @{
    mSupportedOperations = supportedOperations;
    /// @}
    MenuExecutor.updateMenuOperation(menu, supportedOperations);

    /// M: [FEATURE.ADD] HotKnot @{
    boolean canShareByHotKnot = (supportedOperations & MediaObject.SUPPORT_SHARE) != 0;
    mActivity.getHotKnot().updateMenu(menu, R.id.action_share, R.id.action_hotknot, canShareByHotKnot);
    /// @}
    /// M: [BUG.ADD] supported operations is zero(camera preview), close menu @{
    if (supportedOperations == 0) {
        menu.close();
    }
    /// @}
}