Java Code Examples for androidx.core.app.ActivityCompat#invalidateOptionsMenu()
The following examples show how to use
androidx.core.app.ActivityCompat#invalidateOptionsMenu() .
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: GlobalPrivilegeClaimingActivity.java From commcare-android with Apache License 2.0 | 6 votes |
private void refreshUI() { TextView enabledTextView = findViewById(R.id.enabled_textview); TextView notEnabledTextView = findViewById(R.id.not_enabled_textview); Button claimButton = findViewById(R.id.claim_button); TextView instructions = findViewById(R.id.instructions); if (GlobalPrivilegesManager.getEnabledPrivileges().size() > 0) { notEnabledTextView.setVisibility(View.GONE); claimButton.setVisibility(View.GONE); instructions.setVisibility(View.GONE); enabledTextView.setVisibility(View.VISIBLE); enabledTextView.setText(getEnabledText()); } else { enabledTextView.setVisibility(View.GONE); claimButton.setVisibility(View.VISIBLE); instructions.setVisibility(View.VISIBLE); notEnabledTextView.setVisibility(View.VISIBLE); } ActivityCompat.invalidateOptionsMenu(this); }
Example 2
Source File: ViewTaskFragment.java From opentasks with Apache License 2.0 | 6 votes |
private void persistTask() { Activity activity = getActivity(); if (mContentSet != null && activity != null) { if (mDetailView != null) { mDetailView.updateValues(); } if (mContentSet.isUpdate()) { mContentSet.persist(activity); ActivityCompat.invalidateOptionsMenu(activity); } } }
Example 3
Source File: BaseFragment.java From arcusandroid with Apache License 2.0 | 5 votes |
protected void setEmptyTitle() { Activity activity = getActivity(); if (activity == null) { return; } activity.setTitle(""); ActivityCompat.invalidateOptionsMenu(activity); }
Example 4
Source File: AppPermissionActivity.java From AppOpsX with MIT License | 5 votes |
@Override public void showProgress(boolean show) { tvError.setVisibility(View.GONE); mProgressBar.setVisibility(show ? View.VISIBLE : View.GONE); ActivityCompat.invalidateOptionsMenu(AppPermissionActivity.this); }
Example 5
Source File: AppPermissionActivity.java From AppOpsX with MIT License | 5 votes |
@Override public void showError(CharSequence text) { mProgressBar.setVisibility(View.GONE); tvError.setVisibility(View.VISIBLE); tvError.setText(text); ActivityCompat.invalidateOptionsMenu(AppPermissionActivity.this); }
Example 6
Source File: AppPermissionActivity.java From AppOpsX with MIT License | 5 votes |
@Override public void showPerms(List<OpEntryInfo> opEntryInfos) { final SharedPreferences sp = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); adapter.setShowConfig(sp.getBoolean("key_show_op_desc", false), sp.getBoolean("key_show_op_name", false), sp.getBoolean("key_show_perm_time", false)); adapter.setDatas(opEntryInfos); adapter.notifyDataSetChanged(); ActivityCompat.invalidateOptionsMenu(AppPermissionActivity.this); }
Example 7
Source File: AppPermissionActivity.java From AppOpsX with MIT License | 4 votes |
@Override public boolean onCreateOptionsMenu(final Menu menu) { if (!mPresenter.isLoadSuccess()) { return false; } getMenuInflater().inflate(R.menu.app_menu, menu); MenuItem menuShowAllPerm = menu.findItem(R.id.action_hide_perm); MenuItem menuShowOpDesc = menu.findItem(R.id.action_show_op_perm); MenuItem menuShowOpName = menu.findItem(R.id.action_show_op_name); MenuItem menuShowPremTime = menu.findItem(R.id.action_show_perm_time); final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); final Map<MenuItem, String> menus = new HashMap<>(); menus.put(menuShowAllPerm, "key_show_no_prems"); menus.put(menuShowOpDesc, "key_show_op_desc"); menus.put(menuShowOpName, "key_show_op_name"); menus.put(menuShowPremTime, "key_show_perm_time"); MenuItem.OnMenuItemClickListener itemClickListener = new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { String s = menus.get(item); if (s != null) { item.setChecked(!item.isChecked()); sp.edit().putBoolean(s, item.isChecked()).apply(); ActivityCompat.invalidateOptionsMenu(AppPermissionActivity.this); mPresenter.load(); } return true; } }; Set<Map.Entry<MenuItem, String>> entries = menus.entrySet(); for (Map.Entry<MenuItem, String> entry : entries) { entry.getKey().setChecked(sp.getBoolean(entry.getValue(), false)); entry.getKey().setOnMenuItemClickListener(itemClickListener); } return true; }
Example 8
Source File: ViewTaskFragment.java From opentasks with Apache License 2.0 | 4 votes |
/** * Load the task with the given {@link Uri} in the detail view. * <p> * At present only Task Uris are supported. * </p> * TODO: add support for instance Uris. * * @param uri * The {@link Uri} of the task to show. */ private void loadUri(Uri uri) { showFloatingActionButton(false); if (mTaskUri != null) { /* * Unregister the observer for any previously shown task first. */ mAppContext.getContentResolver().unregisterContentObserver(mObserver); persistTask(); } Uri oldUri = mTaskUri; mTaskUri = uri; if (uri != null) { /* * Create a new ContentSet and load the values for the given Uri. Also register listener and observer for changes in the ContentSet and the Uri. */ mContentSet = new ContentSet(uri); mContentSet.addOnChangeListener(this, null, true); mAppContext.getContentResolver().registerContentObserver(uri, false, mObserver); mContentSet.update(mAppContext, CONTENT_VALUE_MAPPER); } else { /* * Immediately update the view with the empty task uri, i.e. clear the view. */ mContentSet = null; if (mContent != null) { mContent.removeAllViews(); } } if ((oldUri == null) != (uri == null)) { /* * getActivity().invalidateOptionsMenu() doesn't work in Android 2.x so use the compat lib */ ActivityCompat.invalidateOptionsMenu(getActivity()); } mAppBar.setExpanded(true, false); }
Example 9
Source File: ViewTaskFragment.java From opentasks with Apache License 2.0 | 4 votes |
@SuppressLint("NewApi") @Override public void onContentLoaded(ContentSet contentSet) { if (contentSet.containsKey(Tasks.ACCOUNT_TYPE)) { mListColor = TaskFieldAdapters.LIST_COLOR.get(contentSet); ((Callback) getActivity()).onListColorLoaded(new ValueColor(mListColor)); updateColor(); Activity activity = getActivity(); int newStatus = TaskFieldAdapters.STATUS.get(contentSet); boolean newPinned = TaskFieldAdapters.PINNED.get(contentSet); if (activity != null && (hasNewStatus(newStatus) || pinChanged(newPinned))) { // new need to update the options menu, because the status of the task has changed ActivityCompat.invalidateOptionsMenu(activity); } mPinned = newPinned; mOldStatus = newStatus; if (mShowFloatingActionButton) { if (!TaskFieldAdapters.IS_CLOSED.get(contentSet)) { showFloatingActionButton(true); mFloatingActionButton.show(); } else { if (mFloatingActionButton.getVisibility() == View.VISIBLE) { mFloatingActionButton.hide(); } } } if (mModel == null || !TextUtils.equals(mModel.getAccountType(), contentSet.getAsString(Tasks.ACCOUNT_TYPE))) { Sources.loadModelAsync(mAppContext, contentSet.getAsString(Tasks.ACCOUNT_TYPE), this); } else { // the model didn't change, just update the view postUpdateView(); } } }