Java Code Examples for android.support.v4.view.MenuItemCompat#getActionProvider()
The following examples show how to use
android.support.v4.view.MenuItemCompat#getActionProvider() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DetailFragment.java From Krishi-Seva with MIT License | 6 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { // Inflate the menu; this adds items to the action bar if it is present. inflater.inflate(R.menu.detailfragment, menu); // 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) MenuItemCompat.getActionProvider(menuItem); // If onLoadFinished happens before this, we can go ahead and set the share intent now. if (mForecast != null) { mShareActionProvider.setShareIntent(createShareForecastIntent()); } }
Example 2
Source File: RideDetailActivity.java From android-ponewheel with MIT License | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.ride_menu, menu); // store action provider shareMenuItem = menu.findItem(R.id.menu_item_share); shareMenuItem.setVisible(false); shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareMenuItem); // Create share intent shareFileIntent = new Intent(); shareFileIntent.setAction(Intent.ACTION_SEND); shareFileIntent.setType("text/csv"); shareFileIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); setShareIntent(shareFileIntent); return true; }
Example 3
Source File: BooksPagerFragment.java From barterli_android with Apache License 2.0 | 6 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_book_detail, menu); final MenuItem menuItem = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem); if (mAdapter.getCount() > 0) { final int position = mBookDetailPager.getCurrentItem(); updateShareIntent(mAdapter.getBookTitleForPosition(position)); updateUserProfile(position); } else { updateShareIntent(null); } }
Example 4
Source File: MainActivity.java From android-MediaRouter with Apache License 2.0 | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { // Be sure to call the super class. super.onCreateOptionsMenu(menu); // Inflate the menu and configure the media router action provider. getMenuInflater().inflate(R.menu.sample_media_router_menu, menu); MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item); MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem); mediaRouteActionProvider.setRouteSelector(mSelector); // Return true to show the menu. return true; }
Example 5
Source File: DeepZoomFragment.java From Ouroboros with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.menu_deep_zoom, menu); MenuItem saveImage = menu.findItem(R.id.action_save_image); MenuItem openExternalButton = menu.findItem(R.id.action_external_browser); MenuItem shareButton = menu.findItem(R.id.menu_item_share); shareButton.setVisible(true); saveImage.setVisible(true); openExternalButton.setVisible(true); getActivity().setTitle(mediaItem.fileName + mediaItem.ext); shareActionProvider = MenuItemCompat.getActionProvider(shareButton); super.onCreateOptionsMenu(menu, inflater); }
Example 6
Source File: CommentActivity.java From ting with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.song_menu, menu); MenuItem item = menu.findItem(R.id.action_share); shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); return true; }
Example 7
Source File: BaseCastManager.java From android with Apache License 2.0 | 5 votes |
/** * Adds and wires up the Media Router cast button. It returns a pointer to the Media Router menu * item if the caller needs such reference. It is assumed that the enclosing * {@link android.app.Activity} inherits (directly or indirectly) from * {@link android.support.v7.app.ActionBarActivity}. * * @param menu * @param menuResourceId The resource id of the cast button in the xml menu descriptor file * @return */ public MenuItem addMediaRouterButton(Menu menu, int menuResourceId) { MenuItem mediaRouteMenuItem = menu.findItem(menuResourceId); MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem); mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector); if (null != getMediaRouteDialogFactory()) { mediaRouteActionProvider.setDialogFactory(getMediaRouteDialogFactory()); } return mediaRouteMenuItem; }
Example 8
Source File: AudioNoteActivity.java From privacy-friendly-notes with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. if (edit){ getMenuInflater().inflate(R.menu.audio, menu); MenuItem item = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); setShareIntent(); } return true; }
Example 9
Source File: ChecklistNoteActivity.java From privacy-friendly-notes with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. if (edit){ getMenuInflater().inflate(R.menu.checklist, menu); MenuItem item = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); setShareIntent(); } return true; }
Example 10
Source File: SketchActivity.java From privacy-friendly-notes with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. if (edit){ getMenuInflater().inflate(R.menu.audio, menu); MenuItem item = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); setShareIntent(); } return true; }
Example 11
Source File: TextNoteActivity.java From privacy-friendly-notes with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. if (edit){ getMenuInflater().inflate(R.menu.text, menu); MenuItem item = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); setShareIntent(); } return true; }
Example 12
Source File: MainActivity.java From DexMovingImageView with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); MenuItem item = menu.findItem(R.id.menu_share); ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "https://github.com/dexlex/DexMovingImageView"); sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Moving ImageView on GitHub"); sendIntent.setType("text/plain"); mShareActionProvider.setShareIntent(sendIntent); return true; }
Example 13
Source File: BookDetailFragment.java From barterli_android with Apache License 2.0 | 5 votes |
@Override public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) { if (mOwnedByUser) { inflater.inflate(R.menu.menu_logged_in_book_detail, menu); } else { inflater.inflate(R.menu.menu_book_detail, menu); } final MenuItem menuItem = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem); updateShareIntent(mBookTitle); }
Example 14
Source File: MsgParseActivity.java From smartcard-reader with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_msg_parse, menu); MenuItem item = menu.findItem(R.id.menu_share_msgs); ShareActionProvider sp = (ShareActionProvider) MenuItemCompat.getActionProvider(item); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(mHtml)); String subject = getString(R.string.app_name) + ": " + mActivityName + ": " + mMsgName; sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject); sendIntent.setType("text/html"); sp.setShareIntent(sendIntent); return true; }
Example 15
Source File: CatViewerActivity.java From android-aop-analytics with Apache License 2.0 | 5 votes |
private void initShareActionProvider(Menu menu) { MenuItem shareMenuItem = menu.findItem(R.id.action_share); ShareActionProvider actionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareMenuItem); Intent shareIntent = new Intent(Intent.ACTION_VIEW); shareIntent.setType(catImage.getType()); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(catImage.getLink())); actionProvider.setShareIntent(shareIntent); actionProvider.setOnShareTargetSelectedListener((source, intent) -> { trackSharingAction(analyticsTrackerHelper, AnalyticsTags.CATEGORY_ACTION, AnalyticsTags.ACTION_SHARE); return true; }); }
Example 16
Source File: WebActivity.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_web, menu); MenuItem item = menu.findItem(R.id.action_more); MoreActionWebProvider provider = (MoreActionWebProvider) MenuItemCompat.getActionProvider(item); provider.setActivity(this); return super.onCreateOptionsMenu(menu); }
Example 17
Source File: ThreadDetailActivity.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_thread_detail, menu); MenuItem item = menu.findItem(R.id.action_more); MoreActionProvider provider = (MoreActionProvider) MenuItemCompat.getActionProvider(item); provider.setCallback(this, this); return true; }
Example 18
Source File: MainActivity.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu( Menu menu ) { super.onCreateOptionsMenu( menu ); getMenuInflater().inflate( R.menu.main, menu ); MenuItem mediaRouteMenuItem = menu.findItem( R.id.media_route_menu_item ); MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider( mediaRouteMenuItem ); mediaRouteActionProvider.setRouteSelector( mMediaRouteSelector ); return true; }
Example 19
Source File: CatalogFragment.java From Ouroboros with GNU General Public License v3.0 | 4 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){ inflater.inflate(R.menu.menu_catalog, menu); MenuItem replyButton = menu.findItem(R.id.action_reply); MenuItem openExternalButton = menu.findItem(R.id.action_external_browser); MenuItem menuLayout = menu.findItem(R.id.action_menu_layout); MenuItem shareButton = menu.findItem(R.id.menu_item_share); MenuItem sortBy = menu.findItem(R.id.action_sort_by); replyButton.setVisible(true); openExternalButton.setVisible(true); menuLayout.setVisible(true); sortBy.setVisible(true); shareButton.setVisible(true); shareActionProvider = MenuItemCompat.getActionProvider(shareButton); MenuItem searchButton = menu.findItem(R.id.action_search); searchButton.setVisible(true); SearchView searchView = (SearchView) searchButton.getActionView(); searchView.setIconifiedByDefault(false); searchView.setSubmitButtonEnabled(false); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { Log.d(LOG_TAG, "query=" + newText); catalogAdapter.setFilterQueryProvider(new FilterQueryProvider() { @Override public Cursor runQuery(CharSequence constraint) { return infiniteDbHelper.searchCatalogForThread(constraint.toString(), SettingsHelper.getSortByMethod(getContext())); } }); catalogAdapter.getFilter().filter(newText); return true; } }); }
Example 20
Source File: MainActivity.java From Liapp with Apache License 2.0 | 3 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); MenuItem shareItem = menu.findItem(R.id.menu_item_share); myShareActionProvider = (ShareActionProvider)MenuItemCompat.getActionProvider(shareItem); return true; }