package com.bytedance.android.live.effect.music;

import X.2K7;
import X.2Pr;
import X.AnonymousClass0EC;
import X.C10000b0;
import X.C10940cW;
import X.C13040fu;
import X.C13050fv;
import X.C13190g9;
import X.C13200gA;
import X.C13220gC;
import X.C13250gF;
import X.C13290gJ;
import X.C31271Mf;
import X.C31521Ne;
import X.C31531Nf;
import X.C31541Ng;
import X.C31661Ns;
import X.C31671Nt;
import X.C46331sV;
import X.C46501sm;
import X.C46511sn;
import X.C46521so;
import X.C46531sp;
import X.C46541sq;
import X.Fun;
import X.G2l;
import X.Ga4;
import X.H1f;
import X.LsC;
import X.M12;
import X.Mk2;
import X.Mk3;
import X.PgU;
import X.PhE;
import X.PlI;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.bytedance.android.livesdk.LiveDialogFragment;
import com.bytedance.covode.number.Covode;
import java.util.HashMap;
import java.util.List;
import kotlin.h.b.n;

public final class LiveMusicDialog extends LiveDialogFragment implements C13290gJ {
    public static final C13040fu LIZLLL = new C13040fu((byte) 0);
    public LiveDialogFragment LIZ;
    public long LIZIZ;
    public C31661Ns LIZJ;
    public final Ga4 LJ = Ga4.PANEL_MUSIC;
    public final Drawable LJFF;
    public final Drawable LJI;
    public final Drawable LJII;
    public final Drawable LJIIIIZZ;
    public final Drawable LJIIIZ;
    public final Drawable LJIIJ;
    public final Drawable LJIIJJI;
    public HashMap LJIIZILJ;

    static {
        Covode.recordClassIndex(6106);
    }

    /* JADX WARNING: type inference failed for: r3v0, types: [androidx.fragment.app.Fragment, com.bytedance.android.live.effect.music.LiveMusicDialog] */
    public final View LIZ(int i) {
        if (this.LJIIZILJ == null) {
            this.LJIIZILJ = new HashMap();
        }
        View view = (View) this.LJIIZILJ.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LJIIZILJ.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

    public final void z_() {
        HashMap hashMap = this.LJIIZILJ;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public final Ga4 b_() {
        return this.LJ;
    }

    public final void LJ() {
        LIZ(true);
    }

    public final void LJFF() {
        LIZ(false);
    }

    public final void LJI() {
        LIZ(false);
    }

    public static boolean LJII() {
        try {
            return 2K7.LIZ.LIZJ();
        } catch (Exception unused) {
            return false;
        }
    }

    public final Fun LIZ() {
        Fun fun = new Fun(2131561649);
        fun.LJI = 80;
        fun.LJIIIIZZ = -1;
        fun.LJFF = 0.0f;
        return fun;
    }

    public final void onDestroyView() {
        LiveMusicDialog.super.onDestroyView();
        C13250gF r0 = C13250gF.LJIIL;
        M12.LIZ(this);
        r0.LIZJ().remove(this);
        z_();
    }

    public final void LIZLLL() {
        C31661Ns r4 = this.LIZJ;
        if (r4 == null) {
            n.LIZ("");
        }
        r4.LIZ(false, -1);
        ImageView imageView = (ImageView) LIZ(2131368580);
        n.LIZIZ(imageView, "");
        imageView.setClickable(true);
        LJIIJJI();
        LIZ(true);
    }

    public LiveMusicDialog() {
        Drawable LIZJ2 = C10000b0.LIZJ(2131234761);
        n.LIZIZ(LIZJ2, "");
        this.LJFF = LIZJ2;
        Drawable LIZJ3 = C10000b0.LIZJ(2131234762);
        n.LIZIZ(LIZJ3, "");
        this.LJI = LIZJ3;
        Drawable LIZJ4 = C10000b0.LIZJ(2131234763);
        n.LIZIZ(LIZJ4, "");
        this.LJII = LIZJ4;
        Drawable LIZJ5 = C10000b0.LIZJ(2131234759);
        n.LIZIZ(LIZJ5, "");
        this.LJIIIIZZ = LIZJ5;
        Drawable LIZJ6 = C10000b0.LIZJ(2131234760);
        n.LIZIZ(LIZJ6, "");
        this.LJIIIZ = LIZJ6;
        Drawable LIZJ7 = C10000b0.LIZJ(2131234764);
        n.LIZIZ(LIZJ7, "");
        this.LJIIJ = LIZJ7;
        Drawable LIZJ8 = C10000b0.LIZJ(2131234765);
        n.LIZIZ(LIZJ8, "");
        this.LJIIJJI = LIZJ8;
    }

    private final void LJIIJJI() {
        String str;
        String str2;
        C13190g9 accompaniment;
        C13190g9 accompaniment2;
        C13200gA r0 = C13250gF.LJIIIIZZ;
        if (r0 == null || (accompaniment2 = r0.getAccompaniment()) == null || (str = accompaniment2.LIZIZ) == null) {
            str = "";
        }
        C13200gA r02 = C13250gF.LJIIIIZZ;
        if (r02 == null || (accompaniment = r02.getAccompaniment()) == null) {
            str2 = null;
        } else {
            str2 = accompaniment.LIZJ;
        }
        PgU.LIZ(new C31521Ne(this, str2, str)).LIZIZ(PhE.LIZ(PlI.LIZIZ)).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZ(new C31531Nf(this), C31541Ng.LIZ);
    }

    public static final /* synthetic */ C31661Ns LIZ(LiveMusicDialog liveMusicDialog) {
        C31661Ns r1 = liveMusicDialog.LIZJ;
        if (r1 == null) {
            n.LIZ("");
        }
        return r1;
    }

    private final void LIZ(boolean z) {
        boolean z2;
        ImageView imageView;
        Drawable drawable;
        Drawable drawable2;
        Drawable drawable3;
        if (C13250gF.LJIIIIZZ != null) {
            z2 = true;
        } else {
            z2 = false;
        }
        if (z2 || C13250gF.LJII == 0) {
            imageView = (ImageView) LIZ(2131368580);
            if (z) {
                drawable = this.LJFF;
            } else {
                drawable = this.LJI;
            }
        } else {
            imageView = (ImageView) LIZ(2131368580);
            drawable = this.LJII;
        }
        imageView.setImageDrawable(drawable);
        C31271Mf r1 = (C31271Mf) LIZ(2131367999);
        if (z2) {
            drawable2 = this.LJIIIIZZ;
        } else {
            drawable2 = this.LJIIIZ;
        }
        r1.setImageDrawable(drawable2);
        C31271Mf r0 = (C31271Mf) LIZ(2131367999);
        n.LIZIZ(r0, "");
        r0.setClickable(z2);
        C31271Mf r12 = (C31271Mf) LIZ(2131373014);
        if (z2) {
            drawable3 = this.LJIIJ;
        } else {
            drawable3 = this.LJIIJJI;
        }
        r12.setImageDrawable(drawable3);
        C31271Mf r02 = (C31271Mf) LIZ(2131373014);
        n.LIZIZ(r02, "");
        r02.setClickable(z2);
    }

    public final void LIZ(long j) {
        if (!C13250gF.LJIIJ) {
            C31661Ns r1 = this.LIZJ;
            if (r1 == null) {
                n.LIZ("");
            }
            r1.LIZ(true, j);
            C46331sV r12 = (C46331sV) LIZ(2131367820);
            n.LIZIZ(r12, "");
            r12.setText(C10000b0.LIZ(2131829221));
            ImageView imageView = (ImageView) LIZ(2131368580);
            n.LIZIZ(imageView, "");
            imageView.setClickable(false);
            LIZ(false);
        }
    }

    /* JADX WARNING: type inference failed for: r5v0, types: [com.bytedance.android.livesdk.LiveDialogFragment, androidx.fragment.app.Fragment, com.bytedance.android.live.effect.music.LiveMusicDialog] */
    public final void onViewCreated(View view, Bundle bundle) {
        M12.LIZ(view);
        LiveMusicDialog.super.onViewCreated(view, bundle);
        LinearLayout linearLayout = (LinearLayout) LIZ(2131363684);
        n.LIZIZ(linearLayout, "");
        ViewGroup.LayoutParams layoutParams = linearLayout.getLayoutParams();
        Resources resources = getResources();
        n.LIZIZ(resources, "");
        layoutParams.height = (resources.getDisplayMetrics().heightPixels * 34) / 100;
        LIZ(2131368293).setOnClickListener(new C13050fv(this));
        H1f LIZ2 = LIZ(2131367779);
        LIZ2.getContext();
        LIZ2.setLayoutManager(new LinearLayoutManager(0, false));
        C31661Ns r3 = new C31661Ns(this.LJIILIIL, C46541sq.LIZ);
        this.LIZJ = r3;
        LIZ2.setAdapter(r3);
        LIZ2.LIZ((AnonymousClass0EC) new C31671Nt());
        LIZ2.setHasFixedSize(true);
        C13250gF r0 = C13250gF.LJIIL;
        M12.LIZ(this);
        r0.LIZJ().add(this);
        LJIIJJI();
        LIZ(C13250gF.LJIIJ);
        C31271Mf r1 = (C31271Mf) LIZ(2131367999);
        n.LIZIZ(r1, "");
        G2l.LIZ(r1, new C46511sn(this));
        C31271Mf r12 = (C31271Mf) LIZ(2131373014);
        n.LIZIZ(r12, "");
        G2l.LIZ(r12, new C46521so(this));
        ImageView imageView = (ImageView) LIZ(2131368580);
        n.LIZIZ(imageView, "");
        G2l.LIZ(imageView, new C46531sp(this));
        getContext();
        if (!LJII()) {
            ((C10940cW) LIZ(2131367804)).LIZ("OFFLINE");
            return;
        }
        ((C10940cW) LIZ(2131367804)).LIZ("LOADING");
        C13250gF.LJIIL.LIZ((LsC<? super List<C13220gC>, 2Pr>) new C46501sm(this));
    }
}
