package com.bytedance.jedi.ext.adapter.internal;

import X.0Bt;
import X.0C9;
import X.0CB;
import X.0CD;
import X.0CH;
import X.0CN;
import X.1Bk;
import X.5An;
import X.6Is;
import X.7he;
import X.C0295Crj;
import X.C1327DVb;
import X.C2098DkM;
import X.C2179Dlf;
import X.C2182Dli;
import X.C2185Dll;
import X.KEM;
import X.M12;
import X.PMk;
import X.PMp;
import com.bytedance.covode.number.Covode;
import com.bytedance.jedi.ext.adapter.JediViewHolder;
import java.util.Collection;
import kotlin.h.b.n;

public final class JediViewHolderProxy implements C1327DVb, C2098DkM, 6Is {
    public static final /* synthetic */ PMp[] LIZ = {new PMk(KEM.LIZ.LIZ(JediViewHolderProxy.class), "lifecycleRegistry", "getLifecycleRegistry()Landroidx/lifecycle/LifecycleRegistry;")};
    public JediViewHolder<? extends 5An, ?> LIZIZ;
    public boolean LIZJ;
    public C2185Dll LIZLLL;
    public boolean LJ;
    public boolean LJFF = true;
    public final C0295Crj<0C9> LJI = 7he.LIZ(C2182Dli.LIZ);
    public boolean LJII;
    public final C0295Crj LJIIIIZZ = 7he.LIZ(new C2179Dlf(this));

    private final 1Bk LIZLLL() {
        return (1Bk) this.LJIIIIZZ.getValue();
    }

    public final void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_CREATE) {
            onCreate();
        } else if (r3 == 0CB.ON_START) {
            onStart();
        } else if (r3 == 0CB.ON_STOP) {
            onStop();
        } else if (r3 == 0CB.ON_DESTROY) {
            onDestroy();
        }
    }

    public final boolean LIZ() {
        return this.LJFF;
    }

    public final 0CH getLifecycleOwner() {
        return this;
    }

    public final 0CD getLifecycle() {
        return LIZLLL();
    }

    /* access modifiers changed from: private */
    /* renamed from: LIZJ */
    public JediViewHolder<? extends 5An, ?> getReceiver() {
        if (this.LIZJ) {
            return null;
        }
        return this.LIZIZ;
    }

    public final 0C9 LIZIZ() {
        return this.LJI.getValue();
    }

    @0CN(LIZ = 0CB.ON_CREATE)
    public final void onCreate() {
        this.LJ = false;
        LIZLLL().LIZ(0CB.ON_CREATE);
    }

    @0CN(LIZ = 0CB.ON_START)
    public final void onStart() {
        if (getReceiver() != null) {
            LIZ(true);
        }
    }

    @0CN(LIZ = 0CB.ON_STOP)
    public final void onStop() {
        if (getReceiver() != null) {
            LIZIZ(true);
        }
    }

    static {
        Covode.recordClassIndex(34919);
    }

    @0CN(LIZ = 0CB.ON_DESTROY)
    public final void onDestroy() {
        LIZLLL().LIZ(0CB.ON_DESTROY);
        if (this.LJI.isInitialized()) {
            0C9 LIZIZ2 = LIZIZ();
            Collection<0Bt> values = LIZIZ2.LIZ().values();
            n.LIZ(values, "");
            for (0Bt onCleared : values) {
                onCleared.onCleared();
            }
            LIZIZ2.LIZ().clear();
        }
        this.LJ = true;
    }

    public final String toString() {
        String str;
        StringBuilder sb = new StringBuilder("Proxy@");
        sb.append(Integer.toHexString(hashCode()));
        sb.append('(');
        sb.append("holder@");
        JediViewHolder<? extends 5An, ?> jediViewHolder = this.LIZIZ;
        if (jediViewHolder != null) {
            str = Integer.toHexString(jediViewHolder.hashCode());
        } else {
            str = null;
        }
        sb.append(str);
        sb.append(",detached:");
        sb.append(this.LIZJ);
        sb.append(",state:");
        sb.append(getLifecycle().LIZ());
        sb.append(')');
        return sb.toString();
    }

    public final void LIZIZ(boolean z) {
        this.LJFF = z;
        LIZLLL().LIZ(0CB.ON_STOP);
    }

    public final void LIZ(boolean z) {
        this.LJFF = z;
        if (!z) {
            this.LJII = true;
        }
        if (this.LJII) {
            LIZLLL().LIZ(0CB.ON_START);
        }
    }

    public final void LIZ(C2185Dll dll, JediViewHolder<? extends 5An, ?> jediViewHolder) {
        M12.LIZ(dll);
        if (jediViewHolder != null) {
            this.LIZIZ = jediViewHolder;
            jediViewHolder.LIZLLL = this;
            this.LIZJ = false;
            dll.LIZ(this);
            return;
        }
        this.LIZIZ = null;
    }
}
