Example usage for android.view MenuItem getActionProvider

List of usage examples for android.view MenuItem getActionProvider

Introduction

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

Prototype

public ActionProvider getActionProvider();

Source Link

Document

Gets the ActionProvider .

Usage

From source file:com.jbirdvegas.mgerrit.PatchSetViewerActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.change_details_menu, menu);
    MenuItem item = menu.findItem(R.id.menu_details_share);
    mShareActionProvider = (ShareActionProvider) item.getActionProvider();

    if (mStatus != null)
        setShareIntent(mChangeId, mChangeNumber);
    return true;//from w  w w  . j a  va2 s.  c om
}

From source file:net.sourceforge.lifeograph.ActivityChapterTag.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    getMenuInflater().inflate(R.menu.menu_chapter_tag, menu);

    MenuItem item = menu.findItem(R.id.change_todo_status);
    ToDoAction ToDoAction = (ToDoAction) item.getActionProvider();
    ToDoAction.mObject = this;

    return true;/*from   w  ww . j  a  v  a2s  .c o  m*/
}

From source file:com.arquitetaweb.observatorio.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.main, menu);

    // Locate MenuItem with ShareActionProvider
    MenuItem item = menu.findItem(R.id.menu_item_share);
    // Fetch and store ShareActionProvider
    mShareActionProvider = (ShareActionProvider) item.getActionProvider();

    Intent mShareIntent = new Intent();
    mShareIntent.setAction(Intent.ACTION_SEND);
    mShareIntent.putExtra(Intent.EXTRA_TEXT,
            "Fique por dentro do oramento e despesas de Maring acesse o site e baixe o aplicativo.\nhttp://observatoriomga.herokuapp.com/#graph/pie/pai");

    mShareIntent.setType("*/*");

    if (mShareActionProvider != null) {
        mShareActionProvider.setShareIntent(mShareIntent);
    }/*from www.  j a v a  2 s.c o m*/

    return super.onCreateOptionsMenu(menu);
}

From source file:org.zakky.memopad.PadActivity.java

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

    /*//  w ww  .jav  a2 s  .c o m
     * 
     */
    MenuItem penColorMenuItem = menu.findItem(R.id.menu_pen_color);
    PenConfigActionProvider actionProvider = (PenConfigActionProvider) penColorMenuItem.getActionProvider();
    actionProvider.setOnColorChangedListener(new OnPenConfigChangedListener() {
        @Override
        public void onColorChanged(int index) {
            getCurrentCanvas().setPenColorIndex(index);
        }

        @Override
        public void onWidthChanged(float width) {
            mCurrentPenSize = width;
            getCurrentCanvas().setPenSize(width);
        }
    });
    // ????2??????
    getCurrentCanvas().setNextPenColor(mPenColorValues.length);

    mCurrentPenSize = 20f;
    getCurrentCanvas().setPenSize(mCurrentPenSize);

    //        mPenColorMenuLabelBase = mPenColorMenuItem.getTitle();
    //        getCurrentCanvas().applyPenColor();

    /*
     * 
     */
    //        mBgColorMenuItem = menu.findItem(R.id.menu_bg_color);
    //        mBgColorMenuLabelBase = mBgColorMenuItem.getTitle();
    //        getCurrentCanvas().applyBgColor();
    final MenuItem bgColorMenuItem = menu.findItem(R.id.menu_bg_color);
    final BgConfigActionProvider bgActionProvider = (BgConfigActionProvider) bgColorMenuItem
            .getActionProvider();
    bgActionProvider.setOnColorChangedListener(new OnBgConfigChangedListener() {
        @Override
        public void onColorChanged(int index) {
            getCurrentCanvas().setBgColorIndex(index);
        }
    });
    getCurrentCanvas().applyBgColor();

    return super.onCreateOptionsMenu(menu);
}

From source file:ca.mymenuapp.ui.activities.RestaurantActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_restaurant, menu);
    android.view.MenuItem item = menu.findItem(R.id.restaurant_share);
    shareActionProvider = (ShareActionProvider) item.getActionProvider();
    return true;/* w  w w  . j  a  va2 s  . co m*/
}

From source file:pl.bcichecki.rms.client.android.fragments.DevicesListFragment.java

private void performActionShare(final ActionMode mode, MenuItem item, final Device selectedDevice) {
    ShareActionProvider shareActionProvider = (ShareActionProvider) item.getActionProvider();
    if (shareActionProvider != null) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType(AppConstants.CONTENT_TEXT_PLAIN);
        intent.putExtra(Intent.EXTRA_TEXT,
                new DeviceTextPrettyPrinterPrinter(getActivity()).print(selectedDevice));
        shareActionProvider.setShareHistoryFileName(null);
        shareActionProvider.setShareIntent(intent);

        Log.d(TAG, "Device " + selectedDevice + " was succesfully shared.");
    }/*w w w .ja  v  a 2s  .  c  o  m*/
}

From source file:org.rm3l.ddwrt.tiles.status.wireless.WirelessIfaceQrCodeActivity.java

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

    this.optionsMenu = menu;

    /* Getting the actionprovider associated with the menu item whose id is share */
    final MenuItem shareMenuItem = menu.findItem(R.id.tile_status_wireless_iface_qrcode_share);
    shareMenuItem.setEnabled(mException == null);

    mShareActionProvider = (ShareActionProvider) shareMenuItem.getActionProvider();

    final View viewToShare = findViewById(R.id.tile_status_wireless_iface_qrcode_view_to_share);
    //Construct Bitmap and share it
    final Bitmap bitmapToExport = Bitmap.createBitmap(viewToShare.getWidth(), viewToShare.getHeight(),
            Bitmap.Config.ARGB_8888);/*from   w  w w . j  ava 2 s .  co m*/
    final Canvas canvas = new Canvas(bitmapToExport);
    viewToShare.draw(canvas);

    mFileToShare = new File(getCacheDir(), String.format("QR-Code_for_Wireless_Network__%s__on_router_%s.png",
            nullToEmpty(mSsid), nullToEmpty(mRouterUuid)));
    OutputStream outputStream = null;
    try {
        outputStream = new BufferedOutputStream(new FileOutputStream(mFileToShare, false));
        bitmapToExport.compress(Bitmap.CompressFormat.PNG, COMPRESSION_QUALITY, outputStream);
        outputStream.flush();
    } catch (IOException e) {
        e.printStackTrace();
        Crouton.makeText(this, getString(R.string.internal_error_please_try_again), Style.ALERT).show();
    } finally {
        try {
            if (outputStream != null) {
                outputStream.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
            //No Worries
        }
    }

    setShareFile(mFileToShare);

    return super.onCreateOptionsMenu(menu);
}

From source file:eg.edu.alexu.alexandriauniversity.activity.ViewItemActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    getMenuInflater().inflate(R.menu.view_item_menu, menu);
    MenuUtils.setShowAsActionAll(menu);//from  w w w  .  j  av  a 2 s.co  m
    if (newerItemId < 0) {
        menu.removeItem(R.id.newer_item);
    }
    if (olderItemId < 0) {
        menu.removeItem(R.id.older_item);
    }

    // Retrieve the share menu item
    MenuItem menuItem = menu.findItem(R.id.action_share);

    // Get the provider and hold onto it to set/change the share intent.
    mShareActionProvider = (ShareActionProvider) menuItem.getActionProvider();

    // If onLoadFinished happens before this, we can go ahead and set the share intent now.
    if (mAlexU != null) {
        if (mShareActionProvider != null) {
            mShareActionProvider.setShareIntent(createShareIntent());
        }
    }

    return true;
}

From source file:com.robandjen.comicsapp.FullscreenActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.mainmenu, menu);

    MenuItem shareitem = menu.findItem(R.id.menu_share);
    mShareProvider = (ShareActionProvider) shareitem.getActionProvider();
    if (mShareProvider != null) {
        mShareIntent = new Intent();
        mShareIntent.setAction(Intent.ACTION_SEND);
        mShareIntent.setType("text/plain");
        mShareProvider.setShareIntent(mShareIntent);
    }//from w w  w.j  a  v  a2  s  .  com
    return super.onCreateOptionsMenu(menu);
}

From source file:ru.gkpromtech.exhibition.media.FullImageActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate menu resource file.
    getMenuInflater().inflate(R.menu.menu_fullscreen_image, menu);

    MenuItem itemSave = menu.findItem(R.id.menu_item_save);
    MenuItem shareItem = menu.findItem(R.id.menu_item_share);

    itemSave.setVisible(mode == SHOW_FILES_MODE ? false : true);

    // Fetch and store ShareActionProvider
    mShareActionProvider = (ShareActionProvider) shareItem.getActionProvider();
    if (mShareActionProvider == null) {
        // Following http://stackoverflow.com/questions/19358510/why-menuitemcompat-getactionprovider-returns-null
        mShareActionProvider = new ShareActionProvider(this);
    }/*from   w  w w  .j a v  a2  s  .c  om*/

    final ViewPager pager = (ViewPager) findViewById(R.id.pager);
    int index = pager.getCurrentItem();
    Object mediaItem = getMediaItem(index);

    shareIntent = getShareIntent();
    setShareIntentMedia(shareIntent, mediaItem);
    setShareIntent(shareIntent);

    pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            Object item = getMediaItem(position);
            setShareIntentMedia(shareIntent, item);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });

    return true;
}