FileDocCategorySizeDatePackage
ViewPool.javaAPI DocAndroid 5.1 API2784Thu Mar 12 22:22:42 GMT 2015com.android.systemui.recents.views

ViewPool

public class ViewPool extends Object

Fields Summary
android.content.Context
mContext
ViewPoolConsumer
mViewCreator
LinkedList
mPool
Constructors Summary
public ViewPool(android.content.Context context, ViewPoolConsumer viewCreator)
Initializes the pool with a fixed predetermined pool size


              
          
        mContext = context;
        mViewCreator = viewCreator;
    
Methods Summary
VpickUpViewFromPool(T preferredData, T prepareData)
Gets a view from the pool and prepares it

        V v = null;
        boolean isNewView = false;
        if (mPool.isEmpty()) {
            v = mViewCreator.createView(mContext);
            isNewView = true;
        } else {
            // Try and find a preferred view
            Iterator<V> iter = mPool.iterator();
            while (iter.hasNext()) {
                V vpv = iter.next();
                if (mViewCreator.hasPreferredData(vpv, preferredData)) {
                    v = vpv;
                    iter.remove();
                    break;
                }
            }
            // Otherwise, just grab the first view
            if (v == null) {
                v = mPool.pop();
            }
        }
        mViewCreator.prepareViewToLeavePool(v, prepareData, isNewView);
        return v;
    
java.util.IteratorpoolViewIterator()
Returns an iterator to the list of the views in the pool.

        if (mPool != null) {
            return mPool.iterator();
        }
        return null;
    
voidreturnViewToPool(V v)
Returns a view into the pool

        mViewCreator.prepareViewToEnterPool(v);
        mPool.push(v);