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