
com.bumptech.glide.load.model.UrlUriLoader 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.
The newest version!
package com.bumptech.glide.load.model;
import android.net.Uri;
import androidx.annotation.NonNull;
import com.bumptech.glide.load.Options;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* Handles http/https Uris by delegating to the {@link ModelLoader} for {@link
* com.bumptech.glide.load.model.GlideUrl GlideUrls}.
*
* @param The type of data this Loader will obtain for a {@link Uri}.
*/
public class UrlUriLoader implements ModelLoader {
private static final Set SCHEMES =
Collections.unmodifiableSet(new HashSet<>(Arrays.asList("http", "https")));
private final ModelLoader urlLoader;
// Public API.
@SuppressWarnings("WeakerAccess")
public UrlUriLoader(ModelLoader urlLoader) {
this.urlLoader = urlLoader;
}
@Override
public LoadData buildLoadData(
@NonNull Uri uri, int width, int height, @NonNull Options options) {
GlideUrl glideUrl = new GlideUrl(uri.toString());
return urlLoader.buildLoadData(glideUrl, width, height, options);
}
@Override
public boolean handles(@NonNull Uri uri) {
return SCHEMES.contains(uri.getScheme());
}
/**
* Loads {@link java.io.InputStream InputStreams} from {@link android.net.Uri Uris} with http or
* https schemes.
*/
public static class StreamFactory implements ModelLoaderFactory {
@NonNull
@Override
public ModelLoader build(MultiModelLoaderFactory multiFactory) {
return new UrlUriLoader<>(multiFactory.build(GlideUrl.class, InputStream.class));
}
@Override
public void teardown() {
// Do nothing.
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy