package com.ss.android.ugc.aweme.music.ui.viewholder;

import X.0CB;
import X.0CH;
import X.2K7;
import X.2Ph;
import X.2ha;
import X.3EX;
import X.4hQ;
import X.8nu;
import X.9Zw;
import X.AnonymousClass9w1;
import X.C3491BMh;
import X.C3589BQb;
import X.C3823BZb;
import X.C3824BZc;
import X.C3825BZd;
import X.C3835BZn;
import X.C6519Cbz;
import X.EUi;
import X.M12;
import X.OD6;
import X.QHW;
import X.QIe;
import X.QJt;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Animatable;
import android.os.Build;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.bytedance.covode.number.Covode;
import com.bytedance.jedi.ext.adapter.JediSimpleViewHolder;
import com.bytedance.lighten.loader.SmartImageView;
import com.ss.android.ugc.aweme.base.model.UrlModel;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.feed.model.AwemeTextLabelModel;
import com.ss.android.ugc.aweme.feed.model.Video;
import kotlin.h.b.n;

public final class MusicDetailVideoItemViewHolder extends JediSimpleViewHolder<Aweme> implements C3589BQb, C3589BQb {
    public static final C3824BZc LJIILIIL = new C3824BZc((byte) 0);
    public final Context LJFF;
    public Aweme LJI;
    public EUi LJIIIZ;
    public final boolean LJIIJ;
    public final C3491BMh LJIIJJI;
    public final String LJIIL;
    public boolean LJIILJJIL;
    public final OD6 LJIILL;
    public final TextView LJIILLIIL;
    public final TextView LJIIZILJ;
    public final TextView LJIJ;
    public final TextView LJIJI;
    public final View LJIJJ;
    public final SmartImageView LJIJJLI;
    public final float LJIL;
    public boolean LJJ;

    static {
        Covode.recordClassIndex(94314);
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
        super.onStateChanged(r1, r2);
    }

    public final void LIZJ() {
        LJIIL();
    }

    public final boolean bU_() {
        return this.LJIILJJIL;
    }

    public final void LJ() {
        MusicDetailVideoItemViewHolder.super.LJ();
        this.LJJ = true;
    }

    public final void LJFF() {
        MusicDetailVideoItemViewHolder.super.LJFF();
        this.LJJ = true;
    }

    public final void LJI() {
        MusicDetailVideoItemViewHolder.super.LJI();
        this.LJJ = true;
    }

    public final void LJII() {
        MusicDetailVideoItemViewHolder.super.LJII();
        this.LJJ = false;
    }

    public final void LJIIIIZZ() {
        MusicDetailVideoItemViewHolder.super.LJIIIIZZ();
        this.LJJ = false;
    }

    public final void LJIIIZ() {
        MusicDetailVideoItemViewHolder.super.LJIIIZ();
        this.LJJ = false;
    }

    public final void aY_() {
        this.LJIJJLI.LIZJ();
    }

    public final void ba_() {
        this.LJIJJLI.LIZIZ();
    }

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

    public final void dj_() {
        MusicDetailVideoItemViewHolder.super.dj_();
        if (this.LJI != null) {
            getAdapterPosition();
        }
    }

    private final boolean LJIILL() {
        boolean z;
        if (Build.VERSION.SDK_INT >= 23) {
            z = true;
        } else {
            z = false;
        }
        return 2Ph.LIZ("aweme_app", "use_dynamic_cover", z);
    }

    private final void LJIIL() {
        Aweme aweme = this.LJI;
        if (aweme != null) {
            Video video = aweme.getVideo();
            n.LIZIZ(video, "");
            if (LIZ(video, "MusicDetailVideoItemViewHolder")) {
                this.LJIILJJIL = true;
            } else {
                LIZ(video.getCover(), "MusicDetailVideoItemViewHolder");
            }
        }
    }

    private boolean LJIILIIL() {
        if (9Zw.LIZ()) {
            return false;
        }
        View view = this.itemView;
        n.LIZIZ(view, "");
        view.getContext();
        if (LJIILJJIL()) {
            View view2 = this.itemView;
            n.LIZIZ(view2, "");
            if (!8nu.LIZ(view2.getContext())) {
                return false;
            }
        }
        if (LJIILL()) {
            return true;
        }
        return false;
    }

    public final void aZ_() {
        if (this.LJIJJLI.getController() != null) {
            QIe controller = this.LJIJJLI.getController();
            if (controller == null) {
                n.LIZIZ();
            }
            n.LIZIZ(controller, "");
            if (controller.LJIIIIZZ() != null) {
                QIe controller2 = this.LJIJJLI.getController();
                if (controller2 == null) {
                    n.LIZIZ();
                }
                n.LIZIZ(controller2, "");
                Animatable LJIIIIZZ = controller2.LJIIIIZZ();
                if (LJIIIIZZ instanceof C3825BZd) {
                    ((C3825BZd) LJIIIIZZ).LIZ();
                }
            }
        }
    }

    public final void LIZ(boolean z) {
        this.LJIJJLI.setUserVisibleHint(z);
    }

    public final void LIZIZ(boolean z) {
        this.LJIJJLI.setAttached(z);
    }

    public final /* synthetic */ void LIZ(Object obj) {
        Aweme aweme = (Aweme) obj;
        M12.LIZ(aweme);
        this.LJIJJLI.setOnClickListener(new C3823BZb(this, aweme));
        this.LJIJJLI.setAnimationListener(this.LJIIIZ);
        this.LJIJJLI.setUserVisibleHint(false);
        SmartImageView smartImageView = this.LJIJJLI;
        getPosition();
        smartImageView.setContentDescription("");
        this.LJI = aweme;
        if (this.LJIIJ) {
            LJIIL();
        }
        this.LJIILL.setVisibility(4);
        this.LJIILLIIL.setVisibility(8);
        this.LJIIZILJ.setVisibility(8);
        this.LJIJ.setVisibility(8);
        LIZ(this.LJIJJ, aweme);
        this.LJIJI.setVisibility(8);
        LIZ((View) this.LJIJI, aweme);
        if (aweme.getMusicStarter() != null) {
            this.LJIJ.setVisibility(0);
            if (!TextUtils.isEmpty(aweme.getLabelMusicStarterText())) {
                this.LJIJ.setText(aweme.getLabelMusicStarterText());
            }
        }
        if (aweme.isPgcShow() && aweme.getTextTopLabels() != null && aweme.getTextTopLabels().size() > 0) {
            this.LJIILLIIL.setVisibility(0);
            this.LJIILL.setVisibility(8);
            TextView textView = this.LJIILLIIL;
            Object obj2 = aweme.getTextTopLabels().get(0);
            n.LIZIZ(obj2, "");
            AwemeTextLabelModel awemeTextLabelModel = (AwemeTextLabelModel) obj2;
            if (TextUtils.isEmpty(awemeTextLabelModel.getLabelName())) {
                textView.setVisibility(8);
                return;
            }
            textView.setText(awemeTextLabelModel.getLabelName());
            textView.setTextSize(0, this.LJIL);
            textView.setTextColor(Color.parseColor(awemeTextLabelModel.getTextColor()));
            textView.setBackground(C6519Cbz.LIZ(Color.parseColor(awemeTextLabelModel.getBgColor()), (float) 2ha.LIZ(2.0d)));
            textView.setSingleLine();
        }
    }

    private final void LIZ(View view, Aweme aweme) {
        if (4hQ.LJFF(aweme)) {
            view.setVisibility(0);
        } else {
            view.setVisibility(8);
        }
    }

    private final void LIZ(UrlModel urlModel, String str) {
        Video video;
        QJt LIZ = QHW.LIZ(3EX.LIZ(urlModel));
        int[] LIZ2 = AnonymousClass9w1.LIZ(200);
        if (LIZ2 != null) {
            LIZ.LIZIZ(LIZ2);
        }
        LIZ.LJJIIZ = this.LJIJJLI;
        LIZ.LIZ(str);
        LIZ.LIZJ();
        Aweme aweme = this.LJI;
        if (aweme != null && (video = aweme.getVideo()) != null) {
            video.setCachedOuterCoverUrl(urlModel);
            video.setCachedOuterCoverSize(LIZ2);
        }
    }

    private final boolean LIZ(Video video, String str) {
        if (!LJIILIIL()) {
            return false;
        }
        C3835BZn bZn = C3835BZn.LIZ;
        SmartImageView smartImageView = this.LJIJJLI;
        Video video2 = video;
        if (video2 == null) {
            n.LIZIZ();
        }
        if (C3835BZn.LIZ(bZn, smartImageView, video2, str, true, false, 96)) {
            return true;
        }
        return false;
    }
}
