Search in sources :

Example 11 with IExpandable

use of com.mikepenz.fastadapter.IExpandable in project FastAdapter by mikepenz.

the class AdapterUtil method findSubItemSelections.

/**
     * internal method to find all selections from subItems and sub sub items so we can save those inside our savedInstanceState
     *
     * @param item       the parent item
     * @param selections the ArrayList which will be stored in the savedInstanceState
     */
public static <Item extends IItem> void findSubItemSelections(Item item, List<String> selections) {
    if (item instanceof IExpandable && !((IExpandable) item).isExpanded() && ((IExpandable) item).getSubItems() != null) {
        List<Item> subItems = (List<Item>) ((IExpandable<Item, ?>) item).getSubItems();
        Item subItem;
        String id;
        for (int i = 0, size = subItems.size(); i < size; i++) {
            subItem = subItems.get(i);
            id = String.valueOf(subItem.getIdentifier());
            if (subItem.isSelected()) {
                selections.add(id);
            }
            findSubItemSelections(subItem, selections);
        }
    }
}
Also used : IItem(com.mikepenz.fastadapter.IItem) IExpandable(com.mikepenz.fastadapter.IExpandable) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

IExpandable (com.mikepenz.fastadapter.IExpandable)11 IItem (com.mikepenz.fastadapter.IItem)10 ArrayList (java.util.ArrayList)6 IAdapter (com.mikepenz.fastadapter.IAdapter)3 List (java.util.List)3 RecyclerView (android.support.v7.widget.RecyclerView)2 View (android.view.View)2 FastAdapter (com.mikepenz.fastadapter.FastAdapter)2 IItemAdapter (com.mikepenz.fastadapter.IItemAdapter)2 LinkedList (java.util.LinkedList)2 Handler (android.os.Handler)1 ActionMode (android.support.v7.view.ActionMode)1 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 Toolbar (android.support.v7.widget.Toolbar)1 LinearLayout (android.widget.LinearLayout)1 StickyHeaderAdapter (com.mikepenz.fastadapter.app.adapters.StickyHeaderAdapter)1 ActionModeHelper (com.mikepenz.fastadapter_extensions.ActionModeHelper)1 IconicsLayoutInflater (com.mikepenz.iconics.context.IconicsLayoutInflater)1 AbstractDrawerItem (com.mikepenz.materialdrawer.model.AbstractDrawerItem)1