Search in sources :

Example 1 with MemoryProductStore

use of org.robobinding.gallery.model.MemoryProductStore in project RoboBinding-gallery by RoboBinding.

the class ContextMenuDemoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MemoryProductStore productStore = MemoryProductStore.getInstance();
    productStore.reset();
    presentationModel = new ContextMenuDemoPresentationModel(productStore);
    contextMenuPresentationModel = new ContextMenuPresentationModel(productStore, presentationModel);
    initializeContentView(R.layout.activity_context_menu_demo, presentationModel);
    ListView productListView = (ListView) findViewById(R.id.productList);
    registerForContextMenu(productListView);
}
Also used : MemoryProductStore(org.robobinding.gallery.model.MemoryProductStore) ContextMenuPresentationModel(org.robobinding.gallery.presentationmodel.ContextMenuPresentationModel) ListView(android.widget.ListView) ContextMenuDemoPresentationModel(org.robobinding.gallery.presentationmodel.ContextMenuDemoPresentationModel)

Example 2 with MemoryProductStore

use of org.robobinding.gallery.model.MemoryProductStore 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)

Example 3 with MemoryProductStore

use of org.robobinding.gallery.model.MemoryProductStore in project RoboBinding-gallery by RoboBinding.

the class ViewPagerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ViewPager viewPager = new ViewPager(this);
    viewPager.setId(R.id.viewPager);
    setContentView(viewPager);
    final MemoryProductStore productStore = MemoryProductStore.getInstance();
    FragmentManager fm = getSupportFragmentManager();
    viewPager.setAdapter(new FragmentStatePagerAdapter(fm) {

        @Override
        public int getCount() {
            return productStore.size();
        }

        @Override
        public Fragment getItem(int index) {
            return FragmentDemo.newInstance(index);
        }
    });
    int selectedProductIndex = getIntent().getIntExtra(FragmentDemo.EXTRA_PRODUCT_INDEX, 0);
    viewPager.setCurrentItem(selectedProductIndex);
}
Also used : FragmentManager(android.support.v4.app.FragmentManager) FragmentStatePagerAdapter(android.support.v4.app.FragmentStatePagerAdapter) MemoryProductStore(org.robobinding.gallery.model.MemoryProductStore) ViewPager(android.support.v4.view.ViewPager) Fragment(android.support.v4.app.Fragment)

Example 4 with MemoryProductStore

use of org.robobinding.gallery.model.MemoryProductStore in project RoboBinding-gallery by RoboBinding.

the class ListFragmentDemo method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MemoryProductStore productStore = MemoryProductStore.getInstance();
    productStore.reset();
    presentationModel = new ListFragmentDemoPresentationModel(getActivity(), productStore.getAll());
}
Also used : MemoryProductStore(org.robobinding.gallery.model.MemoryProductStore) ListFragmentDemoPresentationModel(org.robobinding.gallery.presentationmodel.ListFragmentDemoPresentationModel)

Aggregations

MemoryProductStore (org.robobinding.gallery.model.MemoryProductStore)4 ListView (android.widget.ListView)2 Fragment (android.support.v4.app.Fragment)1 FragmentManager (android.support.v4.app.FragmentManager)1 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)1 ViewPager (android.support.v4.view.ViewPager)1 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 MenuBinder (org.robobinding.MenuBinder)1 ContextMenuDemoPresentationModel (org.robobinding.gallery.presentationmodel.ContextMenuDemoPresentationModel)1 ContextMenuPresentationModel (org.robobinding.gallery.presentationmodel.ContextMenuPresentationModel)1 ContextualActionModePresentationModel (org.robobinding.gallery.presentationmodel.ContextualActionModePresentationModel)1 ListFragmentDemoPresentationModel (org.robobinding.gallery.presentationmodel.ListFragmentDemoPresentationModel)1