1 package com.bumptech.glide.load.resource.bitmap; 2 3 import android.graphics.Bitmap; 4 import android.os.ParcelFileDescriptor; 5 6 import com.bumptech.glide.load.DecodeFormat; 7 import com.bumptech.glide.load.Encoder; 8 import com.bumptech.glide.load.ResourceDecoder; 9 import com.bumptech.glide.load.ResourceEncoder; 10 import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; 11 import com.bumptech.glide.load.resource.NullEncoder; 12 import com.bumptech.glide.load.resource.file.FileToStreamDecoder; 13 import com.bumptech.glide.provider.DataLoadProvider; 14 15 import java.io.File; 16 17 /** 18 * An {@link com.bumptech.glide.provider.DataLoadProvider} that provides classes for decoding and encoding 19 * {@link android.graphics.Bitmap}s from {@link android.os.ParcelFileDescriptor} data. 20 */ 21 public class FileDescriptorBitmapDataLoadProvider implements DataLoadProvider<ParcelFileDescriptor, Bitmap> { 22 private final ResourceDecoder<File, Bitmap> cacheDecoder; 23 private final FileDescriptorBitmapDecoder sourceDecoder; 24 private final BitmapEncoder encoder; 25 private final Encoder<ParcelFileDescriptor> sourceEncoder; 26 27 public FileDescriptorBitmapDataLoadProvider(BitmapPool bitmapPool, DecodeFormat decodeFormat) { 28 cacheDecoder = new FileToStreamDecoder<Bitmap>(new StreamBitmapDecoder(bitmapPool, decodeFormat)); 29 sourceDecoder = new FileDescriptorBitmapDecoder(bitmapPool, decodeFormat); 30 encoder = new BitmapEncoder(); 31 sourceEncoder = NullEncoder.get(); 32 } 33 34 @Override 35 public ResourceDecoder<File, Bitmap> getCacheDecoder() { 36 return cacheDecoder; 37 } 38 39 @Override 40 public ResourceDecoder<ParcelFileDescriptor, Bitmap> getSourceDecoder() { 41 return sourceDecoder; 42 } 43 44 @Override 45 public Encoder<ParcelFileDescriptor> getSourceEncoder() { 46 return sourceEncoder; 47 } 48 49 @Override 50 public ResourceEncoder<Bitmap> getEncoder() { 51 return encoder; 52 } 53 } 54