package com.bytedance.android.livesdk.newtray;

import X.0CB;
import X.0CH;
import X.6Is;
import X.C2675Gg0;
import X.C4672HTd;
import X.HTH;
import X.HTO;
import X.HTW;
import X.Mjy;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.sdk.widgets.LiveRecyclableWidget;
import java.util.ArrayList;
import kotlin.h.b.n;

public class LiveGiftRemoteTrayDisplayWidget extends LiveRecyclableWidget implements 6Is {
    public ArrayList<HTW> LIZ = new ArrayList<>(2);
    public final Mjy LIZIZ = new Mjy();

    static {
        Covode.recordClassIndex(19685);
    }

    public int getLayoutId() {
        return 2131562191;
    }

    public void onInit(Object[] objArr) {
    }

    public void onStateChanged(0CH r1, 0CB r2) {
        super.onStateChanged(r1, r2);
    }

    public HTW LIZ() {
        Context context = this.context;
        n.LIZIZ(context, "");
        return new HTW(context);
    }

    public void onUnload() {
        for (HTO LIZJ : this.LIZ) {
            LIZJ.LIZJ();
        }
        this.LIZIZ.LIZ();
    }

    public void onLoad(Object[] objArr) {
        MethodCollector.i(4141);
        HTW LIZ2 = LIZ();
        LIZ2.setVisibility(4);
        LIZ2.LIZ(this.dataChannel);
        LIZ2.setTrackNum(0);
        View view = this.contentView;
        if (view != null) {
            LIZ2.setViewGroup((ViewGroup) view);
            this.LIZ.add(LIZ2);
            View view2 = this.contentView;
            ViewGroup viewGroup = null;
            if (!(view2 instanceof ViewGroup)) {
                view2 = null;
            }
            ViewGroup viewGroup2 = (ViewGroup) view2;
            if (viewGroup2 != null) {
                viewGroup2.addView(LIZ2);
            }
            HTW LIZ3 = LIZ();
            LIZ3.setVisibility(4);
            LIZ3.LIZ(this.dataChannel);
            LIZ3.setTrackNum(1);
            View view3 = this.contentView;
            if (view3 != null) {
                LIZ3.setViewGroup((ViewGroup) view3);
                this.LIZ.add(LIZ3);
                View view4 = this.contentView;
                if (view4 instanceof ViewGroup) {
                    viewGroup = view4;
                }
                ViewGroup viewGroup3 = viewGroup;
                if (viewGroup3 != null) {
                    viewGroup3.addView(LIZ3);
                }
                this.LIZIZ.LIZ(C2675Gg0.LIZ().LIZ(HTH.class).LIZLLL(new C4672HTd(this)));
                MethodCollector.o(4141);
                return;
            }
            NullPointerException nullPointerException = new NullPointerException("null cannot be cast to non-null type android.view.ViewGroup");
            MethodCollector.o(4141);
            throw nullPointerException;
        }
        NullPointerException nullPointerException2 = new NullPointerException("null cannot be cast to non-null type android.view.ViewGroup");
        MethodCollector.o(4141);
        throw nullPointerException2;
    }
}
