package com.ss.android.ugc.aweme.ttsvoice.ui;

import X.070;
import X.0AA;
import X.0C0;
import X.0CH;
import X.0HH;
import X.1B1;
import X.1hK;
import X.2GO;
import X.2Pr;
import X.30v;
import X.3af;
import X.40q;
import X.6Tu;
import X.8ns;
import X.A7H;
import X.AV8;
import X.B1V;
import X.B1X;
import X.B1Y;
import X.B1Z;
import X.BM4;
import X.BQM;
import X.BQV;
import X.C2188AoK;
import X.C2938B1a;
import X.C2939B1b;
import X.C2940B1c;
import X.C2941B1d;
import X.C2943B1f;
import X.C2944B1g;
import X.C2945B1h;
import X.C2946B1i;
import X.C3444BKm;
import X.C3551BOp;
import X.C3555BOt;
import X.C3932BbM;
import X.Csa;
import X.Css;
import X.Cvh;
import X.D1G;
import X.KEM;
import X.Ls2;
import X.LsC;
import X.M12;
import X.OQg;
import X.OQh;
import X.PHD;
import X.QJu;
import X.Qeg;
import X.T5D;
import X.T5I;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.bytedance.assem.arch.viewModel.AssemViewModel;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.base.fragment.AmeBaseFragment;
import com.ss.android.ugc.aweme.challenge.ui.BaseDetailFragment;
import com.ss.android.ugc.aweme.detail.AbstractDetailFragment;
import com.ss.android.ugc.aweme.music.model.Music;
import com.ss.android.ugc.aweme.ttsvoice.viewmodel.TTSVoiceDetailsViewModel;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import kotlin.h.b.n;

public final class TTSVoiceDetailsFragment extends BaseDetailFragment implements 2GO {
    public static final C2946B1i LJIILJJIL = new C2946B1i((byte) 0);
    public RelativeLayout LIZLLL;
    public OQg LJ;
    public T5D LJIIIZ;
    public ImageView LJIIJ;
    public String LJIIJJI = "";
    public String LJIIL = "";
    public Music LJIILIIL;
    public BQV LJIILL;
    public RelativeLayout LJIIZILJ;
    public TTSVoiceDetailAwemeListFragment LJIJ;
    public ViewGroup LJIJI;
    public View LJIJJ;
    public Qeg LJIJJLI;
    public Qeg LJIL;
    public QJu LJJJJI;
    public boolean LJJJJIZL;
    public float LJJJJJ;
    public float LJJJJJL;
    public int LJJJJL = -1;
    public final Csa LJJJJLI;
    public SparseArray LJJJJLL;

    static {
        Covode.recordClassIndex(120710);
    }

    public final TTSVoiceDetailsViewModel LIZ() {
        return (TTSVoiceDetailsViewModel) this.LJJJJLI.getValue();
    }

    public final String LIZJ(int i) {
        return "tts_page";
    }

    public final int LJIIIZ() {
        return 2131561476;
    }

    public final boolean LJJIJIIJI() {
        return false;
    }

    public final String LJIIJ() {
        return this.LJIIJJI;
    }

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

    public final void onPause() {
        super.onPause();
        LIZ().LIZLLL().LIZIZ();
    }

    public TTSVoiceDetailsFragment() {
        D1G LIZ = KEM.LIZ.LIZ(TTSVoiceDetailsViewModel.class);
        this.LJJJJLI = new Csa(LIZ, new C2940B1c(LIZ), Css.LIZ, C2188AoK.LIZ((0CH) this, false), C2188AoK.LIZ((0C0) this, false), A7H.LIZ, B1V.INSTANCE);
    }

    public final 1B1 LJIILIIL() {
        this.LJJIJIL = new ArrayList();
        this.LJJIJL = new ArrayList();
        this.LIZ = new ArrayList();
        0AA childFragmentManager = getChildFragmentManager();
        StringBuilder sb = new StringBuilder();
        sb.append(AbstractDetailFragment.LJJ);
        boolean z = false;
        sb.append(0);
        TTSVoiceDetailAwemeListFragment LIZ = childFragmentManager.LIZ(sb.toString());
        if (!(LIZ instanceof TTSVoiceDetailAwemeListFragment)) {
            String str = this.LJIIJJI;
            BM4 bm4 = new BM4();
            M12.LIZ("tts_page", str, bm4);
            LIZ = new TTSVoiceDetailAwemeListFragment();
            Bundle bundle = new Bundle();
            bundle.putInt("detail_aweme_list_type", 33);
            bundle.putString("event_label", "tts_page");
            bundle.putString("detail_id", str);
            LIZ.setArguments(bundle);
            LIZ.LJJIJIL = bm4;
            if (this.LJJIJIIJI == 0) {
                z = true;
            }
            LIZ.LJJIIJ = z;
            LIZ.LJJIIJZLJL = true;
        }
        this.LJIJ = LIZ;
        List<C3444BKm> list = this.LJJIJIL;
        TTSVoiceDetailAwemeListFragment tTSVoiceDetailAwemeListFragment = this.LJIJ;
        if (tTSVoiceDetailAwemeListFragment == null) {
            n.LIZ("");
        }
        list.add(tTSVoiceDetailAwemeListFragment);
        List<AmeBaseFragment> list2 = this.LJJIJL;
        TTSVoiceDetailAwemeListFragment tTSVoiceDetailAwemeListFragment2 = this.LJIJ;
        if (tTSVoiceDetailAwemeListFragment2 == null) {
            n.LIZ("");
        }
        list2.add(tTSVoiceDetailAwemeListFragment2);
        this.LIZ.add(33);
        return new BQM(getChildFragmentManager(), this.LJJIJL, this.LIZ);
    }

    public final C3555BOt LIZ(ViewGroup viewGroup) {
        M12.LIZ(viewGroup);
        BQV bqv = this.LJIILL;
        if (bqv == null) {
            n.LIZ("");
        }
        return bqv.LIZ(viewGroup);
    }

    public final void LIZ(Bundle bundle) {
        Serializable serializable;
        String string;
        String str = "";
        if (!(bundle == null || (string = bundle.getString("anchor_id", str)) == null)) {
            str = string;
        }
        this.LJIIJJI = str;
        Serializable serializable2 = null;
        if (bundle != null) {
            serializable = bundle.getSerializable("music_model");
        } else {
            serializable = null;
        }
        if (serializable instanceof Music) {
            serializable2 = serializable;
        }
        this.LJIILIIL = (Music) serializable2;
    }

    /* JADX WARNING: Code restructure failed: missing block: B:15:0x002f, code lost:
        if (r0 != null) goto L_0x0032;
     */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZ(X.2R4 r10) {
        /*
            r9 = this;
            boolean r0 = r9.aq_()
            if (r0 == 0) goto L_0x0103
            X.T5D r0 = r9.LJIIIZ
            java.lang.String r6 = ""
            if (r0 != 0) goto L_0x000f
            kotlin.h.b.n.LIZ(r6)
        L_0x000f:
            r8 = 0
            r0.setRefreshing(r8)
            X.OQg r1 = r9.LJ
            if (r1 != 0) goto L_0x001a
            kotlin.h.b.n.LIZ(r6)
        L_0x001a:
            r0 = 8
            r1.setVisibility(r0)
            if (r10 == 0) goto L_0x0107
            java.util.List r0 = r10.LIZJ
            if (r0 == 0) goto L_0x0107
            java.lang.Object r2 = X.Lea.LJIIIIZZ(r0)
            X.AVv r2 = (X.C1191AVv) r2
            if (r2 == 0) goto L_0x0031
            java.lang.String r0 = r2.LIZIZ
            if (r0 != 0) goto L_0x0032
        L_0x0031:
            r0 = r6
        L_0x0032:
            r9.LJIIL = r0
            android.widget.TextView r4 = r9.LJJII
            r4.setVisibility(r8)
            android.content.Context r1 = r9.requireContext()
            r0 = 2131099750(0x7f060066, float:1.7811862E38)
            int r0 = X.070.LIZJ(r1, r0)
            r4.setTextColor(r0)
            boolean r0 = r4 instanceof X.Qeg
            if (r0 == 0) goto L_0x0053
            r1 = r4
            X.Qeg r1 = (X.Qeg) r1
            r0 = 33
            r1.setTuxFont(r0)
        L_0x0053:
            r3 = 2131820951(0x7f110197, float:1.9274631E38)
            r7 = 1
            java.lang.Object[] r1 = new java.lang.Object[r7]
            java.lang.String r0 = r9.LJIIL
            r1[r8] = r0
            java.lang.String r0 = r9.getString(r3, r1)
            r4.setText(r0)
            X.Qeg r1 = r9.LJIJJLI
            if (r1 != 0) goto L_0x006b
            kotlin.h.b.n.LIZ(r6)
        L_0x006b:
            java.lang.String r0 = r9.LJIIL
            r1.setText(r0)
            if (r2 == 0) goto L_0x009f
            X.2NG r0 = r2.LIZJ
            if (r0 == 0) goto L_0x009f
            java.util.List r1 = r0.LIZIZ
            if (r1 == 0) goto L_0x009f
            boolean r0 = r1.isEmpty()
            r0 = r0 ^ r7
            if (r0 == 0) goto L_0x009f
            X.B3G r0 = new X.B3G
            r0.<init>(r1)
            X.QJt r1 = new X.QJt
            r1.<init>(r0)
            android.content.Context r0 = r9.requireContext()
            r1.LIZIZ = r0
            X.QJs r1 = r1.LIZIZ()
            X.QJu r0 = r9.LJJJJI
            if (r0 != 0) goto L_0x009c
            kotlin.h.b.n.LIZ(r6)
        L_0x009c:
            r0.LIZ(r1)
        L_0x009f:
            android.widget.ImageView r0 = r9.LJIIJ
            if (r0 != 0) goto L_0x00a6
            kotlin.h.b.n.LIZ(r6)
        L_0x00a6:
            r0.setVisibility(r8)
            android.widget.ImageView r1 = r9.LJIIJ
            if (r1 != 0) goto L_0x00b0
            kotlin.h.b.n.LIZ(r6)
        L_0x00b0:
            X.7h0 r0 = new X.7h0
            r0.<init>(r9)
            r1.setOnClickListener(r0)
            if (r2 == 0) goto L_0x0104
            java.lang.Integer r0 = r2.LJ
            if (r0 == 0) goto L_0x0104
            int r0 = r0.intValue()
            long r3 = (long) r0
        L_0x00c3:
            X.Qeg r5 = r9.LJIL
            if (r5 != 0) goto L_0x00ca
            kotlin.h.b.n.LIZ(r6)
        L_0x00ca:
            r0 = 2131827416(0x7f111ad8, float:1.9287744E38)
            java.lang.String r2 = r9.getString(r0)
            kotlin.h.b.n.LIZIZ(r2, r6)
            java.lang.Object[] r1 = new java.lang.Object[r7]
            java.lang.String r0 = X.2yN.LIZ(r3)
            r1[r8] = r0
            java.lang.Object[] r0 = java.util.Arrays.copyOf(r1, r7)
            java.lang.String r0 = X.0HH.LIZ(r2, r0)
            kotlin.h.b.n.LIZIZ(r0, r6)
            r5.setText(r0)
            if (r10 == 0) goto L_0x0103
            java.util.List r0 = r10.LIZJ
            if (r0 == 0) goto L_0x0103
            java.lang.Object r0 = X.Lea.LJIIIIZZ(r0)
            X.AVv r0 = (X.C1191AVv) r0
            if (r0 == 0) goto L_0x0103
            com.ss.android.ugc.aweme.ttsvoice.ui.TTSVoiceDetailAwemeListFragment r1 = r9.LJIJ
            if (r1 != 0) goto L_0x00ff
            kotlin.h.b.n.LIZ(r6)
        L_0x00ff:
            java.lang.String r0 = r0.LIZIZ
            r1.LJJIJLIJ = r0
        L_0x0103:
            return
        L_0x0104:
            r3 = 0
            goto L_0x00c3
        L_0x0107:
            r2 = 0
            goto L_0x0031
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.ttsvoice.ui.TTSVoiceDetailsFragment.LIZ(X.2R4):void");
    }

    public final void LIZ(View view) {
        M12.LIZ(view);
        super.LIZ(view);
        View findViewById = view.findViewById(2131371289);
        n.LIZIZ(findViewById, "");
        this.LJIIZILJ = (RelativeLayout) findViewById;
        OQg findViewById2 = view.findViewById(2131370625);
        n.LIZIZ(findViewById2, "");
        this.LJ = findViewById2;
        T5D findViewById3 = view.findViewById(2131369416);
        n.LIZIZ(findViewById3, "");
        this.LJIIIZ = findViewById3;
        View findViewById4 = view.findViewById(2131365548);
        n.LIZIZ(findViewById4, "");
        this.LJIJI = (ViewGroup) findViewById4;
        LayoutInflater layoutInflater = getLayoutInflater();
        ViewGroup viewGroup = this.LJIJI;
        if (viewGroup == null) {
            n.LIZ("");
        }
        View LIZ = 0HH.LIZ(layoutInflater, 2131561477, viewGroup, true);
        n.LIZIZ(LIZ, "");
        this.LJIJJ = LIZ;
        if (LIZ == null) {
            n.LIZ("");
        }
        View findViewById5 = LIZ.findViewById(2131368579);
        n.LIZIZ(findViewById5, "");
        this.LJIIJ = (ImageView) findViewById5;
        View view2 = this.LJIJJ;
        if (view2 == null) {
            n.LIZ("");
        }
        Qeg findViewById6 = view2.findViewById(2131373011);
        n.LIZIZ(findViewById6, "");
        this.LJIJJLI = findViewById6;
        View view3 = this.LJIJJ;
        if (view3 == null) {
            n.LIZ("");
        }
        Qeg findViewById7 = view3.findViewById(2131372896);
        n.LIZIZ(findViewById7, "");
        this.LJIL = findViewById7;
        View view4 = this.LJIJJ;
        if (view4 == null) {
            n.LIZ("");
        }
        QJu findViewById8 = view4.findViewById(2131373006);
        n.LIZIZ(findViewById8, "");
        this.LJJJJI = findViewById8;
        View findViewById9 = view.findViewById(2131370592);
        n.LIZIZ(findViewById9, "");
        this.LIZLLL = (RelativeLayout) findViewById9;
        Context requireContext = requireContext();
        n.LIZIZ(requireContext, "");
        LayoutInflater layoutInflater2 = getLayoutInflater();
        n.LIZIZ(layoutInflater2, "");
        BQV bqv = new BQV(requireContext, layoutInflater2, 2131820957);
        this.LJIILL = bqv;
        RelativeLayout relativeLayout = this.LIZLLL;
        if (relativeLayout == null) {
            n.LIZ("");
        }
        bqv.LIZ(relativeLayout);
        FrameLayout frameLayout = (FrameLayout) view.findViewById(2131370589);
        n.LIZIZ(frameLayout, "");
        LIZ((View) frameLayout, (LsC<? super View, 2Pr>) new B1Y(this));
    }

    public final void LIZ(boolean z) {
        if (!aq_()) {
            T5D t5d = this.LJIIIZ;
            if (t5d == null) {
                n.LIZ("");
            }
            t5d.setRefreshing(false);
            return;
        }
        OQg oQg = this.LJ;
        if (oQg == null) {
            n.LIZ("");
        }
        oQg.setVisibility(0);
        Context requireContext = requireContext();
        n.LIZIZ(requireContext, "");
        M12.LIZ(requireContext);
        if (!8ns.LIZ()) {
            3af r1 = new 3af(this);
            r1.LJ(2131827476);
            3af.LIZ(r1);
            OQg oQg2 = this.LJ;
            if (oQg2 == null) {
                n.LIZ("");
            }
            OQh oQh = new OQh();
            30v.LIZ(oQh, new C2943B1f(this));
            oQg2.setStatus(oQh);
            T5D t5d2 = this.LJIIIZ;
            if (t5d2 == null) {
                n.LIZ("");
            }
            t5d2.setRefreshing(false);
            return;
        }
        OQg oQg3 = this.LJ;
        if (oQg3 == null) {
            n.LIZ("");
        }
        oQg3.LIZ();
        LIZ().LIZ(this.LJIIJJI);
        List<C3444BKm> list = this.LJJIJIL;
        if (z && list != null) {
            for (C3444BKm LIZ : list) {
                LIZ.LIZ(false, false);
            }
        }
    }

    private final void LIZ(View view, LsC<? super View, 2Pr> lsC) {
        view.setOnClickListener(new C2941B1d(lsC));
    }

    public final void LIZ(float f, float f2) {
        this.LJJJJIZL = C3551BOp.LIZ.LIZ(f, f2, this.LJJJJIZL, this);
    }

    public final void LIZIZ(int i, int i2) {
        ColorDrawable colorDrawable;
        super.LIZIZ(i, i2);
        int i3 = this.LJJJJL;
        ViewGroup viewGroup = this.LJIJI;
        if (viewGroup == null) {
            n.LIZ("");
        }
        float f = 0.0f;
        if (i3 != viewGroup.getBottom()) {
            ViewGroup viewGroup2 = this.LJIJI;
            if (viewGroup2 == null) {
                n.LIZ("");
            }
            int bottom = viewGroup2.getBottom();
            View view = this.LJJIII;
            n.LIZIZ(view, "");
            int bottom2 = bottom - view.getBottom();
            RelativeLayout relativeLayout = this.LJIIZILJ;
            if (relativeLayout == null) {
                n.LIZ("");
            }
            float height = (float) (bottom2 - relativeLayout.getHeight());
            this.LJJJJJ = height;
            Context requireContext = requireContext();
            n.LIZIZ(requireContext, "");
            float LIZ = height - 6Tu.LIZ(requireContext, 20.0f);
            this.LJJJJJL = LIZ;
            if (LIZ < 0.0f) {
                this.LJJJJJL = 0.0f;
            }
            ViewGroup viewGroup3 = this.LJIJI;
            if (viewGroup3 == null) {
                n.LIZ("");
            }
            this.LJJJJL = viewGroup3.getBottom();
        }
        RelativeLayout relativeLayout2 = this.LJIIZILJ;
        if (relativeLayout2 == null) {
            n.LIZ("");
        }
        if (i == 0) {
            RelativeLayout relativeLayout3 = this.LJIIZILJ;
            if (relativeLayout3 == null) {
                n.LIZ("");
            }
            colorDrawable = new ColorDrawable(070.LIZJ(relativeLayout3.getContext(), 2131100577));
        } else {
            RelativeLayout relativeLayout4 = this.LJIIZILJ;
            if (relativeLayout4 == null) {
                n.LIZ("");
            }
            colorDrawable = new ColorDrawable(070.LIZJ(relativeLayout4.getContext(), 2131099659));
        }
        relativeLayout2.setBackground(colorDrawable);
        float f2 = ((float) i) / 1.0f;
        if (f2 >= 0.0f) {
            if (f2 > 1.0f) {
                f = 1.0f;
            } else {
                f = f2;
            }
        }
        TextView textView = this.LJJII;
        n.LIZIZ(textView, "");
        textView.setAlpha(f);
        this.LJJJJIZL = C3551BOp.LIZ.LIZ(f, this.LJJJJIZL, this);
    }

    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        super.onViewCreated(view, bundle);
        if (this.LJIIJJI.length() == 0) {
            1hK activity = getActivity();
            if (activity != null) {
                activity.finish();
                return;
            }
            return;
        }
        TextView textView = this.LJJII;
        textView.setAlpha(0.0f);
        textView.setOnClickListener(new C2945B1h(this));
        ImageView imageView = this.LJJIIZI;
        n.LIZIZ(imageView, "");
        LIZ((View) imageView, (LsC<? super View, 2Pr>) new C2939B1b(this));
        T5D t5d = this.LJIIIZ;
        if (t5d == null) {
            n.LIZ("");
        }
        t5d.setOverScrollMode(C3932BbM.NONE);
        t5d.setScrollMode(40q.NONE);
        t5d.setNestedHeader((T5I) null);
        LIZ().LIZIZ.observe(getViewLifecycleOwner(), new B1Z(this));
        TTSVoiceDetailsViewModel LIZ = LIZ();
        PHD phd = AV8.LIZ;
        B1X b1x = new B1X(this);
        C2938B1a b1a = new C2938B1a(this);
        Cvh cvh = new Cvh();
        C2944B1g b1g = C2944B1g.LIZ;
        M12.LIZ(b1g);
        cvh.LIZIZ = b1g;
        AssemViewModel.asyncSubscribe$default(LIZ, phd, cvh, b1a, (Ls2) null, b1x, 8, (Object) null);
        LIZ(false);
    }
}
