use of android.view.MenuItem in project V2HOT by djyde.
the class ContentActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.content_activity, menu);
MenuItem item = menu.findItem(R.id.menu_item_share);
ShareActionProvider shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
shareActionProvider.setShareIntent(getShareIntent());
return true;
}
use of android.view.MenuItem in project cw-omnibus by commonsguy.
the class MainActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_actions, menu);
rc = (ReverseChronometer) menu.findItem(R.id.countdown).getActionView();
rc.setWarningDuration(5 * 60);
rc.setOnClickListener(this);
rc.setOnLongClickListener(this);
rc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
rc.setTextColor(Color.WHITE);
if (durationInSeconds > 0) {
rc.setOverallDuration(durationInSeconds);
}
MenuItem item = menu.findItem(R.id.route_provider);
MediaRouteActionProvider provider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(item);
provider.setRouteSelector(selector);
return (super.onCreateOptionsMenu(menu));
}
use of android.view.MenuItem in project FlexibleAdapter by davideas.
the class MainActivity method onPrepareOptionsMenu.
/* ====================================
* OPTION MENU PREPARATION & MANAGEMENT
* ==================================== */
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
Log.v(TAG, "onPrepareOptionsMenu called!");
if (mSearchView != null) {
//Has searchText?
if (!mAdapter.hasSearchText()) {
Log.d(TAG, "onPrepareOptionsMenu Clearing SearchView!");
// This also clears the text in SearchView widget
mSearchView.setIconified(true);
} else {
//Necessary after the restoreInstanceState
//must be called first
menu.findItem(R.id.action_search).expandActionView();
//This restores the text, must be after the expandActionView()
//submit = false!!!
mSearchView.setQuery(mAdapter.getSearchText(), false);
//Optionally the keyboard can be closed
mSearchView.clearFocus();
//mSearchView.setIconified(false);//This is not necessary
}
}
// Fast Scroller
MenuItem fastScrollerItem = menu.findItem(R.id.action_fast_scroller);
if (fastScrollerItem != null) {
fastScrollerItem.setChecked(mAdapter.isFastScrollerEnabled());
}
// Animate on update?
MenuItem animateUpdateMenuItem = menu.findItem(R.id.action_animate_on_update);
if (animateUpdateMenuItem != null) {
animateUpdateMenuItem.setChecked(DatabaseConfiguration.animateOnUpdate);
}
// Headers are shown?
MenuItem headersMenuItem = menu.findItem(R.id.action_show_hide_headers);
if (headersMenuItem != null) {
headersMenuItem.setTitle(mAdapter.areHeadersShown() ? R.string.hide_headers : R.string.show_headers);
}
// Sticky Header item?
MenuItem stickyItem = menu.findItem(R.id.action_sticky_headers);
if (stickyItem != null) {
stickyItem.setEnabled(mAdapter.areHeadersShown());
stickyItem.setChecked(mAdapter.areHeadersSticky());
}
// Scrolling Animations?
MenuItem animationMenuItem = menu.findItem(R.id.action_animation);
if (animationMenuItem != null) {
animationMenuItem.setChecked(DatabaseConfiguration.animateOnScrolling);
}
// Reverse scrolling animation?
MenuItem reverseMenuItem = menu.findItem(R.id.action_reverse);
if (reverseMenuItem != null) {
reverseMenuItem.setEnabled(mAdapter.isAnimationOnScrollingEnabled());
reverseMenuItem.setChecked(mAdapter.isAnimationOnReverseScrollingEnabled());
}
// DiffUtil?
MenuItem diffUtilItem = menu.findItem(R.id.action_diff_util);
if (diffUtilItem != null) {
diffUtilItem.setChecked(DatabaseConfiguration.animateWithDiffUtil);
}
return super.onPrepareOptionsMenu(menu);
}
use of android.view.MenuItem in project FlexibleAdapter by davideas.
the class FragmentEndlessScrolling method onPrepareOptionsMenu.
@Override
public void onPrepareOptionsMenu(Menu menu) {
Log.v(TAG, "onPrepareOptionsMenu called!");
MenuItem gridMenuItem = menu.findItem(R.id.action_list_type);
if (mRecyclerView.getLayoutManager() instanceof GridLayoutManager) {
gridMenuItem.setIcon(R.drawable.ic_view_agenda_white_24dp);
gridMenuItem.setTitle(R.string.linear_layout);
} else {
gridMenuItem.setIcon(R.drawable.ic_view_grid_white_24dp);
gridMenuItem.setTitle(R.string.grid_layout);
}
}
use of android.view.MenuItem in project FlexibleAdapter by davideas.
the class MainActivity method onBackPressed.
/* ======
* EXTRAS
* ====== */
@Override
public void onBackPressed() {
// If Drawer is open, back key closes it
if (mDrawer.isDrawerOpen(GravityCompat.START)) {
mDrawer.closeDrawer(GravityCompat.START);
return;
}
// If ActionMode is active, back key closes it
if (mActionModeHelper.destroyActionModeIfCan())
return;
// If SearchView is visible, back key cancels search and iconify it
if (mSearchView != null && !mSearchView.isIconified()) {
mSearchView.setIconified(true);
return;
}
// Return to Overall View
if (DatabaseService.getInstance().getDatabaseType() != DatabaseType.OVERALL) {
MenuItem menuItem = mNavigationView.getMenu().findItem(R.id.nav_overall);
onNavigationItemSelected(menuItem);
return;
}
// Close the App
DatabaseService.onDestroy();
super.onBackPressed();
}
Aggregations