package xyz.netfly.ui.live.tv;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;
import f.a;
import g0.d;
import ie.j5;
import org.drive_hunter.R;
import xyz.netfly.MyApplication;
import xyz.stream.utils.e;
import xyz.stream.view.CustomImageView;
import xyz.stream.view.UiUtils;
import xyz.stream.view.tvrecyclerview.TvRecyclerView;

/* JADX INFO: loaded from: classes3.dex */
public class CustomLiveControl extends FrameLayout {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final j5 f35466a;

    public CustomLiveControl(Context context) {
        this(context, null);
    }

    private void setFavoriteIcon(boolean z10) {
        Drawable drawable = a.getDrawable(getContext(), z10 ? R.drawable.like : R.drawable.like_no);
        if (drawable != null) {
            drawable = drawable.mutate();
        }
        j5 j5Var = this.f35466a;
        if (drawable != null && !z10) {
            Context context = MyApplication.f34822a;
            int i10 = j5Var.f27088g.hasFocus() ? R.color.main_text : R.color.white;
            Object obj = d.f26125a;
            drawable.setTint(context.getColor(i10));
        }
        b(j5Var.f27088g, drawable);
    }

    public final void a(TextView textView, int i10, boolean z10) {
        Drawable drawable = a.getDrawable(getContext(), i10);
        if (drawable != null) {
            drawable = drawable.mutate();
            Context context = MyApplication.f34822a;
            int i11 = z10 ? R.color.main_text : R.color.white;
            Object obj = d.f26125a;
            drawable.setTint(context.getColor(i11));
        }
        b(textView, drawable);
    }

    public final void b(TextView textView, Drawable drawable) {
        if (drawable != null) {
            int intrinsicWidth = drawable.getIntrinsicWidth();
            int intrinsicHeight = drawable.getIntrinsicHeight();
            if (intrinsicWidth <= 0 || intrinsicHeight <= 0) {
                intrinsicWidth = (int) (TypedValue.applyDimension(1, 48.0f, getResources().getDisplayMetrics()) + 0.5f);
                intrinsicHeight = intrinsicWidth;
            }
            drawable.setBounds(0, 0, intrinsicWidth, intrinsicHeight);
        }
        textView.setCompoundDrawablesRelative(drawable, null, null, null);
    }

    public TextView getBtnAudio() {
        return this.f35466a.f27090i;
    }

    public TextView getBtnEpg() {
        return this.f35466a.f27087f;
    }

    public TextView getBtnLike() {
        return this.f35466a.f27088g;
    }

    public TextView getBtnQuality() {
        return this.f35466a.f27093l;
    }

    public TextView getBtnSubtitle() {
        return this.f35466a.f27094m;
    }

    public TextView getChannelList() {
        return this.f35466a.f27086e;
    }

    public TvRecyclerView getRvEpg() {
        return this.f35466a.f27089h;
    }

    public void setAudioIcon(boolean z10) {
        a(this.f35466a.f27090i, R.drawable.audio_white, z10);
    }

    public void setAudioText(String str) {
        if (str == null || str.isEmpty()) {
            return;
        }
        this.f35466a.f27090i.setText(str);
    }

    public void setChannelListIcon(boolean z10) {
        a(this.f35466a.f27086e, R.drawable.ic_channels, z10);
    }

    public void setData(String str, String str2, String str3, boolean z10) {
        setFavoriteIcon(z10);
        j5 j5Var = this.f35466a;
        j5Var.f27092k.setText(str);
        j5Var.f27091j.setText(str2);
        CustomImageView customImageView = j5Var.f27084c;
        if (str3 == null || str3.isEmpty()) {
            customImageView.clearImage();
        } else {
            int iApplyDimension = (int) (TypedValue.applyDimension(1, 120.0f, getResources().getDisplayMetrics()) + 0.5f);
            customImageView.load(CustomImageView.Request.raw(str3).radius((int) (TypedValue.applyDimension(1, 12.0f, getResources().getDisplayMetrics()) + 0.5f)).size(iApplyDimension, iApplyDimension).scaleType(ImageView.ScaleType.FIT_CENTER));
        }
    }

    public void setEpgIcon(boolean z10) {
        a(this.f35466a.f27087f, R.drawable.live_epg, z10);
    }

    public void setLiked(boolean z10) {
        setFavoriteIcon(z10);
    }

    public void setQualityIcon(boolean z10) {
        a(this.f35466a.f27093l, R.drawable.live_hq, z10);
    }

    public void setQualityText(String str) {
        if (str == null || str.isEmpty()) {
            return;
        }
        this.f35466a.f27093l.setText(str);
    }

    public void setSubtitleIcon(boolean z10) {
        a(this.f35466a.f27094m, R.drawable.subtitle_white, z10);
    }

    public void setSubtitleText(String str) {
        if (str == null || str.isEmpty()) {
            return;
        }
        this.f35466a.f27094m.setText(str);
    }

    public CustomLiveControl(Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public CustomLiveControl(Context context, @Nullable AttributeSet attributeSet, int i10) {
        super(context, attributeSet, i10);
        this.f35466a = j5.inflate(LayoutInflater.from(context), this, true);
        setChannelListIcon(false);
        setFavoriteIcon(false);
        setQualityIcon(false);
        setEpgIcon(false);
        setAudioIcon(false);
        setSubtitleIcon(false);
        if (e.d().f36119h) {
            UiUtils.setUnFocusable(getBtnLike());
            UiUtils.setUnFocusable(getBtnAudio());
            UiUtils.setUnFocusable(getBtnQuality());
            UiUtils.setUnFocusable(getBtnEpg());
            UiUtils.setUnFocusable(getBtnSubtitle());
        }
    }
}
