List of usage examples for android.view MenuItem getTitle
public CharSequence getTitle();
From source file:io.github.marktony.espresso.mvp.packages.PackagesFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { if (item == null || selectedPackageNumber == null) { return false; }//from w ww.j a v a 2 s . co m switch (item.getItemId()) { case R.id.action_set_readable: presenter.setPackageReadable(getSelectedPackageNumber(), !item.getTitle().equals(getString(R.string.set_read))); adapter.notifyDataSetChanged(); break; case R.id.action_copy_code: copyPackageNumber(); break; case R.id.action_share: presenter.setShareData(getSelectedPackageNumber()); break; default: break; } return true; }
From source file:org.bienvenidoainternet.app.MainActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override//from w w w . j a v a 2s.c o m public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); int id = item.getItemId(); toolbar.setSubtitle(item.getTitle()); if (id == R.id.nav_recent_post) { toolbar.setTitle("Post recientes"); toolbar.setSubtitle(""); pager.setCurrentItem(0); mainFragment.loadRecentPost(); } for (Board b : boardList) { if (b.getBoardName() == item.getTitle()) { System.out.println("Updating mainfragment to " + b.getBoardName() + " d: " + b.getBoardDir()); mainFragment.setCatalogMode(); mainFragment.updateBoardItems(b, null); pager.setCurrentItem(0); navigationView.getMenu().findItem(R.id.nav_recent_post).setChecked(false); } } return true; }
From source file:com.meinv.ui.activity.HomeActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mActionBarDrawerToggle != null && mActionBarDrawerToggle.onOptionsItemSelected(item)) { return true; }/*from w w w.j a v a 2 s .c om*/ Bundle extras = new Bundle(); extras.putString(BaseWebActivity.BUNDLE_KEY_TITLE, item.getTitle().toString()); extras.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, true); switch (item.getItemId()) { case R.id.action_capture: // readyGo(CaptureActivity.class); // if (ApiConstants.runing()) readyGo(MainActivity.class); break; case R.id.action_about_us: // readyGo(AboutUsActivity.class); extras.putString(BaseWebActivity.BUNDLE_KEY_URL, "http://jiyutang.kuaizhan.com/50/36/p40674244876b91"); readyGo(BaseWebActivity.class, extras); break; case R.id.action_feedback: // FeedbackAPI.openFeedbackActivity(); // Bundle extras = new Bundle(); // extras.putString(FeedbackFragment.BUNDLE_KEY_CONVERSATION_ID, mFeedbackAgent.getDefaultConversation().getId()); // readyGo(FeedBackActivity.class, extras); // FeedbackAgent agent = new FeedbackAgent(this); // agent.startFeedbackActivity(); extras.putString(BaseWebActivity.BUNDLE_KEY_URL, "http://jiyutang.kuaizhan.com/clubv2/forums/WJ8DG03NskvEQmEH"); readyGo(BaseWebActivity.class, extras); break; } return super.onOptionsItemSelected(item); }
From source file:com.ugedal.weeklyschedule.MainActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override//from w ww. j a v a2 s . c o m public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); int group_id = item.getGroupId(); if (group_id == R.id.trinn_chooser) { // Save new state, and update the fragment SharedPreferences sharedPref = getPreferences(Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt(getString(R.string.current_grade_key), id); editor.apply(); TextView text = (TextView) findViewById(R.id.textView); text.setText(item.getTitle()); getSupportActionBar().setTitle(item.getTitle()); mListFragment.myList.clear(); mListFragment.adapter.notifyDataSetChanged(); swipeContainer.setRefreshing(true); mListFragment.refreshContent(); } if (id == R.id.nav_about) { AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle(getString(R.string.about)); final SpannableString s = new SpannableString(getText(R.string.about_message)); Linkify.addLinks(s, Linkify.WEB_URLS); alertDialog.setMessage(s); alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alertDialog.show(); } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:com.abhijitvalluri.android.fitnotifications.HomeActivity.java
private void selectDrawerItem(MenuItem menuItem) { // Create a new fragment and specify the fragment to show based on nav item clicked final Fragment frag; Fragment currFrag = getSupportFragmentManager().findFragmentById(R.id.flContent); boolean isInfoFragment = false; if (currFrag instanceof InfoFragment) { isInfoFragment = true;/*from w w w .j a v a 2s. c om*/ } setTitle(menuItem.getTitle()); switch (menuItem.getItemId()) { case R.id.nav_home: setTitle(R.string.app_name); frag = new HomeFragment(); break; case R.id.nav_about_app: if (isInfoFragment) { ((InfoFragment) currFrag).updateWebViewContent(getString(R.string.about_app_text)); frag = null; } else { frag = InfoFragment.newInstance(getString(R.string.about_app_text)); } break; case R.id.nav_whats_new: if (isInfoFragment) { ((InfoFragment) currFrag).updateWebViewContent(getString(R.string.whats_new_text)); frag = null; } else { frag = InfoFragment.newInstance(getString(R.string.whats_new_text)); } break; case R.id.nav_faqs: if (isInfoFragment) { ((InfoFragment) currFrag).updateWebViewContent(getString(R.string.faqs_text)); frag = null; } else { frag = InfoFragment.newInstance(getString(R.string.faqs_text)); } break; case R.id.nav_manual_setup: if (isInfoFragment) { ((InfoFragment) currFrag).updateWebViewContent(getString(R.string.instructions_text)); frag = null; } else { frag = InfoFragment.newInstance(getString(R.string.instructions_text)); } break; case R.id.nav_opensource: if (isInfoFragment) { ((InfoFragment) currFrag).updateWebViewContent(getString(R.string.opensource_text)); frag = null; } else { frag = InfoFragment.newInstance(getString(R.string.opensource_text)); } break; case R.id.nav_contact: setTitle(menuItem.getTitle()); if (isInfoFragment) { ((InfoFragment) currFrag).updateWebViewContent(getString(R.string.contact_us_text)); frag = null; } else { frag = InfoFragment.newInstance(getString(R.string.contact_us_text)); } break; default: // something unexpected has happened Log it may be? return; } // Highlight the selected item has been done by NavigationView menuItem.setChecked(true); // Set action bar title if (frag != null) { mDrawerToggle.runWhenIdle(new Runnable() { @Override public void run() { // Insert the fragment by replacing any existing fragment FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.flContent, frag).commit(); } }); } // Close the navigation drawer mDrawerLayout.closeDrawers(); }
From source file:com.amaze.filemanager.ui.views.drawer.Drawer.java
public void onNavigationItemActionClick(MenuItem item) { String title = item.getTitle().toString(); MenuMetadata meta = dataUtils.getDrawerMetadata(item); String path = meta.path;/* ww w . j ava 2s . c om*/ switch (item.getGroupId()) { case STORAGES_GROUP: if (!path.equals("/")) { GeneralDialogCreation.showPropertiesDialogForStorage( RootHelper.generateBaseFile(new File(path), true), mainActivity, mainActivity.getAppTheme()); } break; // not to remove the first bookmark (storage) and permanent bookmarks case SERVERS_GROUP: case CLOUDS_GROUP: case FOLDERS_GROUP: if (dataUtils.containsBooks(new String[] { title, path }) != -1) { mainActivity.renameBookmark(title, path); } else if (path.startsWith("smb:/")) { mainActivity.showSMBDialog(title, path, true); } else if (path.startsWith("ssh:/")) { mainActivity.showSftpDialog(title, path, true); } else if (path.startsWith(CloudHandler.CLOUD_PREFIX_DROPBOX)) { GeneralDialogCreation.showCloudDialog(mainActivity, mainActivity.getAppTheme(), OpenMode.DROPBOX); } else if (path.startsWith(CloudHandler.CLOUD_PREFIX_GOOGLE_DRIVE)) { GeneralDialogCreation.showCloudDialog(mainActivity, mainActivity.getAppTheme(), OpenMode.GDRIVE); } else if (path.startsWith(CloudHandler.CLOUD_PREFIX_BOX)) { GeneralDialogCreation.showCloudDialog(mainActivity, mainActivity.getAppTheme(), OpenMode.BOX); } else if (path.startsWith(CloudHandler.CLOUD_PREFIX_ONE_DRIVE)) { GeneralDialogCreation.showCloudDialog(mainActivity, mainActivity.getAppTheme(), OpenMode.ONEDRIVE); } } }
From source file:com.github.rubensousa.bottomsheetbuilder.adapter.BottomSheetAdapterBuilder.java
private List<BottomSheetItem> createAdapterItems(int dividerBackground, int titleTextColor, int itemTextColor, int itemBackground, int tintColor) { List<BottomSheetItem> items = new ArrayList<>(); boolean addedSubMenu = false; for (int i = 0; i < mMenu.size(); i++) { MenuItem item = mMenu.getItem(i); if (item.isVisible()) { if (item.hasSubMenu()) { SubMenu subMenu = item.getSubMenu(); if (i != 0 && addedSubMenu) { if (mMode == BottomSheetBuilder.MODE_GRID) { throw new IllegalArgumentException( "MODE_GRID can't have submenus." + " Use MODE_LIST instead"); }/* ww w . j a va 2 s. c om*/ items.add(new BottomSheetDivider(dividerBackground)); } CharSequence title = item.getTitle(); if (title != null && !title.equals("")) { items.add(new BottomSheetHeader(title.toString(), titleTextColor)); } for (int j = 0; j < subMenu.size(); j++) { MenuItem subItem = subMenu.getItem(j); if (subItem.isVisible()) { items.add(new BottomSheetMenuItem(subItem, itemTextColor, itemBackground, tintColor)); addedSubMenu = true; } } } else { items.add(new BottomSheetMenuItem(item, itemTextColor, itemBackground, tintColor)); } } } return items; }
From source file:com.irateam.vkplayer.activities.ListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list); emptyView = findViewById(R.id.empty_list_view); emptyView.setVisibility(View.GONE); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w ww . ja v a2 s . c om getSupportActionBar().setDisplayHomeAsUpEnabled(true); toolbar.setNavigationOnClickListener(v -> drawerLayout.openDrawer(GravityCompat.START)); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); navigationView = (NavigationView) findViewById(R.id.navigation_view); navigationView.setNavigationItemSelectedListener(this); roundImageView = (RoundImageView) findViewById(R.id.navigation_drawer_header_avatar); userFullName = (TextView) findViewById(R.id.navigation_drawer_header_full_name); userVkId = (TextView) findViewById(R.id.navigation_drawer_header_id); new UserService(this).getCurrentUser((user) -> { ImageLoader.getInstance().displayImage(user.photo_100, roundImageView); userFullName.setText(user.first_name + " " + user.last_name); userVkId.setText(UserService.USER_LINK + String.valueOf(user.id)); }); ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawerLayout.setDrawerListener(drawerToggle); drawerToggle.syncState(); coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout); playerController = new PlayerController(this, findViewById(R.id.player_panel)); playerController.rootView.setVisibility(View.GONE); playerController.setFabOnClickListener(v -> startActivity(new Intent(this, AudioActivity.class))); refreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout); refreshLayout.setColorSchemeResources(R.color.accent, R.color.primary); refreshLayout.setOnRefreshListener(() -> { if (actionMode != null) actionMode.finish(); if (audioAdapter.isSortMode()) audioAdapter.setSortMode(false); audioService.repeatLastRequest(); }); listView = (DragSortListView) findViewById(R.id.list); listView.setAdapter(audioAdapter); listView.setOnItemClickListener((parent, view, position, id) -> { List<Audio> list = audioAdapter.getListByPosition(position); playerService.setPlaylist(list); playerService.play(audioAdapter.getPosition(position)); if (actionMode != null) actionMode.finish(); MenuItem item = navigationView.getMenu().getItem(0); boolean isFromSearch = audioAdapter.belongsToSearchList(position); if (!isFromSearch) { item.setChecked(true); getSupportActionBar().setTitle(item.getTitle()); } if (!isFromSearch || item.isChecked()) { audioAdapter.setOriginalList(list); } }); listView.setOnItemLongClickListener((parent, view, position, id) -> { performCheck(position); return true; }); listView.setDropListener(audioAdapter::drop); audioAdapter.setCoverCheckListener(this::performCheck); audioService.addListener(this); downloadFinishedReceiver = new DownloadFinishedReceiver() { @Override public void onDownloadFinished(Audio audio) { audioAdapter.updateAudioById(audio); } }; registerReceiver(downloadFinishedReceiver, new IntentFilter(DownloadService.DOWNLOAD_FINISHED)); startService(new Intent(this, PlayerService.class)); bindService(new Intent(this, PlayerService.class), this, BIND_AUTO_CREATE); }
From source file:org.chromium.latency.walt.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. Log.i(TAG, "Toolbar button: " + item.getTitle()); switch (item.getItemId()) { case R.id.action_help: return true; case R.id.action_share: attemptSaveAndShareLog();// w ww . j av a2 s . co m return true; case R.id.action_upload: showUploadLogDialog(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:edu.codemonkey.zendroid.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Pass the event to ActionBarDrawerToggle, if it returns // true, then it has handled the app icon touch event if (mDrawerToggle.onOptionsItemSelected(item)) { return true; }//from w w w .j a v a 2 s .c o m if (item.getTitle().equals("save")) { CurrentSelections.getInstance().getCurrentScanObject().saveScan(); arrayAdapter.clear(); arrayAdapter.addAll(LocalDBHandler.getInstance().scanList); arrayAdapter.notifyDataSetChanged(); } else if (item.getTitle().equals("share")) { AlertDialog.Builder illegalStateBuilder = new AlertDialog.Builder(MainActivity.this); illegalStateBuilder.setMessage("Send Mail"); illegalStateBuilder.setPositiveButton("Yes", sendMailListener).setNegativeButton("No", sendMailListener); illegalStateBuilder.show(); } // Handle your other action bar items... return super.onOptionsItemSelected(item); }