jimu-decompiled/sources/com/bumptech/glide/load/engine/EngineResource.java
2025-05-13 19:24:51 +02:00

100 lines
2.7 KiB
Java

package com.bumptech.glide.load.engine;
import android.os.Looper;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.util.Preconditions;
/* loaded from: classes.dex */
class EngineResource<Z> implements Resource<Z> {
private final boolean a;
private final boolean b;
private ResourceListener c;
private Key d;
private int e;
private boolean f;
private final Resource<Z> g;
interface ResourceListener {
void a(Key key, EngineResource<?> engineResource);
}
EngineResource(Resource<Z> resource, boolean z, boolean z2) {
Preconditions.a(resource);
this.g = resource;
this.a = z;
this.b = z2;
}
void a(Key key, ResourceListener resourceListener) {
this.d = key;
this.c = resourceListener;
}
@Override // com.bumptech.glide.load.engine.Resource
public Class<Z> b() {
return this.g.b();
}
void c() {
if (this.f) {
throw new IllegalStateException("Cannot acquire a recycled resource");
}
if (!Looper.getMainLooper().equals(Looper.myLooper())) {
throw new IllegalThreadStateException("Must call acquire on the main thread");
}
this.e++;
}
Resource<Z> d() {
return this.g;
}
boolean e() {
return this.a;
}
void f() {
if (this.e <= 0) {
throw new IllegalStateException("Cannot release a recycled or not yet acquired resource");
}
if (!Looper.getMainLooper().equals(Looper.myLooper())) {
throw new IllegalThreadStateException("Must call release on the main thread");
}
int i = this.e - 1;
this.e = i;
if (i == 0) {
this.c.a(this.d, this);
}
}
@Override // com.bumptech.glide.load.engine.Resource
public Z get() {
return this.g.get();
}
@Override // com.bumptech.glide.load.engine.Resource
public int getSize() {
return this.g.getSize();
}
public String toString() {
return "EngineResource{isCacheable=" + this.a + ", listener=" + this.c + ", key=" + this.d + ", acquired=" + this.e + ", isRecycled=" + this.f + ", resource=" + this.g + '}';
}
@Override // com.bumptech.glide.load.engine.Resource
public void a() {
if (this.e <= 0) {
if (!this.f) {
this.f = true;
if (this.b) {
this.g.a();
return;
}
return;
}
throw new IllegalStateException("Cannot recycle a resource that has already been recycled");
}
throw new IllegalStateException("Cannot recycle a resource while it is still acquired");
}
}