Search in sources :

Example 1 with SlideDownAlphaAnimator

use of com.mikepenz.itemanimators.SlideDownAlphaAnimator in project FastAdapter by mikepenz.

the class ExpandableMultiselectDeleteSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    //as we use an icon from Android-Iconics via xml we add the IconicsLayoutInflater
    //https://github.com/mikepenz/Android-Iconics
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);
    // get RecyclerView
    final RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.sample_collapsible);
    //style our ui
    new MaterializeBuilder().withActivity(this).build();
    //create our FastAdapter
    fastItemAdapter = new FastItemAdapter<>();
    fastItemAdapter.withPositionBasedStateManagement(false).withSelectable(true).withMultiSelect(true).withSelectOnLongClick(true).withOnPreClickListener(new FastAdapter.OnClickListener<IItem>() {

        @Override
        public boolean onClick(View v, IAdapter<IItem> adapter, IItem item, int position) {
            //we handle the default onClick behavior for the actionMode. This will return null if it didn't do anything and you can handle a normal onClick
            Boolean res = mActionModeHelper.onClick(ExpandableMultiselectDeleteSampleActivity.this, item);
            // so that the click listener is not fired
            if (res != null && !res)
                return true;
            return res != null ? res : false;
        }
    }).withOnClickListener(new FastAdapter.OnClickListener<IItem>() {

        @Override
        public boolean onClick(View v, IAdapter<IItem> adapter, IItem item, int position) {
            // check if the actionMode consumes the click. This returns true, if it does, false if not
            if (!mActionModeHelper.isActive())
                Toast.makeText(ExpandableMultiselectDeleteSampleActivity.this, ((SimpleSubItem) item).name + " clicked!", Toast.LENGTH_SHORT).show();
            //                        else
            //                            mFastAdapter.notifyItemChanged(position); // im Bsp. ist das nicht nötig, k.A. warum ich das machen muss!
            mRangeSelectorHelper.onClick();
            return false;
        }
    }).withOnPreLongClickListener(new FastAdapter.OnLongClickListener<IItem>() {

        @Override
        public boolean onLongClick(View v, IAdapter<IItem> adapter, IItem item, int position) {
            boolean actionModeWasActive = mActionModeHelper.isActive();
            ActionMode actionMode = mActionModeHelper.onLongClick((AppCompatActivity) ExpandableMultiselectDeleteSampleActivity.this, position);
            mRangeSelectorHelper.onLongClick(position);
            if (actionMode != null) {
                //we want color our CAB
                ExpandableMultiselectDeleteSampleActivity.this.findViewById(R.id.action_mode_bar).setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(ExpandableMultiselectDeleteSampleActivity.this, R.attr.colorPrimary, R.color.material_drawer_primary));
                // start the drag selection
                mDragSelectTouchListener.startDragSelection(position);
            }
            //if we have no actionMode we do not consume the event
            return actionMode != null && !actionModeWasActive;
        }
    });
    // provide a custom title provider that even shows the count of sub items
    mActionModeHelper = new ActionModeHelper(fastItemAdapter, R.menu.cab, new ActionBarCallBack()).withTitleProvider(new ActionModeHelper.ActionModeTitleProvider() {

        @Override
        public String getTitle(int selected) {
            return selected + "/" + SubItemUtil.countItems(fastItemAdapter.getItemAdapter(), false);
        }
    }).withSupportSubItems(true);
    // this will take care of selecting range of items via long press on the first and afterwards on the last item
    mRangeSelectorHelper = new RangeSelectorHelper(fastItemAdapter).withSavedInstanceState(savedInstanceState).withActionModeHelper(mActionModeHelper);
    // setup the drag select listener and add it to the RecyclerView
    mDragSelectTouchListener = new DragSelectTouchListener().withSelectListener(new DragSelectTouchListener.OnDragSelectListener() {

        @Override
        public void onSelectChange(int start, int end, boolean isSelected) {
            mRangeSelectorHelper.selectRange(start, end, isSelected, true);
            // we handled the long press, so we reset the range selector
            mRangeSelectorHelper.reset();
        }
    });
    rv.addOnItemTouchListener(mDragSelectTouchListener);
    // do basic RecyclerView setup
    rv.setLayoutManager(new LinearLayoutManager(this));
    rv.setItemAnimator(new SlideDownAlphaAnimator());
    rv.setAdapter(fastItemAdapter);
    //fill with some sample data
    List<IItem> items = new ArrayList<>();
    for (int i = 0; i < 20; i++) {
        if (i % 2 == 0) {
            final HeaderSelectionItem expandableItem = new HeaderSelectionItem();
            expandableItem.withSubSelectionProvider(new HeaderSelectionItem.ISubSelectionProvider() {

                @Override
                public int getSelectedSubItems() {
                    return SubItemUtil.countSelectedSubItems(fastItemAdapter, expandableItem);
                }
            }).withName("Test " + (i + 1)).withDescription("ID: " + (i + 1)).withIdentifier(i + 1);
            //.withIsExpanded(true) don't use this in such a setup, use adapter.expand() to expand all items instead
            //add subitems so we can showcase the collapsible functionality
            List<IItem> subItems = new LinkedList<>();
            for (int ii = 1; ii <= 5; ii++) {
                final SimpleSubItem sampleItem = new SimpleSubItem();
                sampleItem.withName("-- Test " + (i + 1) + "." + ii).withDescription("ID: " + (i + 1) * 100 + ii).withIdentifier((i + 1) * 100 + ii);
                subItems.add(sampleItem);
            }
            expandableItem.withSubItems(subItems);
            items.add(expandableItem);
        } else {
            SimpleSubItem sampleItem = new SimpleSubItem();
            sampleItem.withName("Test " + (i + 1)).withDescription("ID: " + (i + 1)).withIdentifier(i + 1);
            items.add(sampleItem);
        }
    }
    fastItemAdapter.add(items);
    fastItemAdapter.expand();
    fastItemAdapter.withSelectionListener(new ISelectionListener() {

        @Override
        public void onSelectionChanged(IItem item, boolean selected) {
            if (item instanceof SimpleSubItem) {
                IItem headerItem = ((SimpleSubItem) item).getParent();
                if (headerItem != null) {
                    int pos = fastItemAdapter.getAdapterPosition(headerItem);
                    // Important: notify the header directly, not via the notifyadapterItemChanged!
                    // we just want to update the view and we are sure, nothing else has to be done
                    fastItemAdapter.notifyItemChanged(pos);
                }
            }
        }
    });
    //restore selections (this has to be done after the items were added
    fastItemAdapter.withSavedInstanceState(savedInstanceState);
    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
    // restore action mode
    if (savedInstanceState != null)
        mActionModeHelper.checkActionMode(this);
}
Also used : ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ISelectionListener(com.mikepenz.fastadapter.ISelectionListener) SlideDownAlphaAnimator(com.mikepenz.itemanimators.SlideDownAlphaAnimator) IItem(com.mikepenz.fastadapter.IItem) IAdapter(com.mikepenz.fastadapter.IAdapter) Toolbar(android.support.v7.widget.Toolbar) SimpleSubItem(com.mikepenz.fastadapter.app.items.expandable.SimpleSubItem) RangeSelectorHelper(com.mikepenz.fastadapter_extensions.RangeSelectorHelper) HeaderSelectionItem(com.mikepenz.fastadapter.app.items.HeaderSelectionItem) AppCompatActivity(android.support.v7.app.AppCompatActivity) MaterializeBuilder(com.mikepenz.materialize.MaterializeBuilder) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) LinkedList(java.util.LinkedList) ActionMode(android.support.v7.view.ActionMode) RecyclerView(android.support.v7.widget.RecyclerView) FastAdapter(com.mikepenz.fastadapter.FastAdapter) IconicsLayoutInflater(com.mikepenz.iconics.context.IconicsLayoutInflater) ActionModeHelper(com.mikepenz.fastadapter_extensions.ActionModeHelper) DragSelectTouchListener(com.michaelflisar.dragselectrecyclerview.DragSelectTouchListener)

Example 2 with SlideDownAlphaAnimator

use of com.mikepenz.itemanimators.SlideDownAlphaAnimator in project FastAdapter by mikepenz.

the class ExpandableSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    //as we use an icon from Android-Iconics via xml we add the IconicsLayoutInflater
    //https://github.com/mikepenz/Android-Iconics
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.sample_collapsible);
    //style our ui
    new MaterializeBuilder().withActivity(this).build();
    //create our FastAdapter
    fastItemAdapter = new FastItemAdapter<>();
    fastItemAdapter.withSelectable(true);
    //get our recyclerView and do basic setup
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
    rv.setLayoutManager(new LinearLayoutManager(this));
    rv.setItemAnimator(new SlideDownAlphaAnimator());
    rv.setAdapter(fastItemAdapter);
    //fill with some sample data
    List<IItem> items = new ArrayList<>();
    for (int i = 1; i <= 100; i++) {
        if (i % 10 == 0) {
            SimpleSubExpandableItem expandableItem = new SimpleSubExpandableItem();
            expandableItem.withName("Test " + i).withIdentifier(100 + 1);
            //add subitems so we can showcase the collapsible functionality
            List<IItem> subItems = new LinkedList<>();
            for (int ii = 1; ii <= 5; ii++) {
                SimpleSubItem sampleItem = new SimpleSubItem();
                sampleItem.withName("-- Test " + ii).withIdentifier(1000 + ii);
                subItems.add(sampleItem);
            }
            expandableItem.withSubItems(subItems);
            items.add(expandableItem);
        } else {
            items.add(new SimpleSubItem().withName("Test " + i).withIdentifier(100 + i));
        }
    }
    fastItemAdapter.add(items);
    //restore selections (this has to be done after the items were added
    fastItemAdapter.withSavedInstanceState(savedInstanceState);
    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
Also used : SimpleSubItem(com.mikepenz.fastadapter.app.items.expandable.SimpleSubItem) SimpleSubExpandableItem(com.mikepenz.fastadapter.app.items.expandable.SimpleSubExpandableItem) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MaterializeBuilder(com.mikepenz.materialize.MaterializeBuilder) LinkedList(java.util.LinkedList) SlideDownAlphaAnimator(com.mikepenz.itemanimators.SlideDownAlphaAnimator) RecyclerView(android.support.v7.widget.RecyclerView) IItem(com.mikepenz.fastadapter.IItem) IconicsLayoutInflater(com.mikepenz.iconics.context.IconicsLayoutInflater) Toolbar(android.support.v7.widget.Toolbar)

Example 3 with SlideDownAlphaAnimator

use of com.mikepenz.itemanimators.SlideDownAlphaAnimator in project FastAdapter by mikepenz.

the class IconGridActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    //as we use an icon from Android-Iconics via xml we add the IconicsLayoutInflater
    //https://github.com/mikepenz/Android-Iconics
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.sample_icon_grid);
    //style our ui
    new MaterializeBuilder().withActivity(this).build();
    //create our FastAdapter which will manage everything
    fastItemAdapter = new FastItemAdapter();
    //get our recyclerView and do basic setup
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
    //init our gridLayoutManager and configure RV
    GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
    gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {

        @Override
        public int getSpanSize(int position) {
            switch(fastItemAdapter.getItemViewType(position)) {
                case R.id.fastadapter_expandable_item_id:
                    return 3;
                case R.id.fastadapter_icon_item_id:
                    return 1;
                default:
                    return -1;
            }
        }
    });
    rv.setLayoutManager(gridLayoutManager);
    rv.setItemAnimator(new SlideDownAlphaAnimator());
    rv.setAdapter(fastItemAdapter);
    //order fonts by their name
    List<ITypeface> mFonts = new ArrayList<>(Iconics.getRegisteredFonts(this));
    Collections.sort(mFonts, new Comparator<ITypeface>() {

        @Override
        public int compare(final ITypeface object1, final ITypeface object2) {
            return object1.getFontName().compareTo(object2.getFontName());
        }
    });
    //add all icons of all registered Fonts to the list
    int count = 0;
    ArrayList<SimpleSubExpandableItem> items = new ArrayList<>(Iconics.getRegisteredFonts(this).size());
    for (ITypeface font : mFonts) {
        //we set the identifier from the count here, as I need a stable ID in the sample to showcase the state restore
        SimpleSubExpandableItem expandableItem = new SimpleSubExpandableItem();
        expandableItem.withName(font.getFontName()).withIdentifier(count);
        ArrayList<IItem> icons = new ArrayList<>();
        for (String icon : font.getIcons()) {
            IconItem iconItem = new IconItem();
            iconItem.withIcon(font.getIcon(icon));
            icons.add(iconItem);
        }
        expandableItem.withSubItems(icons);
        items.add(expandableItem);
        count++;
    }
    //fill with some sample data
    fastItemAdapter.add(items);
    //if first start we want to expand the item with ID 2
    if (savedInstanceState != null) {
        //restore selections (this has to be done after the items were added
        fastItemAdapter.withSavedInstanceState(savedInstanceState);
    } else {
        //expand one item to make sample look a bit more interesting
        fastItemAdapter.expand(2);
    }
    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
Also used : SimpleSubExpandableItem(com.mikepenz.fastadapter.app.items.expandable.SimpleSubExpandableItem) FastItemAdapter(com.mikepenz.fastadapter.commons.adapters.FastItemAdapter) ArrayList(java.util.ArrayList) MaterializeBuilder(com.mikepenz.materialize.MaterializeBuilder) GridLayoutManager(android.support.v7.widget.GridLayoutManager) SlideDownAlphaAnimator(com.mikepenz.itemanimators.SlideDownAlphaAnimator) IconItem(com.mikepenz.fastadapter.app.items.IconItem) ITypeface(com.mikepenz.iconics.typeface.ITypeface) RecyclerView(android.support.v7.widget.RecyclerView) IItem(com.mikepenz.fastadapter.IItem) IconicsLayoutInflater(com.mikepenz.iconics.context.IconicsLayoutInflater) Toolbar(android.support.v7.widget.Toolbar)

Example 4 with SlideDownAlphaAnimator

use of com.mikepenz.itemanimators.SlideDownAlphaAnimator in project FastAdapter by mikepenz.

the class MultiTypeGenericItemActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.sample_multi_generic_item);
    //style our ui
    new MaterializeBuilder().withActivity(this).build();
    //create our FastAdapter which will manage everything
    fastAdapter = new FastAdapter();
    fastAdapter.withSelectable(true);
    //get our recyclerView and do basic setup
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
    //init our gridLayoutManager and configure RV
    GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);
    //if you need multiple items for different models you can also do this be defining a Function which get's the model object and returns the item (extends IItem)
    GenericItemAdapter<IconModel, GenericIconItem> itemAdapter = new GenericItemAdapter<>(new Function<IconModel, GenericIconItem>() {

        @Override
        public GenericIconItem apply(IconModel o) {
            if (o instanceof RightIconModel) {
                return new RightGenericIconItem(o);
            } else {
                return new GenericIconItem(o);
            }
        }
    });
    rv.setLayoutManager(gridLayoutManager);
    rv.setItemAnimator(new SlideDownAlphaAnimator());
    rv.setAdapter(itemAdapter.wrap(fastAdapter));
    //order fonts by their name
    List<ITypeface> mFonts = new ArrayList<>(Iconics.getRegisteredFonts(this));
    Collections.sort(mFonts, new Comparator<ITypeface>() {

        @Override
        public int compare(final ITypeface object1, final ITypeface object2) {
            return object1.getFontName().compareTo(object2.getFontName());
        }
    });
    //add all icons of all registered Fonts to the list
    ArrayList<IconModel> models = new ArrayList<>();
    int i = 0;
    for (ITypeface font : mFonts) {
        for (String icon : font.getIcons()) {
            if (i % 3 == 0) {
                models.add(new IconModel(font.getIcon(icon)));
            } else {
                models.add(new RightIconModel(font.getIcon(icon)));
            }
            i++;
        }
    }
    //fill with some sample data
    itemAdapter.addModel(models);
    //restore selections (this has to be done after the items were added
    fastAdapter.withSavedInstanceState(savedInstanceState);
    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
Also used : RightIconModel(com.mikepenz.fastadapter.app.generic.RightIconModel) IconModel(com.mikepenz.fastadapter.app.generic.IconModel) GenericIconItem(com.mikepenz.fastadapter.app.generic.GenericIconItem) RightGenericIconItem(com.mikepenz.fastadapter.app.generic.RightGenericIconItem) ArrayList(java.util.ArrayList) RightGenericIconItem(com.mikepenz.fastadapter.app.generic.RightGenericIconItem) MaterializeBuilder(com.mikepenz.materialize.MaterializeBuilder) GridLayoutManager(android.support.v7.widget.GridLayoutManager) SlideDownAlphaAnimator(com.mikepenz.itemanimators.SlideDownAlphaAnimator) GenericItemAdapter(com.mikepenz.fastadapter.adapters.GenericItemAdapter) ITypeface(com.mikepenz.iconics.typeface.ITypeface) RightIconModel(com.mikepenz.fastadapter.app.generic.RightIconModel) RecyclerView(android.support.v7.widget.RecyclerView) FastAdapter(com.mikepenz.fastadapter.FastAdapter) Toolbar(android.support.v7.widget.Toolbar)

Example 5 with SlideDownAlphaAnimator

use of com.mikepenz.itemanimators.SlideDownAlphaAnimator in project FastAdapter by mikepenz.

the class MultiselectSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.sample_multi_select);
    //style our ui
    new MaterializeBuilder().withActivity(this).build();
    //create our FastAdapter
    mFastAdapter = new FastAdapter<>();
    //
    mUndoHelper = new UndoHelper(mFastAdapter, new UndoHelper.UndoListener<SimpleItem>() {

        @Override
        public void commitRemove(Set<Integer> positions, ArrayList<FastAdapter.RelativeInfo<SimpleItem>> removed) {
            Log.e("UndoHelper", "Positions: " + positions.toString() + " Removed: " + removed.size());
        }
    });
    //we init our ActionModeHelper
    mActionModeHelper = new ActionModeHelper(mFastAdapter, R.menu.cab, new ActionBarCallBack());
    //create our adapters
    ItemAdapter<SimpleItem> itemAdapter = new ItemAdapter<>();
    final HeaderAdapter<SimpleItem> headerAdapter = new HeaderAdapter<>();
    //configure our mFastAdapter
    //as we provide id's for the items we want the hasStableIds enabled to speed up things
    mFastAdapter.setHasStableIds(true);
    mFastAdapter.withSelectable(true);
    mFastAdapter.withMultiSelect(true);
    mFastAdapter.withSelectOnLongClick(true);
    mFastAdapter.withOnPreClickListener(new FastAdapter.OnClickListener<SimpleItem>() {

        @Override
        public boolean onClick(View v, IAdapter<SimpleItem> adapter, SimpleItem item, int position) {
            //we handle the default onClick behavior for the actionMode. This will return null if it didn't do anything and you can handle a normal onClick
            Boolean res = mActionModeHelper.onClick(item);
            return res != null ? res : false;
        }
    });
    mFastAdapter.withOnClickListener(new FastAdapter.OnClickListener<SimpleItem>() {

        @Override
        public boolean onClick(View v, IAdapter<SimpleItem> adapter, SimpleItem item, int position) {
            Toast.makeText(v.getContext(), "SelectedCount: " + mFastAdapter.getSelections().size() + " ItemsCount: " + mFastAdapter.getSelectedItems().size(), Toast.LENGTH_SHORT).show();
            return false;
        }
    });
    mFastAdapter.withOnPreLongClickListener(new FastAdapter.OnLongClickListener<SimpleItem>() {

        @Override
        public boolean onLongClick(View v, IAdapter<SimpleItem> adapter, SimpleItem item, int position) {
            ActionMode actionMode = mActionModeHelper.onLongClick(MultiselectSampleActivity.this, position);
            if (actionMode != null) {
                //we want color our CAB
                findViewById(R.id.action_mode_bar).setBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(MultiselectSampleActivity.this, R.attr.colorPrimary, R.color.material_drawer_primary));
            }
            //if we have no actionMode we do not consume the event
            return actionMode != null;
        }
    });
    //get our recyclerView and do basic setup
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
    rv.setLayoutManager(new LinearLayoutManager(this));
    rv.setItemAnimator(new SlideDownAlphaAnimator());
    rv.setAdapter(itemAdapter.wrap(headerAdapter.wrap(mFastAdapter)));
    //fill with some sample data
    SimpleItem SimpleItem = new SimpleItem();
    SimpleItem.withName("Header").withIdentifier(1).withSelectable(false);
    headerAdapter.add(SimpleItem);
    List<SimpleItem> items = new ArrayList<>();
    for (int i = 1; i <= 100; i++) {
        SimpleItem item = new SimpleItem();
        item.withName("Test " + i).withIdentifier(100 + i);
        items.add(item);
    }
    itemAdapter.add(items);
    //restore selections (this has to be done after the items were added
    mFastAdapter.withSavedInstanceState(savedInstanceState);
    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
    //inform that longClick is required
    Toast.makeText(this, "LongClick to enable Multi-Selection", Toast.LENGTH_LONG).show();
}
Also used : Set(java.util.Set) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) HeaderAdapter(com.mikepenz.fastadapter.adapters.HeaderAdapter) SlideDownAlphaAnimator(com.mikepenz.itemanimators.SlideDownAlphaAnimator) Toolbar(android.support.v7.widget.Toolbar) ItemAdapter(com.mikepenz.fastadapter.adapters.ItemAdapter) UndoHelper(com.mikepenz.fastadapter_extensions.UndoHelper) MaterializeBuilder(com.mikepenz.materialize.MaterializeBuilder) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ActionMode(android.support.v7.view.ActionMode) RecyclerView(android.support.v7.widget.RecyclerView) FastAdapter(com.mikepenz.fastadapter.FastAdapter) SimpleItem(com.mikepenz.fastadapter.app.items.SimpleItem) ActionModeHelper(com.mikepenz.fastadapter_extensions.ActionModeHelper)

Aggregations

SlideDownAlphaAnimator (com.mikepenz.itemanimators.SlideDownAlphaAnimator)8 RecyclerView (android.support.v7.widget.RecyclerView)7 Toolbar (android.support.v7.widget.Toolbar)7 MaterializeBuilder (com.mikepenz.materialize.MaterializeBuilder)6 ArrayList (java.util.ArrayList)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 FastAdapter (com.mikepenz.fastadapter.FastAdapter)4 GridLayoutManager (android.support.v7.widget.GridLayoutManager)3 View (android.view.View)3 IItem (com.mikepenz.fastadapter.IItem)3 IconicsLayoutInflater (com.mikepenz.iconics.context.IconicsLayoutInflater)3 ITypeface (com.mikepenz.iconics.typeface.ITypeface)3 ActionMode (android.support.v7.view.ActionMode)2 GenericItemAdapter (com.mikepenz.fastadapter.adapters.GenericItemAdapter)2 GenericIconItem (com.mikepenz.fastadapter.app.generic.GenericIconItem)2 IconModel (com.mikepenz.fastadapter.app.generic.IconModel)2 SimpleSubExpandableItem (com.mikepenz.fastadapter.app.items.expandable.SimpleSubExpandableItem)2 SimpleSubItem (com.mikepenz.fastadapter.app.items.expandable.SimpleSubItem)2 ActionModeHelper (com.mikepenz.fastadapter_extensions.ActionModeHelper)2 LinkedList (java.util.LinkedList)2