List of usage examples for android.view MenuItem isChecked
public boolean isChecked();
From source file:com.android.contacts.activities.ContactDetailActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { final MenuItem starredMenuItem = menu.findItem(R.id.menu_star); /*//from ww w.j a va 2 s . c o m * Bug Fix by Mediatek Begin. * Original Android's code: starredMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { // Toggle "starred" state // Make sure there is a contact if (mLookupUri != null) { // Read the current starred value from the UI instead of using the last // loaded state. This allows rapid tapping without writing the same // value several times final boolean isStarred = starredMenuItem.isChecked(); // To improve responsiveness, swap out the picture (and tag) in the UI already ContactDetailDisplayUtils.configureStarredMenuItem(starredMenuItem, mContactData.isDirectoryEntry(), mContactData.isUserProfile(), !isStarred); // Now perform the real save Intent intent = ContactSaveService.createSetStarredIntent( ContactDetailActivity.this, mLookupUri, !isStarred); ContactDetailActivity.this.startService(intent); } return true; } }); // If there is contact data, update the starred state if (mContactData != null) { ContactDetailDisplayUtils.configureStarredMenuItem(starredMenuItem, mContactData.isDirectoryEntry(), mContactData.isUserProfile(), mContactData.getStarred()); } * CR ID: ALPS00115684 */ if (this.mContactData != null && this.mContactData.getIndicate() < 0) { starredMenuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { // Toggle "starred" state // Make sure there is a contact if (mLookupUri != null) { // Read the current starred value from the UI instead of using the last // loaded state. This allows rapid tapping without writing the same // value several times final boolean isStarred = starredMenuItem.isChecked(); // To improve responsiveness, swap out the picture (and tag) in the UI already ContactDetailDisplayUtils.configureStarredMenuItem(starredMenuItem, mContactData.isDirectoryEntry(), mContactData.isUserProfile(), !isStarred); // Now perform the real save Intent intent = ContactSaveService.createSetStarredIntent(ContactDetailActivity.this, mLookupUri, !isStarred); ContactDetailActivity.this.startService(intent); } return true; } }); ContactDetailDisplayUtils.configureStarredMenuItem(starredMenuItem, mContactData.isDirectoryEntry(), mContactData.isUserProfile(), mContactData.getStarred()); } else { Log.i(TAG, "it is sim contact"); starredMenuItem.setVisible(false); } /* * Bug Fix by Mediatek End. */ /* * New Feature by Mediatek Begin. set this if show new association menu */ setAssociationMenu(menu, true); /* * New Feature by Mediatek End. */ return true; }
From source file:com.github.michalbednarski.intentslab.editor.IntentEditorActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.menu_run_intent: runIntent();//from w w w. j a v a 2s.c o m return true; case R.id.set_editor_result: updateIntent(); setResult(0, new Intent().putExtra(Editor.EXTRA_VALUE, mEditedIntent)); finish(); return true; case R.id.attach_intent_filter: { // We have specified component, just find IntentFilters for it final ComponentName componentName = mEditedIntent.getComponent(); ExtendedPackageInfo.getExtendedPackageInfo(this, componentName.getPackageName(), new ExtendedPackageInfo.Callback() { @Override public void onPackageInfoAvailable(ExtendedPackageInfo extendedPackageInfo) { try { setAttachedIntentFilters(extendedPackageInfo .getComponentInfo(componentName.getClassName()).intentFilters); Toast.makeText(IntentEditorActivity.this, R.string.intent_filter_attached, Toast.LENGTH_SHORT).show(); } catch (NullPointerException e) { Toast.makeText(IntentEditorActivity.this, R.string.no_intent_filters_found, Toast.LENGTH_SHORT).show(); } } }); } return true; case R.id.detach_intent_filter: clearAttachedIntentFilters(); return true; case R.id.component_info: { ComponentName component = mEditedIntent.getComponent(); startActivity(new Intent(this, SingleFragmentActivity.class) .putExtra(SingleFragmentActivity.EXTRA_FRAGMENT, ComponentInfoFragment.class.getName()) .putExtra(ComponentInfoFragment.ARG_PACKAGE_NAME, component.getPackageName()) .putExtra(ComponentInfoFragment.ARG_COMPONENT_NAME, component.getClassName()) .putExtra(ComponentInfoFragment.ARG_LAUNCHED_FROM_INTENT_EDITOR, true)); } return true; case R.id.save: { updateIntent(); SavedItemsDatabase.getInstance(this).saveIntent(this, mEditedIntent, mComponentType, mMethodId); } return true; case R.id.track_intent: { if (!item.isChecked()) { XIntentsLab xIntentsLab = XIntentsLabStatic.getInstance(); if (xIntentsLab.havePermission()) { createIntentTracker(); } else { try { startIntentSenderForResult( xIntentsLab.getRequestPermissionIntent(getPackageName()).getIntentSender(), REQUEST_CODE_REQUEST_INTENT_TRACKER_PERMISSION, null, 0, 0, 0); } catch (IntentSender.SendIntentException e) { e.printStackTrace(); // TODO: can we handle this? } } } else { removeIntentTracker(); } return true; } case R.id.disable_interception: getPackageManager().setComponentEnabledSetting( new ComponentName(this, IntentEditorInterceptedActivity.class), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); Toast.makeText(this, R.string.interception_disabled, Toast.LENGTH_SHORT).show(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.almarsoft.GroundhogReader.MessageListActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.messagelist_menu_newpost: String name = mPrefs.getString("name", null); String email = mPrefs.getString("email", null); if (name == null || name.trim().length() == 0 || email == null || email.trim().length() == 0) { new AlertDialog.Builder(this).setTitle(getString(R.string.user_info_unset)) .setMessage(getString(R.string.must_fill_name_email_goto_settings)) .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sumthin) { startActivity(new Intent(MessageListActivity.this, OptionsActivity.class)); }//from ww w . jav a 2 s. c o m }).setNegativeButton(getString(R.string.no), null).show(); } else { Intent intent_Compose = new Intent(MessageListActivity.this, ComposeActivity.class); intent_Compose.putExtra("isNew", true); intent_Compose.putExtra("group", mGroup); startActivityForResult(intent_Compose, UsenetConstants.COMPOSEMESSAGEINTENT); } return true; case R.id.messagelist_menu_getnew: getNewMessagesFromServer(false); return true; case R.id.messagelist_menu_get_latest: getNewMessagesFromServer(true); return true; case R.id.messagelist_menu_refresh: threadMessagesFromDB(); return true; case R.id.messagelist_menu_markread: markAllRead(); return true; case R.id.messagelist_menu_charset: startActivity(new Intent(MessageListActivity.this, ReadCharsetActivity.class)); return true; case R.id.messagelist_menu_settings: startActivity(new Intent(MessageListActivity.this, OptionsActivity.class)); return true; case R.id.messagelist_menu_showread: Editor editor = mPrefs.edit(); item.setChecked(!item.isChecked()); editor.putBoolean("showRead", item.isChecked()); editor.commit(); threadMessagesFromDB(); return true; case R.id.messagelist_menu_managebanneds: Intent intent_bannedthreads = new Intent(MessageListActivity.this, BannedActivity.class); intent_bannedthreads.putExtra("typeban", UsenetConstants.BANNEDTHREADS); intent_bannedthreads.putExtra("group", mGroup); startActivityForResult(intent_bannedthreads, UsenetConstants.BANNEDACTIVITYINTENT); return true; case R.id.messagelist_menu_managebannedusers: Intent intent_bannedusers = new Intent(MessageListActivity.this, BannedActivity.class); intent_bannedusers.putExtra("typeban", UsenetConstants.BANNEDTROLLS); intent_bannedusers.putExtra("group", mGroup); startActivityForResult(intent_bannedusers, UsenetConstants.BANNEDACTIVITYINTENT); return true; case R.id.messagelist_menu_catchup: catchupGroup(); return true; } return false; }
From source file:at.ac.uniklu.mobile.sportal.CourseListFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { if (DEBUG)// ww w. j a v a 2 s.co m Log.d(TAG, "onContextItemSelected " + getTag()); /* WORKAROUND * The onContextItemSelected event is received by all "visible" fragments, in this * case it is the currently displayed fragment in the ViewPager, and fragments beside * this displayed fragment that are preloaded and thus "visible" but not really visible * since they are outside the screen. * Anyway, since this event is received by all "visible" fragments, I need to make sure * that only the event handler of the currently displayed fragment gets executed. */ if (((FragmentPagerSupport) getActivity()).getCurrentItemIndex() != mIndex) { return false; } Lehrveranstaltung course = mCourseModel.getCourse(((AdapterContextMenuInfo) item.getMenuInfo()).position); switch (item.getItemId()) { case R.id.details: Analytics.onEvent(Analytics.EVENT_WEB_COURSEDETAILS); Intent courseDetails = new Intent(getActivity(), WebViewActivity.class) .putExtra(WebViewActivity.URL, course.getDetailsUrl()) .putExtra(WebViewActivity.TITLE, getString(R.string.course_details_title)); startActivity(courseDetails); return true; case R.id.participants: Analytics.onEvent(Analytics.EVENT_COURSE_PARTICIPANTS, "rlvkey", course.getKey() + ""); Intent participants = new Intent(getActivity(), CourseParticipantsListActivity.class) .putExtra(CourseListActivity.COURSE_KEY, course.getKey()) .putExtra(CourseListActivity.COURSE_NAME, course.getTyp() + " " + course.getName()); startActivity(participants); return true; case R.id.website: Analytics.onEvent(Analytics.EVENT_WEB_COURSEWEBSITE); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(course.getWebsiteUrl()))); return true; case R.id.moodle: Analytics.onEvent(Analytics.EVENT_WEB_COURSEMOODLE); Intent moodle = new Intent(getActivity(), WebViewActivity.class) .putExtra(WebViewActivity.URL, course.getMoodleUrl()) .putExtra(WebViewActivity.TITLE, getString(R.string.moodle)) .putExtra(WebViewActivity.MOODLE_HACK, true).putExtra(WebViewActivity.SSO, true); startActivity(moodle); return true; case R.id.checklists: Analytics.onEvent(Analytics.EVENT_COURSE_CHECKLISTS, "rlvkey", course.getKey() + ""); Intent checklists = new Intent(getActivity(), CourseChecklistsActivity.class) .putExtra(CourseListActivity.COURSE_KEY, course.getKey()) .putExtra(CourseListActivity.COURSE_NAME, course.getTyp() + " " + course.getName()); startActivity(checklists); return true; case R.id.ignore: Analytics.onEvent(Analytics.EVENT_IGNORE_COURSE); if (item.isChecked()) { mDB.courseBlacklist_insert(course.getKey()); } else { mDB.courseBlacklist_delete(course.getKey()); } if (DEBUG) Log.d(TAG, "notifyDataSetChanged " + getTag()); mCourseListAdapter.notifyDataSetChanged(); mListener.onBlacklistChanged(); return true; } return super.onContextItemSelected(item); }
From source file:org.mozilla.gecko.GeckoApp.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Tab tab = null;//ww w. j a v a2 s .c o m Intent intent = null; switch (item.getItemId()) { case R.id.quit: synchronized (sLaunchState) { if (sLaunchState == LaunchState.GeckoRunning) GeckoAppShell.notifyGeckoOfEvent(GeckoEvent.createBroadcastEvent("Browser:Quit", null)); else System.exit(0); sLaunchState = LaunchState.GeckoExiting; } return true; case R.id.bookmark: tab = Tabs.getInstance().getSelectedTab(); if (tab != null) { if (item.isChecked()) { tab.removeBookmark(); Toast.makeText(this, R.string.bookmark_removed, Toast.LENGTH_SHORT).show(); item.setIcon(R.drawable.ic_menu_bookmark_add); } else { tab.addBookmark(); Toast.makeText(this, R.string.bookmark_added, Toast.LENGTH_SHORT).show(); item.setIcon(R.drawable.ic_menu_bookmark_remove); } } return true; case R.id.share: tab = Tabs.getInstance().getSelectedTab(); if (tab != null) { GeckoAppShell.openUriExternal(tab.getURL(), "text/plain", "", "", Intent.ACTION_SEND, tab.getTitle()); } return true; case R.id.reload: doReload(); return true; case R.id.forward: doForward(); return true; case R.id.save_as_pdf: GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SaveAs:PDF", null)); return true; case R.id.settings: intent = new Intent(this, GeckoPreferences.class); startActivity(intent); return true; case R.id.site_settings: GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Permissions:Get", null)); return true; case R.id.addons: loadUrlInTab("about:addons"); return true; case R.id.downloads: intent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS); startActivity(intent); return true; case R.id.char_encoding: GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("CharEncoding:Get", null)); return true; default: return super.onOptionsItemSelected(item); } }
From source file:org.de.jmg.learn.MainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. try {// ww w .j av a2 s. c o m getMenuInflater().inflate(R.menu.main, menu); //findViewById(R.menu.main).setBackgroundColor(Color.BLACK); //.setBackgroundColor(Color.BLACK); //resize(); OptionsMenu = menu; if (OptionsMenu != null) { mnuAddNew = menu.findItem(R.id.mnuAddWord); mnuUploadToQuizlet = menu.findItem(R.id.mnuUploadToQuizlet); Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); int height = metrics.heightPixels; int viewTop = this.findViewById(Window.ID_ANDROID_CONTENT).getTop(); height = height - viewTop; double scale = (double) height / (double) 950; if (scale < .5f) { isSmallDevice = true; } if (Build.VERSION.SDK_INT < 11) { menu.findItem(R.id.mnuOpenQuizlet).setVisible(false); menu.findItem(R.id.mnuUploadToQuizlet).setVisible(false); } /* if (isSmallDevice) { MenuItemCompat.setShowAsAction(menu.findItem(R.id.mnuSaveAs), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); } */ MenuItem mnuQuizlet = menu.findItem(R.id.mnuLoginQuizlet); mnuQuizlet.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { //throw new RuntimeException("Test"); return false; } }); if (BuildConfig.DEBUG) { mnuQuizlet.setVisible(true); } else { mnuQuizlet.setVisible(false); } MenuItem mnuAskReverse = OptionsMenu.findItem(R.id.mnuAskReverse); mnuAskReverse.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { item.setChecked(!item.isChecked()); vok.reverse = item.isChecked(); setMnuReverse(); return true; } }); setMnuReverse(); /* if (isSmallDevice) { MenuItem m = menu.findItem(R.id.mnuHome); MenuItemCompat.setShowAsAction(m,MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); m = menu.findItem(R.id.mnuFileOpen); MenuItemCompat.setShowAsAction(m,MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); m = menu.findItem(R.id.mnuSaveAs); MenuItemCompat.setShowAsAction(m,MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); m = menu.findItem(R.id.mnuAddWord); MenuItemCompat.setShowAsAction(m,MenuItemCompat.SHOW_AS_ACTION_IF_ROOM); //lib.ShowToast(this,"Menus set to IF_ROOM!"); } */ mainView.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // Ensure you call it only once : lib.removeLayoutListener(mainView.getViewTreeObserver(), this); //MainActivity.this.SetShowAsAction(mnuUploadToQuizlet); } }); return true; } throw new RuntimeException("menu is null!"); } catch (Exception ex) { lib.ShowException(this, ex); } return false; }
From source file:org.gdgsp.fragment.PeopleFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_random: // Se o tamanho da lista for maior que 0 significa que j carregou if (selectedList.size() > 0) { // Aqui vai gerar um nmero aleatrio entre 0 e o tamanho da lista - 1 Random random = new Random(); int number = random.nextInt(selectedList.size()); // Aps isso o aplicativo vai dar scroll e exibir a pessoa na posio do nmero aleatrio ((LinearLayoutManager) list.getLayoutManager()).scrollToPositionWithOffset(number, 0); if (person != null && selectedList.get(number).getId() == person.getId()) { count = 0;/*from w w w . j a v a2 s .com*/ // Verifica o tanto de tempo que a pessoa ficou com o alerta aberto, se demorar muito vai ter coisa errada, como mudar a hora do sistema e aguardar o sorteio final Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { count++; } }, 1000, 1000); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss dd/MM/yyyy"); String localDate = sdf.format(new Date()); SimpleDateFormat dbDateSDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); final String dbDate = dbDateSDF.format(new Date()); AlertDialog alertDialog = new AlertDialog.Builder(activity) .setTitle(getString(R.string.raffle_person)) .setMessage("Voc!\n\nSorteado s " + localDate) .setPositiveButton(getString(R.string.send), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface p1, int p2) { timer.cancel(); sendRaffle(dbDate); } }).setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface p1, int p2) { timer.cancel(); } }) .create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } else { AlertDialog alertDialog = new AlertDialog.Builder(activity) .setTitle(getString(R.string.raffle_person)) .setMessage(selectedList.get(number).getName()).setPositiveButton("OK", null).create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } } return true; case R.id.menu_hasapp: // Exibir apenas pessoas que usam o aplicativo, essa informao vem de um banco de dados no back-end item.setChecked(!item.isChecked()); selectedList.clear(); selectedList.addAll(item.isChecked() ? hasAppPeople : listPeople); adapter.notifyDataSetChanged(); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.grarak.kerneladiutor.fragments.tools.ProfileFragment.java
private void load(List<RecyclerViewItem> items) { mProfiles = new Profiles(getActivity()); List<Profiles.ProfileItem> profileItems = mProfiles.getAllProfiles(); if (mTaskerMode && profileItems.size() == 0) { Snackbar.make(getRootView(), R.string.no_profiles, Snackbar.LENGTH_LONG).show(); return;//from ww w . j av a2s.c o m } for (int i = 0; i < profileItems.size(); i++) { final int position = i; final CardView cardView = new CardView(getActivity()); cardView.setOnMenuListener(new CardView.OnMenuListener() { @Override public void onMenuReady(final CardView cardView, PopupMenu popupMenu) { Menu menu = popupMenu.getMenu(); menu.add(Menu.NONE, 0, Menu.NONE, getString(R.string.append)); menu.add(Menu.NONE, 1, Menu.NONE, getString(R.string.edit)); menu.add(Menu.NONE, 2, Menu.NONE, getString(R.string.details)); final MenuItem onBoot = menu.add(Menu.NONE, 3, Menu.NONE, getString(R.string.on_boot)) .setCheckable(true); onBoot.setChecked(mProfiles.getAllProfiles().get(position).isOnBootEnabled()); menu.add(Menu.NONE, 4, Menu.NONE, getString(R.string.export)); menu.add(Menu.NONE, 5, Menu.NONE, getString(R.string.delete)); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { List<Profiles.ProfileItem> items = mProfiles.getAllProfiles(); switch (item.getItemId()) { case 0: if (Utils.DONATED) { Intent intent = new Intent(getActivity(), ProfileActivity.class); intent.putExtra(ProfileActivity.POSITION_INTENT, position); startActivityForResult(intent, 2); } else { mDonateDialog = ViewUtils.dialogDonate(getActivity()); mDonateDialog.show(); } break; case 1: if (Utils.DONATED) { Intent intent = new Intent(getActivity(), ProfileEditActivity.class); intent.putExtra(ProfileEditActivity.POSITION_INTENT, position); startActivityForResult(intent, 3); } else { mDonateDialog = ViewUtils.dialogDonate(getActivity()); mDonateDialog.show(); } break; case 2: if (items.get(position).getName() != null) { List<Profiles.ProfileItem.CommandItem> commands = items.get(position) .getCommands(); if (commands.size() > 0) { setForegroundText(items.get(position).getName().toUpperCase()); mDetailsFragment.setText(commands); showForeground(); } else { Utils.toast(R.string.profile_empty, getActivity()); } } break; case 3: onBoot.setChecked(!onBoot.isChecked()); items.get(position).enableOnBoot(onBoot.isChecked()); mProfiles.commit(); break; case 4: mExportProfile = items.get(position); requestPermission(0, Manifest.permission.WRITE_EXTERNAL_STORAGE); break; case 5: mDeleteDialog = ViewUtils.dialogBuilder(getString(R.string.sure_question), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { mProfiles.delete(position); mProfiles.commit(); reload(); } }, new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { mDeleteDialog = null; } }, getActivity()); mDeleteDialog.show(); break; } return false; } }); } }); final DescriptionView descriptionView = new DescriptionView(); descriptionView.setSummary(profileItems.get(i).getName()); descriptionView.setOnItemClickListener(new RecyclerViewItem.OnItemClickListener() { @Override public void onClick(RecyclerViewItem item) { if (mTaskerMode) { mSelectDialog = ViewUtils.dialogBuilder( getString(R.string.select_question, descriptionView.getSummary()), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { ((ProfileTaskerActivity) getActivity()).finish( descriptionView.getSummary().toString(), mProfiles.getAllProfiles().get(position).getCommands()); } }, new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { mSelectDialog = null; } }, getActivity()); mSelectDialog.show(); } else { mApplyDialog = ViewUtils.dialogBuilder( getString(R.string.apply_question, descriptionView.getSummary()), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { } }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { for (Profiles.ProfileItem.CommandItem command : mProfiles.getAllProfiles() .get(position).getCommands()) { CPUFreq.ApplyCpu applyCpu; if (command.getCommand().startsWith("#") && ((applyCpu = new CPUFreq.ApplyCpu( command.getCommand().substring(1))) .toString() != null)) { for (String applyCpuCommand : Service.getApplyCpu(applyCpu, RootUtils.getSU())) { Control.runSetting(applyCpuCommand, null, null, null); } } else { Control.runSetting(command.getCommand(), null, null, null); } } } }, new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialogInterface) { mApplyDialog = null; } }, getActivity()); try { mApplyDialog.show(); } catch (NullPointerException ignored) { } } } }); if (mTaskerMode) { items.add(descriptionView); } else { cardView.addItem(descriptionView); items.add(cardView); } } if (!mTaskerMode) { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(getActivity()); int appWidgetIds[] = appWidgetManager.getAppWidgetIds(new ComponentName(getActivity(), Widget.class)); appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.profile_list); Tile.publishProfileTile(profileItems, getActivity()); } }
From source file:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (drawerToggle.onOptionsItemSelected(item)) { return true; }//www . j a v a 2 s . co m if (page != null) { if (item.getItemId() == ListPage.OPTIONS_MENU_SEARCH) { setSearchMode(true); return true; } if (page.onOptionsItemSelected(item)) { return true; } switch (item.getItemId()) { case android.R.id.home: { if (setSearchMode(false)) { return true; } drawerLayout.closeDrawers(); PageHolder pageHolder = pageManager.getCurrentPage(); String newChanName = pageHolder.chanName; String newBoardName = pageHolder.boardName; if (pageHolder.content == PageHolder.Content.THREADS) { // Up button must navigate to main page in threads list newBoardName = Preferences.getDefaultBoardName(pageHolder.chanName); if (Preferences.isMergeChans() && StringUtils.equals(pageHolder.boardName, newBoardName)) { newChanName = ChanManager.getInstance().getDefaultChanName(); newBoardName = Preferences.getDefaultBoardName(newChanName); } } pageManager.clearStack(); boolean fromCache = pageManager.get(newChanName, newBoardName, null, PageHolder.Content.THREADS) != null; navigateIntentData(newChanName, newBoardName, null, null, null, null, fromCache ? NavigationUtils.FLAG_FROM_CACHE : 0); return true; } case ListPage.APPEARANCE_MENU_CHANGE_THEME: case ListPage.APPEARANCE_MENU_EXPANDED_SCREEN: case ListPage.APPEARANCE_MENU_SPOILERS: case ListPage.APPEARANCE_MENU_MY_POSTS: case ListPage.APPEARANCE_MENU_DRAWER: case ListPage.APPEARANCE_MENU_THREADS_GRID: case ListPage.APPEARANCE_MENU_SFW_MODE: { try { switch (item.getItemId()) { case ListPage.APPEARANCE_MENU_CHANGE_THEME: { showThemeDialog(); return true; } case ListPage.APPEARANCE_MENU_EXPANDED_SCREEN: { Preferences.setExpandedScreen(!item.isChecked()); recreate(); return true; } case ListPage.APPEARANCE_MENU_SPOILERS: { Preferences.setShowSpoilers(!item.isChecked()); return true; } case ListPage.APPEARANCE_MENU_MY_POSTS: { Preferences.setShowMyPosts(!item.isChecked()); return true; } case ListPage.APPEARANCE_MENU_DRAWER: { Preferences.setDrawerLocked(!item.isChecked()); updateWideConfiguration(false); return true; } case ListPage.APPEARANCE_MENU_THREADS_GRID: { Preferences.setThreadsGridMode(!item.isChecked()); return true; } case ListPage.APPEARANCE_MENU_SFW_MODE: { Preferences.setSfwMode(!item.isChecked()); return true; } } } finally { if (page != null) { page.onAppearanceOptionChanged(item.getItemId()); } } } } } return super.onOptionsItemSelected(item); }
From source file:org.mozilla.gecko.BrowserApp.java
private void updateAddonMenuItem(int id, JSONObject options) { // Set attribute for the menu item in cache, if available if (mAddonMenuItemsCache != null && !mAddonMenuItemsCache.isEmpty()) { for (MenuItemInfo item : mAddonMenuItemsCache) { if (item.id == id) { item.label = options.optString("name", item.label); item.checkable = options.optBoolean("checkable", item.checkable); item.checked = options.optBoolean("checked", item.checked); item.enabled = options.optBoolean("enabled", item.enabled); item.visible = options.optBoolean("visible", item.visible); item.added = (mMenu != null); break; }/*from w ww.j ava 2 s .c o m*/ } } if (mMenu == null) { return; } final MenuItem menuItem = mMenu.findItem(id); if (menuItem != null) { menuItem.setTitle(options.optString("name", menuItem.getTitle().toString())); menuItem.setCheckable(options.optBoolean("checkable", menuItem.isCheckable())); menuItem.setChecked(options.optBoolean("checked", menuItem.isChecked())); menuItem.setEnabled(options.optBoolean("enabled", menuItem.isEnabled())); menuItem.setVisible(options.optBoolean("visible", menuItem.isVisible())); } }