![JAR search and dependency download from the Maven repository](/logo.png)
com.bumptech.glide.load.model.stream.MediaStoreImageThumbLoader 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.Options;
import com.bumptech.glide.load.data.mediastore.MediaStoreUtil;
import com.bumptech.glide.load.data.mediastore.ThumbFetcher;
import com.bumptech.glide.load.model.ModelLoader;
import com.bumptech.glide.load.model.ModelLoaderFactory;
import com.bumptech.glide.load.model.MultiModelLoaderFactory;
import com.bumptech.glide.signature.ObjectKey;
import java.io.InputStream;
/**
* Loads {@link InputStream}s from media store image {@link Uri}s that point to pre-generated
* thumbnails for those {@link Uri}s in the media store.
*/
public class MediaStoreImageThumbLoader implements ModelLoader {
public final Context context;
public MediaStoreImageThumbLoader(Context context) {
this.context = context.getApplicationContext();
}
@Override
public LoadData buildLoadData(Uri model, int width, int height, Options options) {
if (MediaStoreUtil.isThumbnailSize(width, height)) {
return new LoadData<>(new ObjectKey(model), ThumbFetcher.buildImageFetcher(context, model));
} else {
return null;
}
}
@Override
public boolean handles(Uri model) {
return MediaStoreUtil.isMediaStoreImageUri(model);
}
/**
* Factory that loads {@link InputStream}s from media store image {@link Uri}s.
*/
public static class Factory implements ModelLoaderFactory {
private final Context context;
public Factory(Context context) {
this.context = context;
}
@Override
public ModelLoader build(MultiModelLoaderFactory multiFactory) {
return new MediaStoreImageThumbLoader(context);
}
@Override
public void teardown() {
// Do nothing.
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy