1 package com.bumptech.glide.load.resource.gif; 2 3 import android.content.Context; 4 5 import com.bumptech.glide.load.Encoder; 6 import com.bumptech.glide.load.ResourceDecoder; 7 import com.bumptech.glide.load.ResourceEncoder; 8 import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; 9 import com.bumptech.glide.load.model.StreamEncoder; 10 import com.bumptech.glide.load.resource.file.FileToStreamDecoder; 11 import com.bumptech.glide.provider.DataLoadProvider; 12 13 import java.io.File; 14 import java.io.InputStream; 15 16 /** 17 * An {@link com.bumptech.glide.provider.DataLoadProvider} that loads an {@link java.io.InputStream} into 18 * {@link com.bumptech.glide.load.resource.gif.GifDrawable} that can be used to display an animated GIF. 19 */ 20 public class GifDrawableLoadProvider implements DataLoadProvider<InputStream, GifDrawable> { 21 private final GifResourceDecoder decoder; 22 private final GifResourceEncoder encoder; 23 private final StreamEncoder sourceEncoder; 24 private final FileToStreamDecoder<GifDrawable> cacheDecoder; 25 26 public GifDrawableLoadProvider(Context context, BitmapPool bitmapPool) { 27 decoder = new GifResourceDecoder(context, bitmapPool); 28 cacheDecoder = new FileToStreamDecoder<GifDrawable>(decoder); 29 encoder = new GifResourceEncoder(bitmapPool); 30 sourceEncoder = new StreamEncoder(); 31 } 32 33 @Override 34 public ResourceDecoder<File, GifDrawable> getCacheDecoder() { 35 return cacheDecoder; 36 } 37 38 @Override 39 public ResourceDecoder<InputStream, GifDrawable> getSourceDecoder() { 40 return decoder; 41 } 42 43 @Override 44 public Encoder<InputStream> getSourceEncoder() { 45 return sourceEncoder; 46 } 47 48 @Override 49 public ResourceEncoder<GifDrawable> getEncoder() { 50 return encoder; 51 } 52 } 53