1 package com.bumptech.glide.load.model.file_descriptor; 2 3 import android.content.Context; 4 import android.net.Uri; 5 import android.os.ParcelFileDescriptor; 6 7 import com.bumptech.glide.Glide; 8 import com.bumptech.glide.load.model.GenericLoaderFactory; 9 import com.bumptech.glide.load.model.ModelLoader; 10 import com.bumptech.glide.load.model.ModelLoaderFactory; 11 import com.bumptech.glide.load.model.ResourceLoader; 12 13 /** 14 * A {@link ModelLoader} For translating android resource id models into {@link ParcelFileDescriptor} data. 15 */ 16 public class FileDescriptorResourceLoader extends ResourceLoader<ParcelFileDescriptor> 17 implements FileDescriptorModelLoader<Integer> { 18 19 /** 20 * The default factory for {@link com.bumptech.glide.load.model.file_descriptor.FileDescriptorResourceLoader}s. 21 */ 22 public static class Factory implements ModelLoaderFactory<Integer, ParcelFileDescriptor> { 23 24 @Override 25 public ModelLoader<Integer, ParcelFileDescriptor> build(Context context, GenericLoaderFactory factories) { 26 return new FileDescriptorResourceLoader(context, factories.buildModelLoader(Uri.class, 27 ParcelFileDescriptor.class)); 28 } 29 30 @Override 31 public void teardown() { 32 // Do nothing. 33 } 34 } 35 36 public FileDescriptorResourceLoader(Context context) { 37 this(context, Glide.buildFileDescriptorModelLoader(Uri.class, context)); 38 } 39 40 public FileDescriptorResourceLoader(Context context, ModelLoader<Uri, ParcelFileDescriptor> uriLoader) { 41 super(context, uriLoader); 42 } 43 } 44