com.bumptech.glide.load.model.stream.MediaStoreStreamLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of glide Show documentation
Show all versions of glide Show documentation
A fast and efficient image loading library for Android focused on smooth scrolling.
package com.bumptech.glide.load.model.stream;
import android.content.Context;
import android.net.Uri;
import com.bumptech.glide.load.data.DataFetcher;
import com.bumptech.glide.load.data.MediaStoreThumbFetcher;
import com.bumptech.glide.load.model.ModelLoader;
import java.io.InputStream;
/**
* An {@link com.bumptech.glide.load.model.ModelLoader} that can use media store uris to open pre-generated thumbnails
* from the media store using {@link android.provider.MediaStore.Images.Thumbnails} and
* {@link android.provider.MediaStore.Video.Thumbnails} if the requested size is less than or equal to the media store
* thumbnail size. If the given uri is not a media store uri or if the desired dimensions are too large,
* it falls back to the wrapped {@link com.bumptech.glide.load.model.ModelLoader} to load the
* {@link java.io.InputStream} data.
*/
public class MediaStoreStreamLoader implements StreamModelLoader {
private final Context context;
private final ModelLoader uriLoader;
public MediaStoreStreamLoader(Context context, ModelLoader uriLoader) {
this.context = context;
this.uriLoader = uriLoader;
}
@Override
public DataFetcher getResourceFetcher(Uri model, int width, int height) {
return new MediaStoreThumbFetcher(context, model, uriLoader.getResourceFetcher(model, width, height), width,
height);
}
}