For a given com.bumptech.glide.load.data.DataFetcher for a given data class, attempts to fetch the data and then run it through one or more com.bumptech.glide.load.engine.DecodePaths. @param The type of data that will be fetched. @param The type of intermediate
| 21 | * of the decode paths succeeds. |
| 22 | */ |
| 23 | public class LoadPath<Data, ResourceType, Transcode> { |
| 24 | private final Class<Data> dataClass; |
| 25 | private final Pool<List<Throwable>> listPool; |
| 26 | private final List<? extends DecodePath<Data, ResourceType, Transcode>> decodePaths; |
| 27 | private final String failureMessage; |
| 28 | |
| 29 | public LoadPath( |
| 30 | Class<Data> dataClass, |
| 31 | Class<ResourceType> resourceClass, |
| 32 | Class<Transcode> transcodeClass, |
| 33 | List<DecodePath<Data, ResourceType, Transcode>> decodePaths, |
| 34 | Pool<List<Throwable>> listPool) { |
| 35 | this.dataClass = dataClass; |
| 36 | this.listPool = listPool; |
| 37 | this.decodePaths = Preconditions.checkNotEmpty(decodePaths); |
| 38 | failureMessage = |
| 39 | "Failed LoadPath{" |
| 40 | + dataClass.getSimpleName() |
| 41 | + "->" |
| 42 | + resourceClass.getSimpleName() |
| 43 | + "->" |
| 44 | + transcodeClass.getSimpleName() |
| 45 | + "}"; |
| 46 | } |
| 47 | |
| 48 | public Resource<Transcode> load( |
| 49 | DataRewinder<Data> rewinder, |
| 50 | @NonNull Options options, |
| 51 | int width, |
| 52 | int height, |
| 53 | DecodePath.DecodeCallback<ResourceType> decodeCallback) |
| 54 | throws GlideException { |
| 55 | List<Throwable> throwables = Preconditions.checkNotNull(listPool.acquire()); |
| 56 | try { |
| 57 | return loadWithExceptionList(rewinder, options, width, height, decodeCallback, throwables); |
| 58 | } finally { |
| 59 | listPool.release(throwables); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | private Resource<Transcode> loadWithExceptionList( |
| 64 | DataRewinder<Data> rewinder, |
| 65 | @NonNull Options options, |
| 66 | int width, |
| 67 | int height, |
| 68 | DecodePath.DecodeCallback<ResourceType> decodeCallback, |
| 69 | List<Throwable> exceptions) |
| 70 | throws GlideException { |
| 71 | Resource<Transcode> result = null; |
| 72 | //noinspection ForLoopReplaceableByForEach to improve perf |
| 73 | for (int i = 0, size = decodePaths.size(); i < size; i++) { |
| 74 | DecodePath<Data, ResourceType, Transcode> path = decodePaths.get(i); |
| 75 | try { |
| 76 | result = path.decode(rewinder, width, height, options, decodeCallback); |
| 77 | } catch (GlideException e) { |
| 78 | exceptions.add(e); |
| 79 | } |
| 80 | if (result != null) { |
nothing calls this directly
no outgoing calls
no test coverage detected