68 lines
2.1 KiB
Java
68 lines
2.1 KiB
Java
package com.bumptech.glide.load.data;
|
|
|
|
import com.bumptech.glide.load.data.DataRewinder;
|
|
import com.bumptech.glide.util.Preconditions;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class DataRewinderRegistry {
|
|
private static final DataRewinder.Factory<?> b = new DataRewinder.Factory<Object>() { // from class: com.bumptech.glide.load.data.DataRewinderRegistry.1
|
|
@Override // com.bumptech.glide.load.data.DataRewinder.Factory
|
|
public DataRewinder<Object> a(Object obj) {
|
|
return new DefaultRewinder(obj);
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.data.DataRewinder.Factory
|
|
public Class<Object> a() {
|
|
throw new UnsupportedOperationException("Not implemented");
|
|
}
|
|
};
|
|
private final Map<Class<?>, DataRewinder.Factory<?>> a = new HashMap();
|
|
|
|
private static final class DefaultRewinder implements DataRewinder<Object> {
|
|
private final Object a;
|
|
|
|
DefaultRewinder(Object obj) {
|
|
this.a = obj;
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.data.DataRewinder
|
|
public Object a() {
|
|
return this.a;
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.data.DataRewinder
|
|
public void b() {
|
|
}
|
|
}
|
|
|
|
public synchronized void a(DataRewinder.Factory<?> factory) {
|
|
this.a.put(factory.a(), factory);
|
|
}
|
|
|
|
public synchronized <T> DataRewinder<T> a(T t) {
|
|
DataRewinder.Factory<?> factory;
|
|
Preconditions.a(t);
|
|
factory = this.a.get(t.getClass());
|
|
if (factory == null) {
|
|
Iterator<DataRewinder.Factory<?>> it = this.a.values().iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
DataRewinder.Factory<?> next = it.next();
|
|
if (next.a().isAssignableFrom(t.getClass())) {
|
|
factory = next;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (factory == null) {
|
|
factory = b;
|
|
}
|
|
return (DataRewinder<T>) factory.a(t);
|
|
}
|
|
}
|