package com.bumptech.glide.util.pool; import android.util.Log; import androidx.core.util.Pools$Pool; import androidx.core.util.Pools$SimplePool; import androidx.core.util.Pools$SynchronizedPool; import java.util.ArrayList; import java.util.List; /* loaded from: classes.dex */ public final class FactoryPools { private static final Resetter a = new Resetter() { // from class: com.bumptech.glide.util.pool.FactoryPools.1 @Override // com.bumptech.glide.util.pool.FactoryPools.Resetter public void a(Object obj) { } }; public interface Factory { T a(); } public interface Poolable { StateVerifier c(); } public interface Resetter { void a(T t); } public static Pools$Pool a(int i, Factory factory) { return a(new Pools$SimplePool(i), factory); } public static Pools$Pool b(int i, Factory factory) { return a(new Pools$SynchronizedPool(i), factory); } public static Pools$Pool> a(int i) { return a(new Pools$SynchronizedPool(i), new Factory>() { // from class: com.bumptech.glide.util.pool.FactoryPools.2 @Override // com.bumptech.glide.util.pool.FactoryPools.Factory public List a() { return new ArrayList(); } }, new Resetter>() { // from class: com.bumptech.glide.util.pool.FactoryPools.3 @Override // com.bumptech.glide.util.pool.FactoryPools.Resetter public void a(List list) { list.clear(); } }); } public static Pools$Pool> b() { return a(20); } private static Pools$Pool a(Pools$Pool pools$Pool, Factory factory) { return a(pools$Pool, factory, a()); } private static Pools$Pool a(Pools$Pool pools$Pool, Factory factory, Resetter resetter) { return new FactoryPool(pools$Pool, factory, resetter); } private static Resetter a() { return (Resetter) a; } private static final class FactoryPool implements Pools$Pool { private final Factory a; private final Resetter b; private final Pools$Pool c; FactoryPool(Pools$Pool pools$Pool, Factory factory, Resetter resetter) { this.c = pools$Pool; this.a = factory; this.b = resetter; } @Override // androidx.core.util.Pools$Pool public T a() { T a = this.c.a(); if (a == null) { a = this.a.a(); if (Log.isLoggable("FactoryPools", 2)) { Log.v("FactoryPools", "Created new " + a.getClass()); } } if (a instanceof Poolable) { a.c().a(false); } return (T) a; } @Override // androidx.core.util.Pools$Pool public boolean a(T t) { if (t instanceof Poolable) { ((Poolable) t).c().a(true); } this.b.a(t); return this.c.a(t); } } }