package com.bumptech.glide; import androidx.core.util.Pools$Pool; import com.bumptech.glide.load.Encoder; import com.bumptech.glide.load.ImageHeaderParser; import com.bumptech.glide.load.ResourceDecoder; import com.bumptech.glide.load.ResourceEncoder; import com.bumptech.glide.load.data.DataRewinder; import com.bumptech.glide.load.data.DataRewinderRegistry; import com.bumptech.glide.load.engine.DecodePath; import com.bumptech.glide.load.engine.LoadPath; import com.bumptech.glide.load.engine.Resource; import com.bumptech.glide.load.model.ModelLoader; import com.bumptech.glide.load.model.ModelLoaderFactory; import com.bumptech.glide.load.model.ModelLoaderRegistry; import com.bumptech.glide.load.resource.transcode.ResourceTranscoder; import com.bumptech.glide.load.resource.transcode.TranscoderRegistry; import com.bumptech.glide.provider.EncoderRegistry; import com.bumptech.glide.provider.ImageHeaderParserRegistry; import com.bumptech.glide.provider.LoadPathCache; import com.bumptech.glide.provider.ModelToResourceClassCache; import com.bumptech.glide.provider.ResourceDecoderRegistry; import com.bumptech.glide.provider.ResourceEncoderRegistry; import com.bumptech.glide.util.pool.FactoryPools; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; /* loaded from: classes.dex */ public class Registry { private final ModelToResourceClassCache h = new ModelToResourceClassCache(); private final LoadPathCache i = new LoadPathCache(); private final Pools$Pool> j = FactoryPools.b(); private final ModelLoaderRegistry a = new ModelLoaderRegistry(this.j); private final EncoderRegistry b = new EncoderRegistry(); private final ResourceDecoderRegistry c = new ResourceDecoderRegistry(); private final ResourceEncoderRegistry d = new ResourceEncoderRegistry(); private final DataRewinderRegistry e = new DataRewinderRegistry(); private final TranscoderRegistry f = new TranscoderRegistry(); private final ImageHeaderParserRegistry g = new ImageHeaderParserRegistry(); public static class MissingComponentException extends RuntimeException { public MissingComponentException(String str) { super(str); } } public static final class NoImageHeaderParserException extends MissingComponentException { public NoImageHeaderParserException() { super("Failed to find image header parser."); } } public static class NoModelLoaderAvailableException extends MissingComponentException { public NoModelLoaderAvailableException(Object obj) { super("Failed to find any ModelLoaders for model: " + obj); } public NoModelLoaderAvailableException(Class cls, Class cls2) { super("Failed to find any ModelLoaders for model: " + cls + " and data: " + cls2); } } public static class NoResultEncoderAvailableException extends MissingComponentException { public NoResultEncoderAvailableException(Class cls) { super("Failed to find result encoder for resource class: " + cls + ", you may need to consider registering a new Encoder for the requested type or DiskCacheStrategy.DATA/DiskCacheStrategy.NONE if caching your transformed resource is unnecessary."); } } public static class NoSourceEncoderAvailableException extends MissingComponentException { public NoSourceEncoderAvailableException(Class cls) { super("Failed to find source encoder for data class: " + cls); } } public Registry() { a(Arrays.asList("Gif", "Bitmap", "BitmapDrawable")); } private List> c(Class cls, Class cls2, Class cls3) { ArrayList arrayList = new ArrayList(); for (Class cls4 : this.c.b(cls, cls2)) { for (Class cls5 : this.f.b(cls4, cls3)) { arrayList.add(new DecodePath(cls, cls4, cls5, this.c.a(cls, cls4), this.f.a(cls4, cls5), this.j)); } } return arrayList; } public Registry a(Class cls, Encoder encoder) { this.b.a(cls, encoder); return this; } public Registry b(Class cls, Class cls2, ModelLoaderFactory modelLoaderFactory) { this.a.b(cls, cls2, modelLoaderFactory); return this; } public Registry a(Class cls, Class cls2, ResourceDecoder resourceDecoder) { a("legacy_append", cls, cls2, resourceDecoder); return this; } public List> b(Class cls, Class cls2, Class cls3) { List> a = this.h.a(cls, cls2); if (a == null) { a = new ArrayList<>(); Iterator> it = this.a.a((Class) cls).iterator(); while (it.hasNext()) { for (Class cls4 : this.c.b(it.next(), cls2)) { if (!this.f.b(cls4, cls3).isEmpty() && !a.contains(cls4)) { a.add(cls4); } } } this.h.a(cls, cls2, Collections.unmodifiableList(a)); } return a; } public Registry a(String str, Class cls, Class cls2, ResourceDecoder resourceDecoder) { this.c.a(str, resourceDecoder, cls, cls2); return this; } public final Registry a(List list) { ArrayList arrayList = new ArrayList(list); arrayList.add(0, "legacy_prepend_all"); arrayList.add("legacy_append"); this.c.a(arrayList); return this; } public Registry a(Class cls, ResourceEncoder resourceEncoder) { this.d.a(cls, resourceEncoder); return this; } public Registry a(DataRewinder.Factory factory) { this.e.a(factory); return this; } public Registry a(Class cls, Class cls2, ResourceTranscoder resourceTranscoder) { this.f.a(cls, cls2, resourceTranscoder); return this; } public Registry a(ImageHeaderParser imageHeaderParser) { this.g.a(imageHeaderParser); return this; } public Registry a(Class cls, Class cls2, ModelLoaderFactory modelLoaderFactory) { this.a.a(cls, cls2, modelLoaderFactory); return this; } public LoadPath a(Class cls, Class cls2, Class cls3) { LoadPath a = this.i.a(cls, cls2, cls3); if (this.i.a(a)) { return null; } if (a == null) { List> c = c(cls, cls2, cls3); a = c.isEmpty() ? null : new LoadPath<>(cls, cls2, cls3, c, this.j); this.i.a(cls, cls2, cls3, a); } return a; } public Encoder c(X x) throws NoSourceEncoderAvailableException { Encoder a = this.b.a(x.getClass()); if (a != null) { return a; } throw new NoSourceEncoderAvailableException(x.getClass()); } public boolean b(Resource resource) { return this.d.a(resource.b()) != null; } public DataRewinder b(X x) { return this.e.a((DataRewinderRegistry) x); } public ResourceEncoder a(Resource resource) throws NoResultEncoderAvailableException { ResourceEncoder a = this.d.a(resource.b()); if (a != null) { return a; } throw new NoResultEncoderAvailableException(resource.b()); } public List> a(Model model) { List> a = this.a.a((ModelLoaderRegistry) model); if (a.isEmpty()) { throw new NoModelLoaderAvailableException(model); } return a; } public List a() { List a = this.g.a(); if (a.isEmpty()) { throw new NoImageHeaderParserException(); } return a; } }