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.StringLoader; 12 13 /** 14 * A {@link ModelLoader} For translating {@link String} models, such as file paths, into {@link ParcelFileDescriptor} 15 * data. 16 */ 17 public class FileDescriptorStringLoader extends StringLoader<ParcelFileDescriptor> 18 implements FileDescriptorModelLoader<String> { 19 20 /** 21 * The default factory for {@link com.bumptech.glide.load.model.file_descriptor.FileDescriptorStringLoader}s. 22 */ 23 public static class Factory implements ModelLoaderFactory<String, ParcelFileDescriptor> { 24 @Override 25 public ModelLoader<String, ParcelFileDescriptor> build(Context context, GenericLoaderFactory factories) { 26 return new FileDescriptorStringLoader(factories.buildModelLoader(Uri.class, ParcelFileDescriptor.class)); 27 } 28 29 @Override 30 public void teardown() { 31 // Do nothing. 32 } 33 } 34 35 public FileDescriptorStringLoader(Context context) { 36 this(Glide.buildFileDescriptorModelLoader(Uri.class, context)); 37 } 38 39 public FileDescriptorStringLoader(ModelLoader<Uri, ParcelFileDescriptor> uriLoader) { 40 super(uriLoader); 41 } 42 } 43