Example usage for android.view ActionMode getMenuInflater

List of usage examples for android.view ActionMode getMenuInflater

Introduction

In this page you can find the example usage for android.view ActionMode getMenuInflater.

Prototype

public abstract MenuInflater getMenuInflater();

Source Link

Document

Returns a MenuInflater with the ActionMode's context.

Usage

From source file:net.lacolaco.smileessence.activity.EditExtractionActivity.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    menu.clear();/*from  w  w w .j  a v  a 2 s.c  om*/
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.edit_list, menu);
    return true;
}

From source file:net.kjmaster.cookiemom.global.CookieActionActivity.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = mode.getMenuInflater();

    if (inflater != null) {
        inflater.inflate(actionMenu, menu);
    }/*from   w w  w .  j  ava  2s  .c o m*/

    return true;
}

From source file:com.vmihalachi.turboeditor.fragment.NavigationDrawerListFragment.java

/**
 * {@inheritDoc}/*from   w  ww.j a  v a  2  s.c  o  m*/
 */
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
    MenuInflater inflater = actionMode.getMenuInflater();
    inflater.inflate(R.menu.action_mode_navigation_drawer, menu);
    return true;
}

From source file:ch.ethz.twimight.activities.DmListActivity.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.dm_context, menu);
    return true;/*ww w.j  a v a2  s  . c om*/
}

From source file:com.veniosg.dir.android.fragment.SideNavFragment.java

private void setListChoiceListener() {
    getListView().setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
        @Override//from w ww.  j  ava  2s . c  o  m
        public boolean onPrepareActionMode(android.view.ActionMode mode, Menu menu) {
            menu.clear();
            mode.getMenuInflater().inflate(R.menu.cab_bookmarks, menu);

            if (getListView().getCheckedItemCount() != 1) {
                menu.removeItem(R.id.menu_open_parent);
            }
            return true;
        }

        @Override
        public void onDestroyActionMode(android.view.ActionMode mode) {
            setStatusBarColour(getActivity(), false);
        }

        @Override
        public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) {
            setStatusBarColour(getActivity(), true);
            return true;
        }

        @Override
        public boolean onActionItemClicked(android.view.ActionMode mode, MenuItem item) {
            switch (item.getItemId()) {
            case R.id.menu_delete:
                long[] ids = getListView().getCheckedItemIds();
                for (long id : ids) {
                    getListView().getContext().getContentResolver().delete(BookmarkProvider.CONTENT_URI,
                            BookmarkProvider._ID + "=?", new String[] { "" + id });
                }
                mode.finish();
                return true;

            case R.id.menu_open_parent:
                int pos = 0;
                SparseBooleanArray checked = getListView().getCheckedItemPositions();
                for (int i = 0; i < getListView().getCount(); i++) {
                    if (checked.get(i)) {
                        pos = i;
                    }
                }

                String path = ((Cursor) getListAdapter().getItem(pos)).getString(2);
                ((BookmarkContract) getActivity()).onBookmarkSelected(new File(path).getParent());
                mode.finish();
                return true;
            }
            return false;
        }

        @Override
        public void onItemCheckedStateChanged(android.view.ActionMode mode, int position, long id,
                boolean checked) {
            if (getListView().getCheckedItemCount() != 0) {

                mode.setTitle(getListView().getCheckedItemCount() + " " + getString(R.string.selected));

                // Force actions' refresh
                mode.invalidate();
            }
        }
    });
    getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
}

From source file:me.diskstation.ammon.gpsrunner.ui.CalendarFragment.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.menu_calendar_contextual, menu);
    selectionMode = true;/*from w w  w.j  a  v a2  s.c om*/
    return true;
}

From source file:com.fusionx.lightirc.ui.UserListFragment.java

@Override
public boolean onCreateActionMode(final ActionMode mode, final Menu menu) {
    mActionMode = mode;//from  w  w w.jav  a2  s .  co m

    final MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.fragment_userlist_cab, menu);
    return true;
}

From source file:br.com.android.cotuca.toptask.Activitys.MSimplesActivity.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {

    if (!actionModeAtivado) {
        mode.getMenuInflater().inflate(R.menu.actionmode_tarefa, menu);
    }/*from ww w.  j a v  a2 s  .  c o  m*/
    return true;
}

From source file:com.btmura.android.reddit.app.MessageThreadListController.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu, ListView listView) {
    if (adapter.getCursor() == null) {
        listView.clearChoices();//  w w  w.ja va 2s . c  om
        return false;
    }

    actionMode = mode;
    MenuInflater inflater = mode.getMenuInflater();
    inflater.inflate(R.menu.message_thread_action_menu, menu);
    return true;
}

From source file:com.btmura.android.reddit.app.SubredditActionModeController.java

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu, ListView lv) {
    if (adapter.getCursor() == null) {
        lv.clearChoices();//  w  w w . j av a2  s .  c om
        return false;
    }
    actionMode = mode;

    MenuInflater menuInflater = mode.getMenuInflater();
    menuInflater.inflate(R.menu.subreddit_action_menu, menu);
    return true;
}