com.bumptech.glide.load.data.AssetFileDescriptorLocalUriFetcher 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.data;
import android.content.ContentResolver;
import android.content.res.AssetFileDescriptor;
import android.net.Uri;
import androidx.annotation.NonNull;
import java.io.FileNotFoundException;
import java.io.IOException;
/** Fetches an {@link AssetFileDescriptor} for a local {@link android.net.Uri}. */
public final class AssetFileDescriptorLocalUriFetcher extends LocalUriFetcher {
public AssetFileDescriptorLocalUriFetcher(ContentResolver contentResolver, Uri uri) {
super(contentResolver, uri);
}
@Override
protected AssetFileDescriptor loadResource(Uri uri, ContentResolver contentResolver)
throws FileNotFoundException {
AssetFileDescriptor result = contentResolver.openAssetFileDescriptor(uri, "r");
if (result == null) {
throw new FileNotFoundException("FileDescriptor is null for: " + uri);
}
return result;
}
@Override
protected void close(AssetFileDescriptor data) throws IOException {
data.close();
}
@NonNull
@Override
public Class getDataClass() {
return AssetFileDescriptor.class;
}
}