package coil.memory;

import coil.memory.MemoryCache;
import coil.util.Collections;
import java.util.Set;
import x4.AbstractC3233J;

/* JADX INFO: loaded from: classes.dex */
public final class RealMemoryCache implements MemoryCache {
    private final StrongMemoryCache strongMemoryCache;
    private final WeakMemoryCache weakMemoryCache;

    public RealMemoryCache(StrongMemoryCache strongMemoryCache, WeakMemoryCache weakMemoryCache) {
        this.strongMemoryCache = strongMemoryCache;
        this.weakMemoryCache = weakMemoryCache;
    }

    @Override // coil.memory.MemoryCache
    public void clear() {
        this.strongMemoryCache.clearMemory();
        this.weakMemoryCache.clearMemory();
    }

    @Override // coil.memory.MemoryCache
    public MemoryCache.Value get(MemoryCache.Key key) {
        MemoryCache.Value value = this.strongMemoryCache.get(key);
        return value == null ? this.weakMemoryCache.get(key) : value;
    }

    @Override // coil.memory.MemoryCache
    public Set<MemoryCache.Key> getKeys() {
        return AbstractC3233J.s(this.strongMemoryCache.getKeys(), this.weakMemoryCache.getKeys());
    }

    @Override // coil.memory.MemoryCache
    public int getMaxSize() {
        return this.strongMemoryCache.getMaxSize();
    }

    @Override // coil.memory.MemoryCache
    public int getSize() {
        return this.strongMemoryCache.getSize();
    }

    @Override // coil.memory.MemoryCache
    public boolean remove(MemoryCache.Key key) {
        return this.strongMemoryCache.remove(key) || this.weakMemoryCache.remove(key);
    }

    @Override // coil.memory.MemoryCache
    public void set(MemoryCache.Key key, MemoryCache.Value value) {
        this.strongMemoryCache.set(MemoryCache.Key.copy$default(key, null, Collections.toImmutableMap(key.getExtras()), 1, null), value.getBitmap(), Collections.toImmutableMap(value.getExtras()));
    }

    @Override // coil.memory.MemoryCache
    public void trimMemory(int i6) {
        this.strongMemoryCache.trimMemory(i6);
        this.weakMemoryCache.trimMemory(i6);
    }
}
