FileDocCategorySizeDatePackage
FakeExpandableAdapter.javaAPI DocAndroid 5.1 API7569Thu Mar 12 22:22:44 GMT 2015com.android.layoutlib.bridge.impl.binding

FakeExpandableAdapter

public class FakeExpandableAdapter extends Object implements android.widget.HeterogeneousExpandableList, android.widget.ExpandableListAdapter

Fields Summary
private final com.android.ide.common.rendering.api.IProjectCallback
mCallback
private final com.android.ide.common.rendering.api.ResourceReference
mAdapterRef
private boolean
mSkipCallbackParser
protected final List
mItems
private final List
mGroupTypes
private final List
mChildrenTypes
Constructors Summary
public FakeExpandableAdapter(com.android.ide.common.rendering.api.ResourceReference adapterRef, com.android.ide.common.rendering.api.AdapterBinding binding, com.android.ide.common.rendering.api.IProjectCallback callback)


        
              
        mAdapterRef = adapterRef;
        mCallback = callback;

        createItems(binding, binding.getItemCount(), binding.getRepeatCount(), mGroupTypes, 1);
    
Methods Summary
public booleanareAllItemsEnabled()

        return true;
    
private voidcreateItems(java.lang.Iterable iterable, int itemCount, int repeatCount, java.util.List types, int depth)

        // Need an array to count for each type.
        // This is likely too big, but is the max it can be.
        int[] typeCount = new int[itemCount];

        // we put several repeating sets.
        for (int r = 0 ; r < repeatCount ; r++) {
            // loop on the type of list items, and add however many for each type.
            for (DataBindingItem dataBindingItem : iterable) {
                ResourceReference viewRef = dataBindingItem.getViewReference();
                int typeIndex = types.indexOf(viewRef);
                if (typeIndex == -1) {
                    typeIndex = types.size();
                    types.add(viewRef);
                }

                List<DataBindingItem> children = dataBindingItem.getChildren();
                int count = dataBindingItem.getCount();

                // if there are children, we use the count as a repeat count for the children.
                if (children.size() > 0) {
                    count = 1;
                }

                int index = typeCount[typeIndex];
                typeCount[typeIndex] += count;

                for (int k = 0 ; k < count ; k++) {
                    AdapterItem item = new AdapterItem(dataBindingItem, typeIndex, mItems.size(),
                            index++);
                    mItems.add(item);

                    if (children.size() > 0) {
                        createItems(dataBindingItem, depth + 1);
                    }
                }
            }
        }
    
private voidcreateItems(com.android.ide.common.rendering.api.DataBindingItem item, int depth)

        if (depth == 2) {
            createItems(item, item.getChildren().size(), item.getCount(), mChildrenTypes, depth);
        }
    
public java.lang.ObjectgetChild(int groupPosition, int childPosition)

        return getChildItem(groupPosition, childPosition);
    
public longgetChildId(int groupPosition, int childPosition)

        return childPosition;
    
private AdapterItemgetChildItem(int groupPosition, int childPosition)

        AdapterItem item = mItems.get(groupPosition);

        List<AdapterItem> children = item.getChildren();
        return children.get(childPosition);
    
public intgetChildType(int groupPosition, int childPosition)

        return getChildItem(groupPosition, childPosition).getType();
    
public intgetChildTypeCount()

        return mChildrenTypes.size();
    
public android.view.ViewgetChildView(int groupPosition, int childPosition, boolean isLastChild, android.view.View convertView, android.view.ViewGroup parent)

        // we don't care about recycling here because we never scroll.
        AdapterItem parentItem = mItems.get(groupPosition);
        AdapterItem item = getChildItem(groupPosition, childPosition);
        Pair<View, Boolean> pair = AdapterHelper.getView(item, parentItem, parent, mCallback,
                mAdapterRef, mSkipCallbackParser);
        mSkipCallbackParser = pair.getSecond();
        return pair.getFirst();
    
public intgetChildrenCount(int groupPosition)

        AdapterItem item = mItems.get(groupPosition);
        return item.getChildren().size();
    
public longgetCombinedChildId(long groupId, long childId)

        return groupId << 16 | childId;
    
public longgetCombinedGroupId(long groupId)

        return groupId << 16 | 0x0000FFFF;
    
public java.lang.ObjectgetGroup(int groupPosition)

        return mItems.get(groupPosition);
    
public intgetGroupCount()

        return mItems.size();
    
public longgetGroupId(int groupPosition)

        return groupPosition;
    
public intgetGroupType(int groupPosition)

        return mItems.get(groupPosition).getType();
    
public intgetGroupTypeCount()

        return mGroupTypes.size();
    
public android.view.ViewgetGroupView(int groupPosition, boolean isExpanded, android.view.View convertView, android.view.ViewGroup parent)

        // we don't care about recycling here because we never scroll.
        AdapterItem item = mItems.get(groupPosition);
        Pair<View, Boolean> pair = AdapterHelper.getView(item, null /*parentItem*/, parent,
                mCallback, mAdapterRef, mSkipCallbackParser);
        mSkipCallbackParser = pair.getSecond();
        return pair.getFirst();
    
public booleanhasStableIds()

        return true;
    
public booleanisChildSelectable(int groupPosition, int childPosition)

        return true;
    
public booleanisEmpty()

        return mItems.isEmpty();
    
public voidonGroupCollapsed(int groupPosition)

        // pass
    
public voidonGroupExpanded(int groupPosition)

        // pass
    
public voidregisterDataSetObserver(android.database.DataSetObserver observer)

        // pass
    
public voidunregisterDataSetObserver(android.database.DataSetObserver observer)

        // pass