77 lines
2.6 KiB
Java
77 lines
2.6 KiB
Java
package com.bumptech.glide.load.model;
|
|
|
|
import android.util.Log;
|
|
import com.bumptech.glide.Priority;
|
|
import com.bumptech.glide.load.DataSource;
|
|
import com.bumptech.glide.load.Options;
|
|
import com.bumptech.glide.load.data.DataFetcher;
|
|
import com.bumptech.glide.load.model.ModelLoader;
|
|
import com.bumptech.glide.signature.ObjectKey;
|
|
import com.bumptech.glide.util.ByteBufferUtil;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.nio.ByteBuffer;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class ByteBufferFileLoader implements ModelLoader<File, ByteBuffer> {
|
|
|
|
public static class Factory implements ModelLoaderFactory<File, ByteBuffer> {
|
|
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
|
|
public ModelLoader<File, ByteBuffer> a(MultiModelLoaderFactory multiModelLoaderFactory) {
|
|
return new ByteBufferFileLoader();
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.model.ModelLoaderFactory
|
|
public void a() {
|
|
}
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.model.ModelLoader
|
|
public boolean a(File file) {
|
|
return true;
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.model.ModelLoader
|
|
public ModelLoader.LoadData<ByteBuffer> a(File file, int i, int i2, Options options) {
|
|
return new ModelLoader.LoadData<>(new ObjectKey(file), new ByteBufferFetcher(file));
|
|
}
|
|
|
|
private static final class ByteBufferFetcher implements DataFetcher<ByteBuffer> {
|
|
private final File a;
|
|
|
|
ByteBufferFetcher(File file) {
|
|
this.a = file;
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.data.DataFetcher
|
|
public void a(Priority priority, DataFetcher.DataCallback<? super ByteBuffer> dataCallback) {
|
|
try {
|
|
dataCallback.a((DataFetcher.DataCallback<? super ByteBuffer>) ByteBufferUtil.a(this.a));
|
|
} catch (IOException e) {
|
|
if (Log.isLoggable("ByteBufferFileLoader", 3)) {
|
|
Log.d("ByteBufferFileLoader", "Failed to obtain ByteBuffer for file", e);
|
|
}
|
|
dataCallback.a((Exception) e);
|
|
}
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.data.DataFetcher
|
|
public void b() {
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.data.DataFetcher
|
|
public void cancel() {
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.data.DataFetcher
|
|
public DataSource getDataSource() {
|
|
return DataSource.LOCAL;
|
|
}
|
|
|
|
@Override // com.bumptech.glide.load.data.DataFetcher
|
|
public Class<ByteBuffer> a() {
|
|
return ByteBuffer.class;
|
|
}
|
|
}
|
|
}
|