package com.ss.android.ugc.aweme.detail.panel;

import X.070;
import X.0Bs;
import X.0Bv;
import X.0Bx;
import X.0By;
import X.0CH;
import X.0HH;
import X.1hK;
import X.2GD;
import X.2GO;
import X.2Pr;
import X.2nK;
import X.3Fl;
import X.3ae;
import X.BD0;
import X.BD1;
import X.BD2;
import X.BD3;
import X.BD4;
import X.BD5;
import X.BD8;
import X.BP0;
import X.C1683AgB;
import X.C3248BCy;
import X.C3251BDb;
import X.C3252BDc;
import X.D1G;
import X.LnI;
import X.LsC;
import X.M12;
import X.Qxn;
import X.SsI;
import X.T3s;
import X.TnV;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import androidx.fragment.app.Fragment;
import com.bytedance.assem.arch.core.AssemSupervisor;
import com.bytedance.assem.arch.core.Assembler;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.music.model.Music;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import kotlin.h.b.n;
import kotlin.o.z;

public final class MusicVideoDetailFragmentPanel extends MusicFeedPanel implements 2GO {
    public static final BD8 LJJJJI = new BD8((byte) 0);
    public Qxn LJJJJ;
    public AnimatorSet LLLFF;
    public final Long LLLFFI;

    static {
        Covode.recordClassIndex(63744);
    }

    public final void LJIJ() {
        MusicVideoDetailFragmentPanel.super.LJIJ();
        SsI.LIZIZ(this);
        if (this.LLLFFI != null) {
            BP0.LIZ.LIZIZ(new BD3(this));
        }
    }

    public final void cs_() {
        super.cs_();
        if (this.LJJJJIZL != null) {
            ViewGroup.MarginLayoutParams marginLayoutParams = null;
            if (3Fl.LJIILIIL != 0) {
                View view = this.LJJJJIZL;
                n.LIZIZ(view, "");
                ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
                if (layoutParams instanceof ViewGroup.MarginLayoutParams) {
                    marginLayoutParams = layoutParams;
                }
                ViewGroup.MarginLayoutParams marginLayoutParams2 = (ViewGroup.MarginLayoutParams) marginLayoutParams;
                if (marginLayoutParams2 != null) {
                    Resources system = Resources.getSystem();
                    n.LIZIZ(system, "");
                    marginLayoutParams2.height = LnI.LIZ(TypedValue.applyDimension(1, 44.0f, system.getDisplayMetrics()));
                    Resources system2 = Resources.getSystem();
                    n.LIZIZ(system2, "");
                    marginLayoutParams2.bottomMargin = LnI.LIZ(TypedValue.applyDimension(1, 6.0f, system2.getDisplayMetrics()));
                    return;
                }
                return;
            }
            View view2 = this.LJJJJIZL;
            n.LIZIZ(view2, "");
            ViewGroup.LayoutParams layoutParams2 = view2.getLayoutParams();
            if (layoutParams2 instanceof ViewGroup.MarginLayoutParams) {
                marginLayoutParams = layoutParams2;
            }
            ViewGroup.MarginLayoutParams marginLayoutParams3 = marginLayoutParams;
            if (marginLayoutParams3 != null) {
                Resources system3 = Resources.getSystem();
                n.LIZIZ(system3, "");
                marginLayoutParams3.height = LnI.LIZ(TypedValue.applyDimension(1, 36.0f, system3.getDisplayMetrics()));
                Resources system4 = Resources.getSystem();
                n.LIZIZ(system4, "");
                marginLayoutParams3.bottomMargin = LnI.LIZ(TypedValue.applyDimension(1, 6.0f, system4.getDisplayMetrics()));
            }
        }
    }

    public final void LJIIL() {
        String str;
        String str2;
        Qxn qxn;
        View findViewById;
        View findViewById2;
        if (this.LLL != null) {
            Activity activity = this.LLL;
            String str3 = "";
            n.LIZIZ(activity, str3);
            if (!activity.isFinishing() && bt_() != null && this.LJJJJJ == null) {
                super.LJIIL();
                TnV tnV = this.LLIFFJFJJ;
                n.LIZIZ(tnV, str3);
                String from = tnV.getFrom();
                if (from == null) {
                    from = str3;
                }
                HashMap hashMap = new HashMap();
                if (n.LIZ(from, "from_music_video_feeds")) {
                    str = "single_song_trends";
                } else {
                    str = "single_song";
                }
                hashMap.put("enter_from", str);
                Music music = this.LIZIZ;
                if (music == null || (str2 = String.valueOf(music.getId())) == null) {
                    TnV tnV2 = this.LLIFFJFJJ;
                    n.LIZIZ(tnV2, str3);
                    str2 = tnV2.getMusicId();
                    if (str2 == null) {
                        str2 = str3;
                    }
                }
                hashMap.put("music_id", str2);
                String str4 = this.LJJJ;
                if (str4 == null) {
                    str4 = str3;
                }
                hashMap.put("group_id", str4);
                2nK.LIZ("show_music_title_button", hashMap);
                View view = this.LJJJJIZL;
                if (view != null) {
                    qxn = (Qxn) view.findViewById(2131364812);
                } else {
                    qxn = null;
                }
                this.LJJJJ = qxn;
                Fragment bt_ = bt_();
                n.LIZIZ(bt_, str3);
                0CH activity2 = bt_.getActivity();
                if (activity2 != null && (findViewById = this.LJJJJIZL.findViewById(2131367844)) != null && (findViewById2 = this.LJJJJIZL.findViewById(2131367845)) != null) {
                    Activity activity3 = this.LLL;
                    if (activity3 != null) {
                        if (3Fl.LJIILIIL != 0) {
                            ViewGroup.LayoutParams layoutParams = findViewById.getLayoutParams();
                            if (!(layoutParams instanceof ViewGroup.MarginLayoutParams)) {
                                layoutParams = null;
                            }
                            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
                            if (marginLayoutParams != null) {
                                Resources system = Resources.getSystem();
                                n.LIZIZ(system, str3);
                                marginLayoutParams.height = LnI.LIZ(TypedValue.applyDimension(1, 44.0f, system.getDisplayMetrics()));
                                Resources system2 = Resources.getSystem();
                                n.LIZIZ(system2, str3);
                                marginLayoutParams.bottomMargin = LnI.LIZ(TypedValue.applyDimension(1, 6.0f, system2.getDisplayMetrics()));
                            }
                            3ae r1 = new 3ae();
                            r1.LIZIZ = 2130968619;
                            Resources system3 = Resources.getSystem();
                            n.LIZIZ(system3, str3);
                            r1.LIZJ = Float.valueOf(TypedValue.applyDimension(1, 28.0f, system3.getDisplayMetrics()));
                            findViewById2.setBackground(r1.LIZ(activity3));
                        } else {
                            ViewGroup.LayoutParams layoutParams2 = findViewById.getLayoutParams();
                            if (!(layoutParams2 instanceof ViewGroup.MarginLayoutParams)) {
                                layoutParams2 = null;
                            }
                            ViewGroup.MarginLayoutParams marginLayoutParams2 = (ViewGroup.MarginLayoutParams) layoutParams2;
                            if (marginLayoutParams2 != null) {
                                Resources system4 = Resources.getSystem();
                                n.LIZIZ(system4, str3);
                                marginLayoutParams2.height = LnI.LIZ(TypedValue.applyDimension(1, 36.0f, system4.getDisplayMetrics()));
                                Resources system5 = Resources.getSystem();
                                n.LIZIZ(system5, str3);
                                marginLayoutParams2.bottomMargin = LnI.LIZ(TypedValue.applyDimension(1, 6.0f, system5.getDisplayMetrics()));
                            }
                            3ae r12 = new 3ae();
                            r12.LIZIZ = 2130968618;
                            Resources system6 = Resources.getSystem();
                            n.LIZIZ(system6, str3);
                            r12.LIZJ = Float.valueOf(TypedValue.applyDimension(1, 28.0f, system6.getDisplayMetrics()));
                            findViewById2.setBackground(r12.LIZ(activity3));
                        }
                    }
                    TnV tnV3 = this.LLIFFJFJJ;
                    n.LIZIZ(tnV3, str3);
                    String from2 = tnV3.getFrom();
                    if (from2 != null) {
                        str3 = from2;
                    }
                    D1G<? extends C1683AgB> LIZ = BP0.LIZ.LIZ(str3);
                    if (LIZ != null) {
                        AssemSupervisor LIZ2 = C3252BDc.LIZ((1hK) activity2);
                        if (LIZ2 == null || LIZ2.LJIIIIZZ == null) {
                            C3251BDb.LIZ((1hK) activity2, (LsC<? super Assembler, 2Pr>) new BD1(activity2, str3, LIZ, findViewById2, this));
                            return;
                        }
                        0Bx LIZ3 = 0By.LIZ(activity2, (0Bv) null);
                        if (2GD.LIZ) {
                            0Bs.LIZ(LIZ3, activity2);
                        }
                        Assembler LIZ4 = LIZ3.LIZ(Assembler.class);
                        LIZ4.LIZ(activity2, new C3248BCy(activity2, str3, LIZ, findViewById2, this));
                        LIZ4.LIZJ(activity2, new BD5(activity2, str3, LIZ, findViewById2, this));
                    }
                }
            }
        }
    }

    private final int[] LIZ(Context context) {
        return new int[]{Color.parseColor("#333333"), 070.LIZJ(context, 2131099762)};
    }

    public final View LIZ(RelativeLayout relativeLayout) {
        View LIZ = 0HH.LIZ(LayoutInflater.from(this.LLL), 2131559530, relativeLayout, false);
        if (this.LIZIZ != null) {
            Qxn findViewById = LIZ.findViewById(2131364812);
            n.LIZIZ(findViewById, "");
            LIZ(findViewById, LIZ(this.LIZIZ));
        }
        n.LIZIZ(LIZ, "");
        return LIZ;
    }

    public final void LIZIZ(View view) {
        View view2;
        View view3 = null;
        if (view != null) {
            view2 = view.findViewById(2131364801);
            view3 = view.findViewById(2131364825);
        } else {
            view2 = null;
        }
        Activity activity = this.LLL;
        if (activity != null) {
            if (view2 != null) {
                view2.setBackground(new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, LIZ((Context) activity)));
            }
            if (view3 != null) {
                view3.setBackground(new GradientDrawable(GradientDrawable.Orientation.RIGHT_LEFT, LIZ((Context) activity)));
            }
        }
        super.LIZIZ(view);
    }

    public final void LIZ(View view) {
        TnV tnV = this.LLIFFJFJJ;
        String str = "";
        n.LIZIZ(tnV, str);
        String from = tnV.getFrom();
        if (from == null) {
            from = str;
        }
        if (n.LIZ(from, "from_music_video_feeds")) {
            TnV tnV2 = this.LLIFFJFJJ;
            n.LIZIZ(tnV2, str);
            String eventType = tnV2.getEventType();
            if (eventType != null) {
                str = eventType;
            }
            LIZ(str, "single_song_trends");
            return;
        }
        LIZ("single_song", "single_song");
    }

    public final void LIZJ(View view) {
        Drawable drawable;
        super.LIZJ(view);
        if (view != null) {
            Context context = view.getContext();
            if (context != null) {
                3ae r4 = new 3ae();
                r4.LIZ = Integer.valueOf(070.LIZJ(context, 2131099731));
                Resources system = Resources.getSystem();
                n.LIZIZ(system, "");
                r4.LIZJ = Float.valueOf(TypedValue.applyDimension(1, 32.0f, system.getDisplayMetrics()));
                drawable = r4.LIZ(context);
            } else {
                drawable = null;
            }
            view.setBackground(drawable);
        }
    }

    public final void LIZ(BD4 bd4) {
        Music music;
        String text;
        long j = bd4.LIZJ;
        Long l = this.LLLFFI;
        if (l != null && j == l.longValue() && bd4.LIZIZ != null && this.LJJJJ != null && (music = bd4.LIZIZ) != null) {
            String LIZ = LIZ(music);
            if (LIZ != null) {
                Qxn qxn = this.LJJJJ;
                String str = null;
                if (!(qxn == null || qxn.getText() == null)) {
                    Qxn qxn2 = this.LJJJJ;
                    if (!(qxn2 == null || (text = qxn2.getText()) == null)) {
                        Objects.requireNonNull(text, "null cannot be cast to non-null type kotlin.CharSequence");
                        str = z.LIZIZ(text).toString();
                    }
                    if (n.LIZ(str, z.LIZIZ(LIZ).toString())) {
                        return;
                    }
                }
            }
            int i = bd4.LIZ;
            if (i == 1) {
                LIZ(this.LJJJJ, LIZ);
            } else if (i == 2) {
                AnimatorSet animatorSet = this.LLLFF;
                if (animatorSet != null) {
                    animatorSet.cancel();
                }
                Qxn qxn3 = this.LJJJJ;
                if (qxn3 != null) {
                    ObjectAnimator ofFloat = ObjectAnimator.ofFloat(qxn3, "alpha", new float[]{1.0f, 0.0f});
                    ofFloat.setDuration(100);
                    Qxn qxn4 = this.LJJJJ;
                    if (qxn4 != null) {
                        ObjectAnimator ofFloat2 = ObjectAnimator.ofFloat(qxn4, "alpha", new float[]{0.0f, 1.0f});
                        ofFloat2.setDuration(100);
                        ofFloat2.addListener(new BD0(this, LIZ));
                        AnimatorSet animatorSet2 = new AnimatorSet();
                        this.LLLFF = animatorSet2;
                        animatorSet2.playSequentially(new Animator[]{ofFloat, ofFloat2});
                        AnimatorSet animatorSet3 = this.LLLFF;
                        if (animatorSet3 != null) {
                            animatorSet3.start();
                        }
                    }
                }
            }
        }
    }

    public /* synthetic */ MusicVideoDetailFragmentPanel(Bundle bundle, TnV tnV) {
        this(bundle, tnV, (Long) null);
    }

    public final void LIZ(View view, Bundle bundle) {
        MusicVideoDetailFragmentPanel.super.LIZ(view, bundle);
        if (this.LLLFFI != null) {
            BP0.LIZ.LIZ((LsC<? super BD4, 2Pr>) new BD2(this));
        }
    }

    public final void LIZ(List<Object> list, boolean z) {
        MusicVideoDetailFragmentPanel.super.LIZ(list, z);
        if (BP0.LIZ.LIZ(this.LLL) && list != null && list.size() > 0) {
            T3s t3s = this.LJJJLIIL;
            n.LIZIZ(t3s, "");
            t3s.setCurrentItem(0);
        }
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public MusicVideoDetailFragmentPanel(Bundle bundle, TnV tnV, Long l) {
        super(bundle, tnV);
        M12.LIZ(tnV);
        this.LLLFFI = l;
    }
}
