package com.airbnb.epoxy;

import X.6Is;
import X.AnonymousClass0CB;
import X.AnonymousClass0CH;
import X.AnonymousClass0CN;
import X.C04460Hc;
import X.C04600Hq;
import X.M12;
import android.content.Context;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import java.lang.ref.WeakReference;

public final class PoolReference implements 6Is {
    public final RecyclerView.RecycledViewPool LIZ;
    public final WeakReference<Context> LIZIZ;
    public final C04460Hc LIZJ;

    static {
        Covode.recordClassIndex(1955);
    }

    public final void onStateChanged(AnonymousClass0CH r2, AnonymousClass0CB r3) {
        if (r3 == AnonymousClass0CB.ON_DESTROY) {
            onContextDestroyed();
        }
    }

    public final Context LIZ() {
        return (Context) this.LIZIZ.get();
    }

    @AnonymousClass0CN(LIZ = AnonymousClass0CB.ON_DESTROY)
    public final void onContextDestroyed() {
        C04460Hc r1 = this.LIZJ;
        M12.LIZ(this);
        if (C04600Hq.LIZ(LIZ())) {
            this.LIZ.clear();
            r1.LIZ.remove(this);
        }
    }

    public PoolReference(Context context, RecyclerView.RecycledViewPool recycledViewPool, C04460Hc r4) {
        M12.LIZ(context, recycledViewPool, r4);
        this.LIZ = recycledViewPool;
        this.LIZJ = r4;
        this.LIZIZ = new WeakReference<>(context);
    }
}
