package com.ss.android.ugc.aweme.shortvideo.sticker.infoSticker.interact.consume.view;

import X.0AA;
import X.0HH;
import X.2yN;
import X.9x5;
import X.C5869F9t;
import X.C5881FAf;
import X.C5884FAi;
import X.FA9;
import X.FAU;
import X.FAV;
import X.M12;
import X.Qyn;
import X.Srx;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.shortvideo.sticker.infoSticker.interact.consume.dialog.ViewPagerBottomSheetDialogFragment;
import com.ss.android.ugc.aweme.shortvideo.sticker.infoSticker.interact.consume.fragment.PollDetailFragment;
import com.ss.android.ugc.aweme.sticker.data.PollStruct;
import com.ss.android.ugc.aweme.sticker.data.PollStruct$OptionsBean;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import kotlin.h.b.n;

public final class PollBottomSheetDialogFragment extends ViewPagerBottomSheetDialogFragment {
    public static final FA9 LJFF = new FA9((byte) 0);
    public Qyn LIZ;
    public Srx LIZIZ;
    public PollStruct LIZJ;
    public C5869F9t LIZLLL;
    public C5881FAf LJ;
    public View LJI;
    public 9x5 LJII;
    public TextView LJIIIIZZ;
    public ImageView LJIIIZ;
    public SparseArray LJIIJ;

    static {
        Covode.recordClassIndex(112367);
    }

    public final /* synthetic */ void onDestroyView() {
        PollBottomSheetDialogFragment.super.onDestroyView();
        SparseArray sparseArray = this.LJIIJ;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    public final void onDismiss(DialogInterface dialogInterface) {
        PollBottomSheetDialogFragment.super.onDismiss(dialogInterface);
        C5869F9t f9t = this.LIZLLL;
        if (f9t != null) {
            f9t.LIZ();
        }
    }

    public final void onCreate(Bundle bundle) {
        Serializable serializable;
        PollBottomSheetDialogFragment.super.onCreate(bundle);
        setStyle(0, 2131887101);
        Bundle arguments = getArguments();
        if (arguments != null) {
            serializable = arguments.getSerializable("key_poll");
        } else {
            serializable = null;
        }
        this.LIZJ = (PollStruct) serializable;
    }

    public final Dialog onCreateDialog(Bundle bundle) {
        Dialog onCreateDialog = super.onCreateDialog(bundle);
        n.LIZIZ(onCreateDialog, "");
        onCreateDialog.setOnShowListener(new FAV(this));
        return onCreateDialog;
    }

    public final void show(0AA r1, String str) {
        M12.LIZ(r1, str);
        try {
            PollBottomSheetDialogFragment.super.show(r1, str);
        } catch (IllegalStateException unused) {
        }
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        long j;
        List options;
        PollStruct$OptionsBean pollStruct$OptionsBean;
        List options2;
        PollStruct$OptionsBean pollStruct$OptionsBean2;
        M12.LIZ(layoutInflater);
        View LIZ2 = 0HH.LIZ(layoutInflater, 2131562312, viewGroup, false);
        n.LIZIZ(LIZ2, "");
        this.LJI = LIZ2;
        if (LIZ2 == null) {
            n.LIZ("");
        }
        this.LIZ = LIZ2.findViewById(2131371003);
        View view = this.LJI;
        if (view == null) {
            n.LIZ("");
        }
        this.LIZIZ = view.findViewById(2131372992);
        View view2 = this.LJI;
        if (view2 == null) {
            n.LIZ("");
        }
        this.LJIIIIZZ = (TextView) view2.findViewById(2131371242);
        View view3 = this.LJI;
        if (view3 == null) {
            n.LIZ("");
        }
        this.LJIIIZ = (ImageView) view3.findViewById(2131366353);
        0AA childFragmentManager = getChildFragmentManager();
        n.LIZIZ(childFragmentManager, "");
        9x5 r1 = new 9x5(childFragmentManager);
        this.LJII = r1;
        r1.LIZ.add(PollDetailFragment.LIZJ.LIZ(0, this.LIZJ));
        9x5 r0 = this.LJII;
        if (r0 == null) {
            n.LIZIZ();
        }
        r0.LIZ.add(PollDetailFragment.LIZJ.LIZ(1, this.LIZJ));
        9x5 r02 = this.LJII;
        if (r02 == null) {
            n.LIZIZ();
        }
        Object obj = r02.LIZ.get(0);
        Objects.requireNonNull(obj, "null cannot be cast to non-null type com.ss.android.ugc.aweme.shortvideo.sticker.infoSticker.interact.consume.fragment.PollDetailFragment");
        ((PollDetailFragment) obj).LIZIZ = this.LJ;
        9x5 r03 = this.LJII;
        if (r03 == null) {
            n.LIZIZ();
        }
        Object obj2 = r03.LIZ.get(1);
        Objects.requireNonNull(obj2, "null cannot be cast to non-null type com.ss.android.ugc.aweme.shortvideo.sticker.infoSticker.interact.consume.fragment.PollDetailFragment");
        ((PollDetailFragment) obj2).LIZIZ = this.LJ;
        Srx srx = this.LIZIZ;
        if (srx != null) {
            srx.setPagingEnable(false);
        }
        Srx srx2 = this.LIZIZ;
        if (srx2 != null) {
            srx2.setAdapter(this.LJII);
        }
        Qyn qyn = this.LIZ;
        if (qyn != null) {
            qyn.post(new C5884FAi(this));
        }
        PollStruct pollStruct = this.LIZJ;
        long j2 = 0;
        if (pollStruct == null || (options2 = pollStruct.getOptions()) == null || (pollStruct$OptionsBean2 = (PollStruct$OptionsBean) options2.get(0)) == null) {
            j = 0;
        } else {
            j = pollStruct$OptionsBean2.getPollCount();
        }
        PollStruct pollStruct2 = this.LIZJ;
        if (!(pollStruct2 == null || (options = pollStruct2.getOptions()) == null || (pollStruct$OptionsBean = (PollStruct$OptionsBean) options.get(1)) == null)) {
            j2 = pollStruct$OptionsBean.getPollCount();
        }
        String LIZ3 = 2yN.LIZ(j + j2);
        TextView textView = this.LJIIIIZZ;
        if (textView != null) {
            String string = getResources().getString(2131834898);
            n.LIZIZ(string, "");
            String LIZ4 = 0HH.LIZ(string, Arrays.copyOf(new Object[]{LIZ3}, 1));
            n.LIZIZ(LIZ4, "");
            textView.setText(LIZ4);
        }
        ImageView imageView = this.LJIIIZ;
        if (imageView != null) {
            imageView.setOnClickListener(new FAU(this));
        }
        View view4 = this.LJI;
        if (view4 == null) {
            n.LIZ("");
        }
        return view4;
    }
}
