Search in sources :

Example 16 with MenuItem

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;
}
Also used : MenuItem(android.view.MenuItem) ShareActionProvider(android.support.v7.widget.ShareActionProvider)

Example 17 with MenuItem

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));
}
Also used : MediaRouteActionProvider(android.support.v7.app.MediaRouteActionProvider) MenuItem(android.view.MenuItem)

Example 18 with MenuItem

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);
}
Also used : MenuItem(android.view.MenuItem)

Example 19 with MenuItem

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);
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) SmoothScrollGridLayoutManager(eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager) MenuItem(android.view.MenuItem)

Example 20 with MenuItem

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();
}
Also used : MenuItem(android.view.MenuItem)

Aggregations

MenuItem (android.view.MenuItem)713 View (android.view.View)125 Intent (android.content.Intent)75 TextView (android.widget.TextView)66 ImageView (android.widget.ImageView)55 PopupMenu (android.widget.PopupMenu)54 Menu (android.view.Menu)47 SmallTest (android.test.suitebuilder.annotation.SmallTest)42 SearchView (android.support.v7.widget.SearchView)41 RecyclerView (android.support.v7.widget.RecyclerView)32 MenuInflater (android.view.MenuInflater)29 AdapterView (android.widget.AdapterView)27 ListView (android.widget.ListView)27 SubMenu (android.view.SubMenu)26 ComponentName (android.content.ComponentName)25 PackageManager (android.content.pm.PackageManager)24 Parcelable (android.os.Parcelable)23 Toolbar (android.support.v7.widget.Toolbar)19 ResolveInfo (android.content.pm.ResolveInfo)18 Bundle (android.os.Bundle)18