All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.bumptech.glide.load.data.AssetFileDescriptorLocalUriFetcher Maven / Gradle / Ivy

Go to download

A fast and efficient image loading library for Android focused on smooth scrolling.

There is a newer version: 5.0.0-rc01
Show newest version
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;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy