Search in sources :

Example 1 with ContextualActionModePresentationModel

use of org.robobinding.gallery.presentationmodel.ContextualActionModePresentationModel in project RoboBinding-gallery by RoboBinding.

the class ContextualActionModeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MemoryProductStore productStore = MemoryProductStore.getInstance();
    productStore.reset();
    presentationModel = new ContextualActionModePresentationModel(productStore);
    initializeContentView(R.layout.activity_contextual_action_mode, presentationModel);
    ListView productListView = (ListView) findViewById(R.id.productList);
    productListView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            startSupportActionMode(new ActionMode.Callback() {

                @Override
                public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
                    return false;
                }

                @Override
                public void onDestroyActionMode(ActionMode actionMode) {
                }

                @Override
                public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
                    MenuBinder menuBinder = createMenuBinder(menu, getMenuInflater());
                    menuBinder.inflateAndBind(R.menu.contextual_action_mode, presentationModel);
                    return true;
                }

                @Override
                public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
                    return false;
                }
            });
            return true;
        }
    });
}
Also used : MemoryProductStore(org.robobinding.gallery.model.MemoryProductStore) MenuBinder(org.robobinding.MenuBinder) MenuItem(android.view.MenuItem) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) ContextualActionModePresentationModel(org.robobinding.gallery.presentationmodel.ContextualActionModePresentationModel) ListView(android.widget.ListView) ActionMode(android.support.v7.view.ActionMode) Menu(android.view.Menu)

Aggregations

ActionMode (android.support.v7.view.ActionMode)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 OnItemLongClickListener (android.widget.AdapterView.OnItemLongClickListener)1 ListView (android.widget.ListView)1 MenuBinder (org.robobinding.MenuBinder)1 MemoryProductStore (org.robobinding.gallery.model.MemoryProductStore)1 ContextualActionModePresentationModel (org.robobinding.gallery.presentationmodel.ContextualActionModePresentationModel)1