FileDocCategorySizeDatePackage
RemoteViewsListAdapter.javaAPI DocAndroid 5.1 API3394Thu Mar 12 22:22:10 GMT 2015android.widget

RemoteViewsListAdapter

public class RemoteViewsListAdapter extends BaseAdapter
hide

Fields Summary
private android.content.Context
mContext
private ArrayList
mRemoteViewsList
private ArrayList
mViewTypes
private int
mViewTypeCount
Constructors Summary
public RemoteViewsListAdapter(android.content.Context context, ArrayList remoteViews, int viewTypeCount)


        
              
        mContext = context;
        mRemoteViewsList = remoteViews;
        mViewTypeCount = viewTypeCount;
        init();
    
Methods Summary
public intgetCount()

        if (mRemoteViewsList != null) {
            return mRemoteViewsList.size();
        } else {
            return 0;
        }
    
public java.lang.ObjectgetItem(int position)

        return null;
    
public longgetItemId(int position)

        return position;
    
public intgetItemViewType(int position)

        if (position < getCount()) {
            int layoutId = mRemoteViewsList.get(position).getLayoutId();
            return mViewTypes.indexOf(layoutId);
        } else {
            return 0;
        }
    
public android.view.ViewgetView(int position, android.view.View convertView, android.view.ViewGroup parent)

        if (position < getCount()) {
            RemoteViews rv = mRemoteViewsList.get(position);
            rv.setIsWidgetCollectionChild(true);
            View v;
            if (convertView != null && rv != null &&
                    convertView.getId() == rv.getLayoutId()) {
                v = convertView;
                rv.reapply(mContext, v);
            } else {
                v = rv.apply(mContext, parent);
            }
            return v;
        } else {
            return null;
        }
    
public intgetViewTypeCount()

        return mViewTypeCount;
    
public booleanhasStableIds()

        return false;
    
private voidinit()

        if (mRemoteViewsList == null) return;

        mViewTypes.clear();
        for (RemoteViews rv: mRemoteViewsList) {
            if (!mViewTypes.contains(rv.getLayoutId())) {
                mViewTypes.add(rv.getLayoutId());
            }
        }

        if (mViewTypes.size() > mViewTypeCount || mViewTypeCount < 1) {
            throw new RuntimeException("Invalid view type count -- view type count must be >= 1" +
                    "and must be as large as the total number of distinct view types");
        }
    
public voidsetViewsList(java.util.ArrayList remoteViews)

        mRemoteViewsList = remoteViews;
        init();
        notifyDataSetChanged();