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

FakeAdapter

public class FakeAdapter extends android.widget.BaseAdapter
Fake adapter to do fake data binding in {@link AdapterView} objects for {@link ListAdapter} and {@link SpinnerAdapter}.

Fields Summary
private final List
mTypes
private final com.android.ide.common.rendering.api.IProjectCallback
mCallback
private final com.android.ide.common.rendering.api.ResourceReference
mAdapterRef
private final List
mItems
private boolean
mSkipCallbackParser
Constructors Summary
public FakeAdapter(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;

        final int repeatCount = binding.getRepeatCount();
        final int itemCount = binding.getItemCount();

        // 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 : binding) {
                ResourceReference viewRef = dataBindingItem.getViewReference();
                int typeIndex = mTypes.indexOf(viewRef);
                if (typeIndex == -1) {
                    typeIndex = mTypes.size();
                    mTypes.add(viewRef);
                }

                int count = dataBindingItem.getCount();

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

                for (int k = 0 ; k < count ; k++) {
                    mItems.add(new AdapterItem(dataBindingItem, typeIndex, mItems.size(), index++));
                }
            }
        }
    
Methods Summary
public intgetCount()

        return mItems.size();
    
public android.view.ViewgetDropDownView(int position, android.view.View convertView, android.view.ViewGroup parent)

        // pass
        return null;
    
public java.lang.ObjectgetItem(int position)

        return mItems.get(position);
    
public longgetItemId(int position)

        return position;
    
public intgetItemViewType(int position)

        return mItems.get(position).getType();
    
public android.view.ViewgetView(int position, android.view.View convertView, android.view.ViewGroup parent)

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

    
public intgetViewTypeCount()

        return mTypes.size();
    
public booleanisEnabled(int position)

        return true;