obj.inflater = null;
obj.parent = null;
obj.resid = 0;
obj.view = null;
mRequestPool.release(obj);
}
使用方法,如下:
public class MyPooledClass {
private static final SynchronizedPool sPool =
new SynchronizedPool(10);
public static MyPooledClass obtain() {
MyPooledClass instance = sPool.acquire();
return (instance != null) ? instance : new MyPooledClass();
}
public void recycle() {
// Clear state if needed.
sPool.release(this);
}
}
[](()Pool接口的定义
来让我们看看这个Pool的接口,接口很简单,就2个方法。 acquire()主要是从缓存池中获取一个对象,这里可能为空。为空的情况:
[](()1,对象缓存池中没有缓存对象,这种情况是对象池中没有放进任何对象。
[](()2,对象池中对象被用完了。
release() 主要是释放一个对象到对象缓存池中,如果 《Android学习笔记总结+最新移动架