Java 类android.support.v4.util.Pools.Pool 实例源码

项目:GitHub    文件:FactoryPools.java   
/**
 * Returns a new thread safe {@link Pool} that never returns {@code null} and that contains
 * {@link List Lists} of a specific generic type with the given maximum size.
 *
 * <p>If the pool is empty when {@link Pool#acquire()} is called, a new {@link List} will be
 * created.
 *
 * @param <T> The type of object that the {@link List Lists} will contain.
 */
// Public API.
@SuppressWarnings("WeakerAccess")
public static <T> Pool<List<T>> threadSafeList(int size) {
  return build(new SynchronizedPool<List<T>>(size), new Factory<List<T>>() {
    @Override
    public List<T> create() {
      return new ArrayList<>();
    }
  }, new Resetter<List<T>>() {
    @Override
    public void reset(List<T> object) {
      object.clear();
    }
  });
}
项目:GitHub    文件:DecodePath.java   
public DecodePath(Class<DataType> dataClass, Class<ResourceType> resourceClass,
    Class<Transcode> transcodeClass,
    List<? extends ResourceDecoder<DataType, ResourceType>> decoders,
    ResourceTranscoder<ResourceType, Transcode> transcoder, Pool<List<Exception>> listPool) {
  this.dataClass = dataClass;
  this.decoders = decoders;
  this.transcoder = transcoder;
  this.listPool = listPool;
  failureMessage = "Failed DecodePath{" + dataClass.getSimpleName() + "->"
      + resourceClass.getSimpleName() + "->" + transcodeClass.getSimpleName() + "}";
}
项目:GitHub    文件:LoadPath.java   
public LoadPath(Class<Data> dataClass, Class<ResourceType> resourceClass,
    Class<Transcode> transcodeClass,
    List<DecodePath<Data, ResourceType, Transcode>> decodePaths, Pool<List<Exception>> listPool) {
  this.dataClass = dataClass;
  this.listPool = listPool;
  this.decodePaths = Preconditions.checkNotEmpty(decodePaths);
  failureMessage = "Failed LoadPath{" + dataClass.getSimpleName() + "->"
      + resourceClass.getSimpleName() + "->" + transcodeClass.getSimpleName() + "}";
}
项目:GitHub    文件:FactoryPools.java   
/**
 * Returns a new thread safe {@link Pool} that never returns {@code null} and that contains
 * {@link List Lists} of a specific generic type with the given maximum size.
 *
 * <p>If the pool is empty when {@link Pool#acquire()} is called, a new {@link List} will be
 * created.
 *
 * @param <T> The type of object that the {@link List Lists} will contain.
 */
public static <T> Pool<List<T>> threadSafeList(int size) {
  return build(new SynchronizedPool<List<T>>(size), new Factory<List<T>>() {
    @Override
    public List<T> create() {
      return new ArrayList<>();
    }
  }, new Resetter<List<T>>() {
    @Override
    public void reset(List<T> object) {
      object.clear();
    }
  });
}
项目:GitHub    文件:DecodePath.java   
public DecodePath(Class<DataType> dataClass, Class<ResourceType> resourceClass,
    Class<Transcode> transcodeClass,
    List<? extends ResourceDecoder<DataType, ResourceType>> decoders,
    ResourceTranscoder<ResourceType, Transcode> transcoder, Pool<List<Throwable>> listPool) {
  this.dataClass = dataClass;
  this.decoders = decoders;
  this.transcoder = transcoder;
  this.listPool = listPool;
  failureMessage = "Failed DecodePath{" + dataClass.getSimpleName() + "->"
      + resourceClass.getSimpleName() + "->" + transcodeClass.getSimpleName() + "}";
}
项目:GitHub    文件:LoadPath.java   
public LoadPath(Class<Data> dataClass, Class<ResourceType> resourceClass,
    Class<Transcode> transcodeClass,
    List<DecodePath<Data, ResourceType, Transcode>> decodePaths, Pool<List<Throwable>> listPool) {
  this.dataClass = dataClass;
  this.listPool = listPool;
  this.decodePaths = Preconditions.checkNotEmpty(decodePaths);
  failureMessage = "Failed LoadPath{" + dataClass.getSimpleName() + "->"
      + resourceClass.getSimpleName() + "->" + transcodeClass.getSimpleName() + "}";
}
项目:GitHub    文件:ModelLoaderRegistry.java   
public ModelLoaderRegistry(Pool<List<Exception>> exceptionListPool) {
  this(new MultiModelLoaderFactory(exceptionListPool));
}
项目:GitHub    文件:MultiModelLoaderFactory.java   
public MultiModelLoaderFactory(Pool<List<Exception>> exceptionListPool) {
  this(exceptionListPool, DEFAULT_FACTORY);
}
项目:GitHub    文件:MultiModelLoaderFactory.java   
MultiModelLoaderFactory(Pool<List<Exception>> exceptionListPool,
    Factory factory) {
  this.exceptionListPool = exceptionListPool;
  this.factory = factory;
}
项目:GitHub    文件:MultiModelLoaderFactory.java   
public <Model, Data> MultiModelLoader<Model, Data> build(
    List<ModelLoader<Model, Data>> modelLoaders, Pool<List<Exception>> exceptionListPool) {
  return new MultiModelLoader<>(modelLoaders, exceptionListPool);
}
项目:GitHub    文件:MultiModelLoader.java   
MultiModelLoader(List<ModelLoader<Model, Data>> modelLoaders,
    Pool<List<Exception>> exceptionListPool) {
  this.modelLoaders = modelLoaders;
  this.exceptionListPool = exceptionListPool;
}
项目:GitHub    文件:MultiModelLoader.java   
MultiFetcher(List<DataFetcher<Data>> fetchers, Pool<List<Exception>> exceptionListPool) {
  this.exceptionListPool = exceptionListPool;
  Preconditions.checkNotEmpty(fetchers);
  this.fetchers = fetchers;
  currentIndex = 0;
}
项目:GitHub    文件:FactoryPools.java   
private static <T extends Poolable> Pool<T> build(Pool<T> pool, Factory<T> factory) {
  return build(pool, factory, FactoryPools.<T>emptyResetter());
}
项目:GitHub    文件:FactoryPools.java   
private static <T> Pool<T> build(Pool<T> pool, Factory<T> factory,
    Resetter<T> resetter) {
  return new FactoryPool<>(pool, factory, resetter);
}
项目:GitHub    文件:FactoryPools.java   
FactoryPool(Pool<T> pool, Factory<T> factory, Resetter<T> resetter) {
  this.pool = pool;
  this.factory = factory;
  this.resetter = resetter;
}
项目:GitHub    文件:ModelLoaderRegistry.java   
public ModelLoaderRegistry(Pool<List<Throwable>> throwableListPool) {
  this(new MultiModelLoaderFactory(throwableListPool));
}
项目:GitHub    文件:MultiModelLoaderFactory.java   
public MultiModelLoaderFactory(Pool<List<Throwable>> throwableListPool) {
  this(throwableListPool, DEFAULT_FACTORY);
}
项目:GitHub    文件:MultiModelLoaderFactory.java   
@VisibleForTesting
MultiModelLoaderFactory(Pool<List<Throwable>> throwableListPool,
    Factory factory) {
  this.throwableListPool = throwableListPool;
  this.factory = factory;
}
项目:GitHub    文件:MultiModelLoaderFactory.java   
public <Model, Data> MultiModelLoader<Model, Data> build(
    List<ModelLoader<Model, Data>> modelLoaders, Pool<List<Throwable>> throwableListPool) {
  return new MultiModelLoader<>(modelLoaders, throwableListPool);
}
项目:GitHub    文件:MultiModelLoader.java   
MultiModelLoader(List<ModelLoader<Model, Data>> modelLoaders,
    Pool<List<Throwable>> exceptionListPool) {
  this.modelLoaders = modelLoaders;
  this.exceptionListPool = exceptionListPool;
}
项目:GitHub    文件:MultiModelLoader.java   
MultiFetcher(List<DataFetcher<Data>> fetchers, Pool<List<Throwable>> throwableListPool) {
  this.throwableListPool = throwableListPool;
  Preconditions.checkNotEmpty(fetchers);
  this.fetchers = fetchers;
  currentIndex = 0;
}
项目:GitHub    文件:FactoryPools.java   
private static <T extends Poolable> Pool<T> build(Pool<T> pool, Factory<T> factory) {
  return build(pool, factory, FactoryPools.<T>emptyResetter());
}
项目:GitHub    文件:FactoryPools.java   
private static <T> Pool<T> build(Pool<T> pool, Factory<T> factory,
    Resetter<T> resetter) {
  return new FactoryPool<>(pool, factory, resetter);
}
项目:GitHub    文件:FactoryPools.java   
FactoryPool(Pool<T> pool, Factory<T> factory, Resetter<T> resetter) {
  this.pool = pool;
  this.factory = factory;
  this.resetter = resetter;
}
项目:GitHub    文件:FactoryPools.java   
/**
 * Returns a non-thread safe {@link Pool} that never returns {@code null} from
 * {@link Pool#acquire()} and that contains objects of the type created by the given
 * {@link Factory} with the given maximum size.
 *
 * <p>If the pool is empty when {@link Pool#acquire()} is called, the given {@link Factory} will
 * be used to create a new instance.
 *
 * @param <T> The type of object the pool will contains.
 */
public static <T extends Poolable> Pool<T> simple(int size, Factory<T> factory) {
  return build(new SimplePool<T>(size), factory);
}
项目:GitHub    文件:FactoryPools.java   
/**
 * Returns a new thread safe {@link Pool} that never returns {@code null} from
 * {@link Pool#acquire()} and that contains objects of the type created by the given
 * {@link Factory} with the given maximum size.
 *
 * <p>If the pool is empty when {@link Pool#acquire()} is called, the given {@link Factory} will
 * be used to create a new instance.
 *
 * @param <T> The type of object the pool will contains.
 */
public static <T extends Poolable> Pool<T> threadSafe(int size, Factory<T> factory) {
  return build(new SynchronizedPool<T>(size), factory);
}
项目:GitHub    文件:FactoryPools.java   
/**
 * Returns a new {@link Pool} that never returns {@code null} and that contains {@link List Lists}
 * of a specific generic type with a standard maximum size of 20.
 *
 * <p>If the pool is empty when {@link Pool#acquire()} is called, a new {@link List} will be
 * created.
 *
 * @param <T> The type of object that the {@link List Lists} will contain.
 */
public static <T> Pool<List<T>> threadSafeList() {
  return threadSafeList(DEFAULT_POOL_SIZE);
}
项目:GitHub    文件:FactoryPools.java   
/**
 * Returns a non-thread safe {@link Pool} that never returns {@code null} from
 * {@link Pool#acquire()} and that contains objects of the type created by the given
 * {@link Factory} with the given maximum size.
 *
 * <p>If the pool is empty when {@link Pool#acquire()} is called, the given {@link Factory} will
 * be used to create a new instance.
 *
 * @param <T> The type of object the pool will contains.
 */
public static <T extends Poolable> Pool<T> simple(int size, Factory<T> factory) {
  return build(new SimplePool<T>(size), factory);
}
项目:GitHub    文件:FactoryPools.java   
/**
 * Returns a new thread safe {@link Pool} that never returns {@code null} from
 * {@link Pool#acquire()} and that contains objects of the type created by the given
 * {@link Factory} with the given maximum size.
 *
 * <p>If the pool is empty when {@link Pool#acquire()} is called, the given {@link Factory} will
 * be used to create a new instance.
 *
 * @param <T> The type of object the pool will contains.
 */
public static <T extends Poolable> Pool<T> threadSafe(int size, Factory<T> factory) {
  return build(new SynchronizedPool<T>(size), factory);
}
项目:GitHub    文件:FactoryPools.java   
/**
 * Returns a new {@link Pool} that never returns {@code null} and that contains {@link List Lists}
 * of a specific generic type with a standard maximum size of 20.
 *
 * <p>If the pool is empty when {@link Pool#acquire()} is called, a new {@link List} will be
 * created.
 *
 * @param <T> The type of object that the {@link List Lists} will contain.
 */
public static <T> Pool<List<T>> threadSafeList() {
  return threadSafeList(DEFAULT_POOL_SIZE);
}