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