package com.bytedance.ies.powerlist;

import X.0Bt;
import X.0Bv;
import X.0By;
import X.0CB;
import X.0CD;
import X.0CH;
import X.0H8;
import X.0HB;
import X.0HH;
import X.1Bj;
import X.1Bk;
import X.1hK;
import X.4hP;
import X.AbV;
import X.C0352Cto;
import X.C0353Ctp;
import X.C0366Cuc;
import X.C1443DZn;
import X.C1481DaP;
import X.CuG;
import X.Lel;
import X.M12;
import X.Pkb;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.powerlist.proxy.ListVMProxy;
import java.util.List;
import kotlin.h.b.n;

public abstract class PowerCell<T extends C1481DaP> extends RecyclerView.ViewHolder implements 1Bj, 0CH, C0353Ctp<PowerCell<T>, T, ListVMProxy<PowerCell<T>, T>> {
    public final 1Bk LIZ;
    public boolean LIZIZ;
    public 0CH LIZJ;
    public T LIZLLL;
    public PowerAdapter LJ;
    public PowerStub LJFF;
    public boolean LJI;
    public final PowerCell<T> LJII;
    public ListVMProxy<PowerCell<T>, T> LJIIIIZZ;
    public final C0352Cto<PowerCell<T>, T> LJIIIZ;

    static {
        Covode.recordClassIndex(30215);
    }

    public void LIZ(T t, List<? extends Object> list) {
        M12.LIZ(t, list);
    }

    public void LIZ(Object obj) {
    }

    public void LIZ(boolean z) {
    }

    public int bB_() {
        return 0;
    }

    public void bC_() {
    }

    public void bD_() {
    }

    public void bJ_() {
    }

    public void bK_() {
    }

    public void bL_() {
    }

    public final /* bridge */ /* synthetic */ 4hP C_() {
        return this.LJII;
    }

    public final 0CH D_() {
        return this.LIZJ;
    }

    public final /* bridge */ /* synthetic */ CuG aV_() {
        return this.LJIIIIZZ;
    }

    public void bF_() {
        bI_();
    }

    public C0352Cto<PowerCell<T>, T> bM_() {
        return this.LJIIIZ;
    }

    public 0CD getLifecycle() {
        return this.LIZ;
    }

    public void bE_() {
        bH_();
        bG_();
    }

    public PowerCell() {
        this(C1443DZn.LIZ.LIZJ());
    }

    private final void LJFF() {
        if (this.LJI) {
            this.LIZ.LIZ(0CB.ON_START);
        }
    }

    private final void LJIJI() {
        if (this.LJI) {
            this.LIZ.LIZ(0CB.ON_PAUSE);
            bK_();
        }
    }

    public final 0CH bA_() {
        PowerAdapter powerAdapter = this.LJ;
        if (powerAdapter != null) {
            return powerAdapter.LJIIJJI();
        }
        return null;
    }

    private final boolean LJ() {
        Pkb<AbV> pkb;
        AbV abV;
        PowerAdapter powerAdapter = this.LJ;
        if (powerAdapter == null || (pkb = powerAdapter.LJFF) == null || (abV = (AbV) pkb.LJIIJJI()) == null) {
            return false;
        }
        return abV.LJ;
    }

    private final void LJIL() {
        if (this.LJI) {
            this.LIZ.LIZ(0CB.ON_STOP);
            ListVMProxy<PowerCell<T>, T> listVMProxy = this.LJIIIIZZ;
            if (listVMProxy != null) {
                listVMProxy.LIZ((PowerCell<T>) this);
            }
        }
    }

    public final void bG_() {
        0CD lifecycle;
        if (!this.LIZIZ) {
            0CH r0 = this.LIZJ;
            if (!(r0 == null || (lifecycle = r0.getLifecycle()) == null)) {
                lifecycle.LIZ(this);
            }
            this.LIZIZ = true;
        }
    }

    public final void bH_() {
        this.LJI = true;
        int i = C0366Cuc.LIZIZ[getLifecycle().LIZ().ordinal()];
        if (i == 1) {
            LJFF();
            LIZIZ(false);
        } else if (i == 2) {
            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. */
    public final void bI_() {
        /*
            r2 = this;
            X.0CD r0 = r2.getLifecycle()
            X.0CC r0 = r0.LIZ()
            int[] r1 = X.C0366Cuc.LIZJ
            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.LJI = r0
            return
        L_0x001d:
            r2.LJIJI()
        L_0x0020:
            r2.LJIL()
            goto L_0x0019
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.ies.powerlist.PowerCell.bI_():void");
    }

    public final /* bridge */ /* synthetic */ void LIZ(CuG cuG) {
        this.LJIIIIZZ = (ListVMProxy) cuG;
    }

    public void LIZ(T t) {
        M12.LIZ(t);
        LIZ(t, (List<? extends Object>) Lel.INSTANCE);
    }

    public PowerCell(View view) {
        super(view);
        this.LIZ = new 1Bk(this);
        this.LJII = this;
    }

    private final void LIZIZ(boolean z) {
        if (this.LJI) {
            this.LIZ.LIZ(0CB.ON_RESUME);
            ListVMProxy<PowerCell<T>, T> listVMProxy = this.LJIIIIZZ;
            if (listVMProxy != null) {
                listVMProxy.LIZ(this, z);
            }
            LIZ(z);
        }
    }

    public View LIZ(ViewGroup viewGroup) {
        View LIZ2;
        M12.LIZ(viewGroup);
        Integer valueOf = Integer.valueOf(bB_());
        if (valueOf.intValue() > 0 && valueOf != null && (LIZ2 = LIZ(viewGroup, valueOf.intValue())) != null) {
            return LIZ2;
        }
        throw new IllegalArgumentException("onCreateItemView layoutId is valid!!");
    }

    public static /* synthetic */ 0Bt LIZ(PowerCell powerCell, Class cls) {
        1hK LJ2;
        PowerAdapter powerAdapter = powerCell.LJ;
        if (powerAdapter == null || (LJ2 = powerAdapter.LJ()) == null) {
            return null;
        }
        return 0By.LIZ(LJ2, (0Bv) null).LIZ(cls);
    }

    public static /* synthetic */ 0Bt LIZIZ(PowerCell powerCell, Class cls) {
        Fragment LIZLLL2;
        PowerAdapter powerAdapter = powerCell.LJ;
        if (powerAdapter == null || (LIZLLL2 = powerAdapter.LIZLLL()) == null) {
            return null;
        }
        return 0By.LIZ(LIZLLL2, (0Bv) null).LIZ(cls);
    }

    public final View LIZ(ViewGroup viewGroup, int i) {
        M12.LIZ(viewGroup);
        Context context = viewGroup.getContext();
        if (!LJ()) {
            View LIZ2 = 0HH.LIZ(LayoutInflater.from(context), i, viewGroup, false);
            n.LIZ(LIZ2, "");
            return LIZ2;
        } else if (context instanceof Activity) {
            0H8.LIZ(i);
            View LIZ3 = 0HB.LIZ((Activity) context, i);
            0HB.LIZ(context, i);
            n.LIZ(LIZ3, "");
            return LIZ3;
        } else {
            throw new IllegalStateException("context is not an Activity??".toString());
        }
    }

    public void onStateChanged(0CH r3, 0CB r4) {
        0CD lifecycle;
        M12.LIZ(r3, r4);
        switch (C0366Cuc.LIZ[r4.ordinal()]) {
            case 1:
                this.LIZ.LIZ(0CB.ON_CREATE);
                bJ_();
                return;
            case 2:
                LJFF();
                return;
            case 3:
                LIZIZ(true);
                return;
            case 4:
                LJIJI();
                return;
            case 5:
                LJIL();
                return;
            case 6:
                bI_();
                this.LIZ.LIZ(0CB.ON_DESTROY);
                0CH r0 = this.LIZJ;
                if (!(r0 == null || (lifecycle = r0.getLifecycle()) == null)) {
                    lifecycle.LIZIZ(this);
                }
                bL_();
                return;
            default:
                return;
        }
    }
}
