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

import X.0HH;
import X.30v;
import X.4PU;
import X.BbC;
import X.C4028EaO;
import X.C5876FAa;
import X.C5879FAd;
import X.C5881FAf;
import X.FAT;
import X.FAZ;
import X.M12;
import X.Mk2;
import X.Mk3;
import X.OQg;
import X.OQh;
import X.PhE;
import X.PlI;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.base.fragment.AmeBaseFragment;
import com.ss.android.ugc.aweme.profile.model.User;
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.ArrayList;
import java.util.List;
import kotlin.h.b.n;

public final class PollDetailFragment extends AmeBaseFragment implements 4PU, BbC<User> {
    public static final FAT LIZJ = new FAT((byte) 0);
    public C5876FAa LIZ;
    public C5881FAf LIZIZ;
    public PollStruct LIZLLL;
    public int LJ;
    public View LJIIIZ;
    public RecyclerView LJIIJ;
    public OQg LJIIJJI;
    public C4028EaO LJIIL;
    public SparseArray LJIILIIL;

    static {
        Covode.recordClassIndex(112336);
    }

    public final void LIZ(Exception exc) {
    }

    public final void LIZJ(List<User> list, boolean z) {
    }

    public final void cn_() {
    }

    public final void bw_() {
        C4028EaO eaO;
        if (aq_() && (eaO = this.LJIIL) != null) {
            eaO.showLoadMoreLoading();
        }
    }

    public final void onDestroy() {
        PollDetailFragment.super.onDestroy();
        C5876FAa fAa = this.LIZ;
        if (fAa != null) {
            fAa.LIZIZ.dispose();
        }
    }

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

    public final void LIZIZ() {
        if (aq_()) {
            OQg oQg = this.LJIIJJI;
            if (oQg != null) {
                oQg.setVisibility(0);
            }
            OQg oQg2 = this.LJIIJJI;
            if (oQg2 != null) {
                oQg2.LIZ();
            }
        }
    }

    public final void LJFF() {
        if (aq_()) {
            OQg oQg = this.LJIIJJI;
            if (oQg != null) {
                oQg.setVisibility(0);
            }
            OQg oQg2 = this.LJIIJJI;
            if (oQg2 != null) {
                OQh oQh = new OQh();
                String string = getString(2131834891);
                n.LIZIZ(string, "");
                oQh.LIZ(string);
                oQg2.setStatus(oQh);
            }
        }
    }

    public final void LIZJ() {
        PollStruct$OptionsBean pollStruct$OptionsBean;
        PollStruct$OptionsBean pollStruct$OptionsBean2;
        C5876FAa fAa = this.LIZ;
        if (fAa != null) {
            PollStruct pollStruct = this.LIZLLL;
            if (pollStruct == null) {
                n.LIZIZ();
            }
            long pollId = pollStruct.getPollId();
            long j = 0;
            if (this.LJ == 0) {
                PollStruct pollStruct2 = this.LIZLLL;
                if (pollStruct2 == null) {
                    n.LIZIZ();
                }
                List options = pollStruct2.getOptions();
                if (!(options == null || (pollStruct$OptionsBean2 = (PollStruct$OptionsBean) options.get(0)) == null)) {
                    j = pollStruct$OptionsBean2.getOptionId();
                }
            } else {
                PollStruct pollStruct3 = this.LIZLLL;
                if (pollStruct3 == null) {
                    n.LIZIZ();
                }
                List options2 = pollStruct3.getOptions();
                if (!(options2 == null || (pollStruct$OptionsBean = (PollStruct$OptionsBean) options2.get(1)) == null)) {
                    j = pollStruct$OptionsBean.getOptionId();
                }
            }
            fAa.LIZ(pollId, j);
        }
    }

    public final void bc_() {
        PollStruct$OptionsBean pollStruct$OptionsBean;
        PollStruct$OptionsBean pollStruct$OptionsBean2;
        if (this.LIZLLL == null) {
            LJFF();
        }
        C5876FAa fAa = this.LIZ;
        if (fAa != null) {
            PollStruct pollStruct = this.LIZLLL;
            if (pollStruct == null) {
                n.LIZIZ();
            }
            long pollId = pollStruct.getPollId();
            long j = 0;
            if (this.LJ == 0) {
                PollStruct pollStruct2 = this.LIZLLL;
                if (pollStruct2 == null) {
                    n.LIZIZ();
                }
                List options = pollStruct2.getOptions();
                if (!(options == null || (pollStruct$OptionsBean2 = (PollStruct$OptionsBean) options.get(0)) == null)) {
                    j = pollStruct$OptionsBean2.getOptionId();
                }
            } else {
                PollStruct pollStruct3 = this.LIZLLL;
                if (pollStruct3 == null) {
                    n.LIZIZ();
                }
                List options2 = pollStruct3.getOptions();
                if (!(options2 == null || (pollStruct$OptionsBean = (PollStruct$OptionsBean) options2.get(1)) == null)) {
                    j = pollStruct$OptionsBean.getOptionId();
                }
            }
            fAa.LIZ.getPollDetail(pollId, j, fAa.LIZJ.LIZ).LIZIZ(PhE.LIZIZ(PlI.LIZJ)).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZIZ(new FAZ(fAa));
        }
    }

    public final void LIZJ(Exception exc) {
        C4028EaO eaO;
        if (aq_() && (eaO = this.LJIIL) != null) {
            eaO.showLoadMoreError();
        }
    }

    public final void LIZIZ(Exception exc) {
        if (aq_()) {
            OQg oQg = this.LJIIJJI;
            if (oQg != null) {
                oQg.setVisibility(0);
            }
            OQg oQg2 = this.LJIIJJI;
            if (oQg2 != null) {
                OQh oQh = new OQh();
                30v.LIZIZ(oQh, new C5879FAd(this));
                oQg2.setStatus(oQh);
            }
        }
    }

    public final void onCreate(Bundle bundle) {
        int i;
        Serializable serializable;
        PollDetailFragment.super.onCreate(bundle);
        Bundle arguments = getArguments();
        if (arguments != null) {
            i = arguments.getInt("key_state");
        } else {
            i = 0;
        }
        this.LJ = i;
        Bundle arguments2 = getArguments();
        if (arguments2 != null) {
            serializable = arguments2.getSerializable("key_poll");
        } else {
            serializable = null;
        }
        this.LIZLLL = (PollStruct) serializable;
        this.LIZ = new C5876FAa(this, this.LIZIZ, this.LJ);
    }

    public final void LIZ(List<User> list, boolean z) {
        if (aq_()) {
            if (!z) {
                C4028EaO eaO = this.LJIIL;
                if (eaO != null) {
                    eaO.showLoadMoreEmpty();
                }
            } else {
                C4028EaO eaO2 = this.LJIIL;
                if (eaO2 != null) {
                    eaO2.resetLoadMoreState();
                }
            }
            OQg oQg = this.LJIIJJI;
            if (oQg != null) {
                oQg.setVisibility(8);
            }
            C4028EaO eaO3 = this.LJIIL;
            if (eaO3 != null) {
                eaO3.setData(list);
            }
        }
    }

    public final void LIZIZ(List<User> list, boolean z) {
        List list2;
        if (aq_()) {
            C4028EaO eaO = this.LJIIL;
            if (eaO != null) {
                eaO.setShowFooter(false);
            }
            if (!z) {
                C4028EaO eaO2 = this.LJIIL;
                if (eaO2 != null) {
                    eaO2.showLoadMoreEmpty();
                }
            } else {
                C4028EaO eaO3 = this.LJIIL;
                if (eaO3 != null) {
                    eaO3.resetLoadMoreState();
                }
            }
            C4028EaO eaO4 = this.LJIIL;
            if (eaO4 == null || (list2 = eaO4.getData()) == null) {
                list2 = new ArrayList();
            }
            if (list != null && !list.isEmpty()) {
                list2.addAll(list);
                C4028EaO eaO5 = this.LJIIL;
                if (eaO5 != null) {
                    eaO5.setDataAfterLoadMore(list2);
                }
            }
            C4028EaO eaO6 = this.LJIIL;
            if (eaO6 != null) {
                eaO6.setShowFooter(true);
            }
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:17:0x0036, code lost:
        if (X.878.LIZ(r3) != false) goto L_0x0038;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:35:0x0068, code lost:
        if (X.878.LIZ(r3) != false) goto L_0x0038;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:36:0x006b, code lost:
        LIZIZ();
        r1 = r4.LJIIJ;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:37:0x0070, code lost:
        if (r1 == null) goto L_?;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:38:0x0072, code lost:
        r1.post(new X.C5880FAe(r4, r2, r3));
     */
    /* JADX WARNING: Code restructure failed: missing block: B:40:?, code lost:
        return;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:41:?, code lost:
        return;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void onViewCreated(android.view.View r5, android.os.Bundle r6) {
        /*
            r4 = this;
            X.M12.LIZ(r5)
            com.ss.android.ugc.aweme.shortvideo.sticker.infoSticker.interact.consume.fragment.PollDetailFragment.super.onViewCreated(r5, r6)
            int r2 = r4.LJ
            r0 = 1
            r1 = 0
            if (r2 != 0) goto L_0x003c
            X.FAf r0 = r4.LIZIZ
            if (r0 == 0) goto L_0x001a
            X.FAc r0 = r0.LIZ()
            if (r0 == 0) goto L_0x001a
            java.util.List<com.ss.android.ugc.aweme.profile.model.User> r3 = r0.LIZ
            if (r3 != 0) goto L_0x001f
        L_0x001a:
            java.util.ArrayList r3 = new java.util.ArrayList
            r3.<init>()
        L_0x001f:
            X.FAf r0 = r4.LIZIZ
            if (r0 == 0) goto L_0x002d
            X.FAc r0 = r0.LIZ()
            if (r0 == 0) goto L_0x002d
            X.FAh r2 = r0.LIZIZ
            if (r2 != 0) goto L_0x0032
        L_0x002d:
            X.FAh r2 = new X.FAh
            r2.<init>(r1, r1)
        L_0x0032:
            boolean r0 = X.878.LIZ(r3)
            if (r0 == 0) goto L_0x006b
        L_0x0038:
            r4.LIZJ()
        L_0x003b:
            return
        L_0x003c:
            if (r2 != r0) goto L_0x0038
            X.FAf r0 = r4.LIZIZ
            if (r0 == 0) goto L_0x004c
            X.FAc r0 = r0.LIZ()
            if (r0 == 0) goto L_0x004c
            java.util.List<com.ss.android.ugc.aweme.profile.model.User> r3 = r0.LIZJ
            if (r3 != 0) goto L_0x0051
        L_0x004c:
            java.util.ArrayList r3 = new java.util.ArrayList
            r3.<init>()
        L_0x0051:
            X.FAf r0 = r4.LIZIZ
            if (r0 == 0) goto L_0x005f
            X.FAc r0 = r0.LIZ()
            if (r0 == 0) goto L_0x005f
            X.FAh r2 = r0.LIZLLL
            if (r2 != 0) goto L_0x0064
        L_0x005f:
            X.FAh r2 = new X.FAh
            r2.<init>(r1, r1)
        L_0x0064:
            boolean r0 = X.878.LIZ(r3)
            if (r0 == 0) goto L_0x006b
            goto L_0x0038
        L_0x006b:
            r4.LIZIZ()
            androidx.recyclerview.widget.RecyclerView r1 = r4.LJIIJ
            if (r1 == 0) goto L_0x003b
            X.FAe r0 = new X.FAe
            r0.<init>(r4, r2, r3)
            r1.post(r0)
            goto L_0x003b
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.shortvideo.sticker.infoSticker.interact.consume.fragment.PollDetailFragment.onViewCreated(android.view.View, android.os.Bundle):void");
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        OQg oQg;
        M12.LIZ(layoutInflater);
        View LIZ2 = 0HH.LIZ(layoutInflater, 2131562313, viewGroup, false);
        this.LJIIIZ = LIZ2;
        RecyclerView recyclerView = null;
        if (LIZ2 != null) {
            oQg = (OQg) LIZ2.findViewById(2131370625);
        } else {
            oQg = null;
        }
        this.LJIIJJI = oQg;
        if (LIZ2 != null) {
            recyclerView = (RecyclerView) LIZ2.findViewById(2131369401);
        }
        this.LJIIJ = recyclerView;
        C4028EaO eaO = new C4028EaO();
        this.LJIIL = eaO;
        eaO.setLoadMoreListener(this);
        RecyclerView recyclerView2 = this.LJIIJ;
        if (recyclerView2 != null) {
            recyclerView2.setAdapter(this.LJIIL);
        }
        RecyclerView recyclerView3 = this.LJIIJ;
        if (recyclerView3 != null) {
            getContext();
            recyclerView3.setLayoutManager(new LinearLayoutManager());
        }
        return this.LJIIIZ;
    }
}
