package com.bytedance.jedi.ext.adapter;

import X.0CB;
import X.0CD;
import X.0CH;
import X.0CN;
import X.1Bk;
import X.2Pr;
import X.2cN;
import X.5Am;
import X.5An;
import X.6Is;
import X.7he;
import X.7xU;
import X.B8T;
import X.C0295Crj;
import X.C0435Cwt;
import X.C0436Cwu;
import X.C0643D4t;
import X.C1324DUy;
import X.C1325DUz;
import X.C2098DkM;
import X.C2176Dlc;
import X.C2178Dle;
import X.C2181Dlh;
import X.C2183Dlj;
import X.C2184Dlk;
import X.C2186Dlm;
import X.C2193Dlt;
import X.CvE;
import X.DRZ;
import X.DUT;
import X.DV0;
import X.DV9;
import X.KEM;
import X.LsC;
import X.LsD;
import X.LsE;
import X.LsF;
import X.Lsh;
import X.M12;
import X.PHD;
import X.PMk;
import X.PMp;
import android.view.View;
import com.bytedance.covode.number.Covode;
import com.bytedance.jedi.arch.JediViewModel;
import com.bytedance.jedi.ext.adapter.internal.JediViewHolderProxy;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import kotlin.h.b.n;

public abstract class JediViewHolder<R extends 5An, ITEM> extends C2176Dlc<ITEM> implements 0CH, C2181Dlh<R>, 6Is {
    public static final /* synthetic */ PMp[] LIZ = {new PMk(KEM.LIZ.LIZ(JediViewHolder.class), "lifecycleRegistry", "getLifecycleRegistry()Landroidx/lifecycle/LifecycleRegistry;")};
    public 0CH LIZIZ;
    public C2184Dlk LIZJ;
    public JediViewHolderProxy LIZLLL;
    public boolean LJ;
    public final C0295Crj LJFF = 7he.LIZ(new C2178Dle(this));

    private final 1Bk LJIILIIL() {
        return (1Bk) this.LJFF.getValue();
    }

    public void LIZ(List<Object> list) {
    }

    public final void LIZIZ(ITEM item) {
    }

    public void LJ() {
    }

    public void LJFF() {
    }

    public void LJI() {
    }

    public void LJII() {
    }

    public void LJIIIIZZ() {
    }

    public void LJIIIZ() {
    }

    public boolean getUniqueOnlyGlobal() {
        return false;
    }

    public void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_CREATE) {
            create$ext_adapter_release();
        } else if (r3 == 0CB.ON_START) {
            start$ext_adapter_release();
        } else if (r3 == 0CB.ON_RESUME) {
            resume$ext_adapter_release();
        } else if (r3 == 0CB.ON_PAUSE) {
            pause$ext_adapter_release();
        } else if (r3 == 0CB.ON_STOP) {
            stop$ext_adapter_release();
        } else if (r3 == 0CB.ON_DESTROY) {
            destroy$ext_adapter_release();
        }
    }

    public final C2098DkM bf_() {
        return this.LIZLLL;
    }

    public 0CD getLifecycle() {
        return LJIILIIL();
    }

    private final C2183Dlj LJIIL() {
        C2184Dlk dlk = this.LIZJ;
        if (dlk == null) {
            n.LIZ("");
        }
        return dlk.LIZIZ;
    }

    public final 0CH LJIIJ() {
        0CH r1 = this.LIZIZ;
        if (r1 == null) {
            n.LIZ("");
        }
        return r1;
    }

    @0CN(LIZ = 0CB.ON_DESTROY)
    public final void destroy$ext_adapter_release() {
        LJIIIZ();
        LJIILJJIL();
        LJIILIIL().LIZ(0CB.ON_DESTROY);
    }

    public C1325DUz getLifecycleOwnerHolder() {
        C2098DkM bf_ = bf_();
        if (bf_ != null) {
            return bf_;
        }
        throw new 7xU("null cannot be cast to non-null type com.bytedance.jedi.arch.LifecycleOwnerHolder");
    }

    public C1324DUy<R> getReceiverHolder() {
        C2098DkM bf_ = bf_();
        if (bf_ != null) {
            return bf_;
        }
        throw new 7xU("null cannot be cast to non-null type com.bytedance.jedi.arch.ReceiverHolder<VH>");
    }

    static {
        Covode.recordClassIndex(34812);
    }

    private final void LJIILJJIL() {
        0CH r1 = this.LIZIZ;
        if (r1 == null) {
            n.LIZ("");
        }
        r1.getLifecycle().LIZIZ(this);
        LJIILL();
    }

    public void bu_() {
        super.bu_();
        JediViewHolderProxy jediViewHolderProxy = this.LIZLLL;
        if (jediViewHolderProxy != null && this == jediViewHolderProxy.LIZIZ) {
            jediViewHolderProxy.LIZJ = true;
        }
        LJIILL();
    }

    @0CN(LIZ = 0CB.ON_PAUSE)
    public final void pause$ext_adapter_release() {
        if (this.LJ) {
            LJII();
            LJIILIIL().LIZ(0CB.ON_PAUSE);
        }
    }

    @0CN(LIZ = 0CB.ON_RESUME)
    public final void resume$ext_adapter_release() {
        if (this.LJ) {
            LJI();
            LJIILIIL().LIZ(0CB.ON_RESUME);
        }
    }

    @0CN(LIZ = 0CB.ON_START)
    public final void start$ext_adapter_release() {
        if (this.LJ) {
            LJFF();
            LJIILIIL().LIZ(0CB.ON_START);
            JediViewHolderProxy jediViewHolderProxy = this.LIZLLL;
            if (jediViewHolderProxy != null && this == jediViewHolderProxy.LIZIZ) {
                jediViewHolderProxy.LIZ(false);
            }
        }
    }

    @0CN(LIZ = 0CB.ON_STOP)
    public final void stop$ext_adapter_release() {
        if (this.LJ) {
            LJIIIIZZ();
            LJIILIIL().LIZ(0CB.ON_STOP);
            JediViewHolderProxy jediViewHolderProxy = this.LIZLLL;
            if (jediViewHolderProxy != null && this == jediViewHolderProxy.LIZIZ) {
                jediViewHolderProxy.LIZIZ(false);
            }
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:5:0x0017, code lost:
        if (r1 != 3) goto L_0x0019;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private final void LJIILL() {
        /*
            r2 = this;
            X.0CD r0 = r2.getLifecycle()
            X.0CC r0 = r0.LIZ()
            int[] r1 = X.CvE.LIZIZ
            int r0 = r0.ordinal()
            r1 = r1[r0]
            r0 = 1
            if (r1 == r0) goto L_0x001d
            r0 = 2
            if (r1 == r0) goto L_0x0020
            r0 = 3
            if (r1 == r0) goto L_0x0020
        L_0x0019:
            r0 = 0
            r2.LJ = r0
            return
        L_0x001d:
            r2.pause$ext_adapter_release()
        L_0x0020:
            r2.stop$ext_adapter_release()
            goto L_0x0019
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.jedi.ext.adapter.JediViewHolder.LJIILL():void");
    }

    @0CN(LIZ = 0CB.ON_CREATE)
    public final void create$ext_adapter_release() {
        C2183Dlj LJIIL = LJIIL();
        int i = this.LJIIIIZZ;
        if (i < 0 || i >= LJIIL.LIZ.size() || !LJIIL.LIZ.get(i).booleanValue()) {
            LJ();
            LJIIL().LIZ(this.LJIIIIZZ, true);
            LJIILIIL().LIZ(0CB.ON_CREATE);
        }
    }

    public void dj_() {
        super.dj_();
        JediViewHolderProxy jediViewHolderProxy = this.LIZLLL;
        if (jediViewHolderProxy != null && this == jediViewHolderProxy.LIZIZ) {
            jediViewHolderProxy.LIZJ = false;
        }
        this.LJ = true;
        int i = CvE.LIZ[getLifecycle().LIZ().ordinal()];
        if (i == 2) {
            start$ext_adapter_release();
            resume$ext_adapter_release();
        } else if (i == 3) {
            resume$ext_adapter_release();
        }
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public JediViewHolder(View view) {
        super(view);
        M12.LIZ(view);
    }

    public <VM1 extends JediViewModel<S1>, S1 extends 5Am, R> R withState(VM1 vm1, LsC<? super S1, ? extends R> lsC) {
        M12.LIZ(vm1, lsC);
        M12.LIZ(vm1, lsC);
        return DV0.LIZ(vm1, lsC);
    }

    public <S extends 5Am> 2cN subscribe(JediViewModel<S> jediViewModel, DUT<S> dut, LsD<? super R, ? super S, 2Pr> lsD) {
        M12.LIZ(jediViewModel, dut, lsD);
        M12.LIZ(jediViewModel, dut, lsD);
        return DV0.LIZ(this, jediViewModel, dut, lsD);
    }

    public final void LIZIZ(ITEM item, int i, List<Object> list) {
        JediViewHolderProxy jediViewHolderProxy;
        Object obj;
        super.LIZIZ(item, i, list);
        if (list != null && (!(list instanceof Collection) || !list.isEmpty())) {
            Iterator<T> it = list.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                T next = it.next();
                if (!(next instanceof C0436Cwu)) {
                    next = null;
                }
                C0436Cwu cwu = (C0436Cwu) next;
                if (cwu != null) {
                    obj = cwu.getSecond();
                } else {
                    obj = null;
                }
                if (obj == C2193Dlt.LIZ) {
                    break;
                }
            }
        }
        this.LJ = true;
        LJIILJJIL();
        C2184Dlk dlk = this.LIZJ;
        if (dlk == null) {
            n.LIZ("");
        }
        C2186Dlm dlm = dlk.LIZJ;
        if (i < 0 || i >= dlm.LIZ.size() || (jediViewHolderProxy = dlm.LIZ.get(i)) == null) {
            jediViewHolderProxy = (JediViewHolderProxy) dlk.LIZ.invoke();
            dlk.LIZJ.LIZ(i, jediViewHolderProxy);
        }
        JediViewHolderProxy jediViewHolderProxy2 = this.LIZLLL;
        if (!(jediViewHolderProxy == jediViewHolderProxy2 || jediViewHolderProxy2 == null || this != jediViewHolderProxy2.LIZIZ)) {
            C2184Dlk dlk2 = this.LIZJ;
            if (dlk2 == null) {
                n.LIZ("");
            }
            jediViewHolderProxy2.LIZ(dlk2.LIZLLL, (JediViewHolder<? extends 5An, ?>) null);
        }
        C2184Dlk dlk3 = this.LIZJ;
        if (dlk3 == null) {
            n.LIZ("");
        }
        jediViewHolderProxy.LIZ(dlk3.LIZLLL, this);
        this.LJ = true;
        0CH r0 = this.LIZIZ;
        if (r0 == null) {
            n.LIZ("");
        }
        r0.getLifecycle().LIZ(this);
        LIZ(list);
    }

    public <S extends 5Am, A> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, DUT<DRZ<A>> dut, LsD<? super R, ? super A, 2Pr> lsD) {
        M12.LIZ(jediViewModel, phd, dut, lsD);
        M12.LIZ(jediViewModel, phd, dut, lsD);
        return DV0.LIZ(this, jediViewModel, phd, dut, lsD);
    }

    public <S extends 5Am, A, B> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, DUT<C0435Cwt<A, B>> dut, LsE<? super R, ? super A, ? super B, 2Pr> lsE) {
        PHD<S, ? extends A> phd3 = phd;
        JediViewModel<S> jediViewModel2 = jediViewModel;
        PHD<S, ? extends B> phd4 = phd2;
        LsE<? super R, ? super A, ? super B, 2Pr> lsE2 = lsE;
        DUT<C0435Cwt<A, B>> dut2 = dut;
        M12.LIZ(jediViewModel2, phd3, phd4, dut2, lsE2);
        M12.LIZ(jediViewModel2, phd3, phd4, dut2, lsE2);
        return DV0.LIZ(this, jediViewModel2, phd3, phd4, dut2, lsE2);
    }

    public <S extends 5Am, T> 2cN asyncSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends B8T<? extends T>> phd, DUT<DRZ<B8T<T>>> dut, LsD<? super R, ? super Throwable, 2Pr> lsD, LsC<? super R, 2Pr> lsC, LsD<? super R, ? super T, 2Pr> lsD2) {
        PHD<S, ? extends B8T<? extends T>> phd2 = phd;
        JediViewModel<S> jediViewModel2 = jediViewModel;
        DUT<DRZ<B8T<T>>> dut2 = dut;
        M12.LIZ(jediViewModel2, phd2, dut2);
        M12.LIZ(jediViewModel2, phd2, dut2);
        return DV0.LIZ(this, jediViewModel2, phd2, dut2, lsD, lsC, lsD2);
    }

    public <S extends 5Am, A, B, C> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, PHD<S, ? extends C> phd3, DUT<DV9<A, B, C>> dut, LsF<? super R, ? super A, ? super B, ? super C, 2Pr> lsF) {
        PHD<S, ? extends A> phd4 = phd;
        JediViewModel<S> jediViewModel2 = jediViewModel;
        PHD<S, ? extends B> phd5 = phd2;
        PHD<S, ? extends C> phd6 = phd3;
        LsF<? super R, ? super A, ? super B, ? super C, 2Pr> lsF2 = lsF;
        DUT<DV9<A, B, C>> dut2 = dut;
        M12.LIZ(jediViewModel2, phd4, phd5, phd6, dut2, lsF2);
        M12.LIZ(jediViewModel2, phd4, phd5, phd6, dut2, lsF2);
        return DV0.LIZ(this, jediViewModel2, phd4, phd5, phd6, dut2, lsF2);
    }

    public <S extends 5Am, A, B, C, D> 2cN selectSubscribe(JediViewModel<S> jediViewModel, PHD<S, ? extends A> phd, PHD<S, ? extends B> phd2, PHD<S, ? extends C> phd3, PHD<S, ? extends D> phd4, DUT<C0643D4t<A, B, C, D>> dut, Lsh<? super R, ? super A, ? super B, ? super C, ? super D, 2Pr> lsh) {
        DUT<C0643D4t<A, B, C, D>> dut2 = dut;
        PHD<S, ? extends A> phd5 = phd;
        Lsh<? super R, ? super A, ? super B, ? super C, ? super D, 2Pr> lsh2 = lsh;
        JediViewModel<S> jediViewModel2 = jediViewModel;
        PHD<S, ? extends B> phd6 = phd2;
        PHD<S, ? extends C> phd7 = phd3;
        PHD<S, ? extends D> phd8 = phd4;
        M12.LIZ(jediViewModel2, phd5, phd6, phd7, phd8, dut2, lsh2);
        M12.LIZ(jediViewModel2, phd5, phd6, phd7, phd8, dut2, lsh2);
        return DV0.LIZ(this, jediViewModel2, phd5, phd6, phd7, phd8, dut2, lsh2);
    }
}
