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