package we;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.j2;
import ie.v1;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import org.drive_hunter.R;
import t4.f;
import xyz.stream.api.entity.LiveChannelEntity;
import xyz.stream.view.BaseRecycleViewAdapter;
import xyz.stream.view.CustomImageView;
import xyz.stream.view.OnItemListener;
import xyz.stream.view.PlayingView;
import xyz.stream.view.SingleTypeAdapter;
import xyz.stream.view.UiUtils;

/* JADX INFO: loaded from: classes3.dex */
public final class c extends SingleTypeAdapter {

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public int f34283b;

    public c(ArrayList arrayList, Activity activity) {
        super(arrayList, activity);
        this.f34283b = -1;
    }

    public static void e(c cVar, v1 v1Var, int i10, LiveChannelEntity liveChannelEntity, View view, boolean z10) {
        cVar.getClass();
        v1Var.f27551g.setSelected(z10);
        TextView textView = v1Var.f27551g;
        PlayingView playingView = v1Var.f27550f;
        LinearLayout linearLayout = v1Var.f27545a;
        TextView textView2 = v1Var.f27547c;
        TextView textView3 = v1Var.f27549e;
        if (z10) {
            OnItemListener onItemListener = cVar.onItemListener;
            if (onItemListener != null) {
                onItemListener.onItemFocus(view, i10);
            }
            textView3.setSelected(true);
            textView2.setSelected(true);
            linearLayout.setBackgroundResource(R.drawable.shape_radius_red_select_12);
            Activity activity = cVar.context;
            Object obj = g0.d.f26125a;
            textView3.setTextColor(activity.getColor(R.color.main_text));
            textView2.setTextColor(cVar.context.getColor(R.color.main_text));
            playingView.setBarColorRes(R.color.main_text);
            textView.setTextColor(cVar.context.getColor(R.color.main_text));
            return;
        }
        textView3.setSelected(false);
        textView2.setSelected(false);
        linearLayout.setBackgroundResource(liveChannelEntity.getId().intValue() == cVar.f34283b ? R.drawable.shape_radius_black3_12 : R.color.transparent);
        Activity activity2 = cVar.context;
        Object obj2 = g0.d.f26125a;
        int i11 = R.color.white;
        textView3.setTextColor(activity2.getColor(R.color.white));
        textView2.setTextColor(cVar.context.getColor(R.color.black_9));
        playingView.setBarColorRes(R.color.main_color);
        Activity activity3 = cVar.context;
        if (liveChannelEntity.getId().intValue() != cVar.f34283b) {
            i11 = R.color.black_9;
        }
        textView.setTextColor(activity3.getColor(i11));
    }

    @Override // xyz.stream.view.SingleTypeAdapter
    public final v3.a createBinding(ViewGroup viewGroup) {
        return v1.inflate(LayoutInflater.from(this.context), viewGroup, false);
    }

    public final void f(int i10) {
        int iIndexOf;
        int iIndexOf2;
        int i11 = this.f34283b;
        this.f34283b = i10;
        if (i11 > -1) {
            Object obj = f.x(this.dataList).e(new xyz.netfly.mobile.player.c(i11, 7)).g().f32947a;
            if (obj == null) {
                obj = null;
            }
            LiveChannelEntity liveChannelEntity = (LiveChannelEntity) obj;
            if (liveChannelEntity != null && (iIndexOf2 = this.dataList.indexOf(liveChannelEntity)) >= 0) {
                notifyItemChanged(iIndexOf2);
            }
        }
        Object obj2 = f.x(this.dataList).e(new xyz.netfly.mobile.player.c(i10, 8)).g().f32947a;
        LiveChannelEntity liveChannelEntity2 = (LiveChannelEntity) (obj2 != null ? obj2 : null);
        if (liveChannelEntity2 == null || (iIndexOf = this.dataList.indexOf(liveChannelEntity2)) < 0) {
            return;
        }
        notifyItemChanged(iIndexOf);
    }

    @Override // xyz.stream.view.SingleTypeAdapter
    public final void onBindData(v3.a aVar, Object obj, int i10) {
        int color;
        v1 v1Var = (v1) aVar;
        LiveChannelEntity liveChannelEntity = (LiveChannelEntity) obj;
        v1Var.f27551g.setText(liveChannelEntity.getId().intValue() > 0 ? String.format(Locale.getDefault(), "%05d", liveChannelEntity.getId()) : "");
        LinearLayout linearLayout = v1Var.f27545a;
        if (linearLayout.isFocused()) {
            Activity activity = this.context;
            Object obj2 = g0.d.f26125a;
            color = activity.getColor(R.color.main_text);
        } else {
            Activity activity2 = this.context;
            Object obj3 = g0.d.f26125a;
            color = activity2.getColor(R.color.white);
        }
        TextView textView = v1Var.f27549e;
        textView.setTextColor(color);
        int iIntValue = liveChannelEntity.getId().intValue();
        int i11 = this.f34283b;
        TextView textView2 = v1Var.f27551g;
        PlayingView playingView = v1Var.f27550f;
        TextView textView3 = v1Var.f27547c;
        if (iIntValue == i11) {
            playingView.setVisibility(0);
            playingView.setBarColorRes(linearLayout.isFocused() ? R.color.main_text : R.color.main_color);
            linearLayout.setBackgroundResource(linearLayout.isFocused() ? R.drawable.shape_radius_red_select_12 : R.drawable.shape_radius_black3_12);
            textView2.setTextColor(linearLayout.isFocused() ? this.context.getColor(R.color.main_text) : this.context.getColor(R.color.white));
            textView3.setTextColor(linearLayout.isFocused() ? this.context.getColor(R.color.main_text) : this.context.getColor(R.color.black_9));
        } else {
            playingView.setVisibility(8);
            linearLayout.setBackgroundResource(R.color.transparent);
            textView2.setTextColor(this.context.getColor(R.color.black_9));
            textView3.setTextColor(this.context.getColor(R.color.black_9));
        }
        re.a.u().getClass();
        int iT = re.a.t(liveChannelEntity);
        ImageView imageView = v1Var.f27546b;
        if (iT == 1) {
            imageView.setVisibility(0);
            imageView.setImageResource(R.drawable.icon_premium);
        } else if (iT == 2) {
            imageView.setVisibility(0);
            imageView.setImageResource(R.drawable.icon_premium_2);
        } else {
            imageView.setVisibility(8);
        }
        if (liveChannelEntity.getExtra() == null || liveChannelEntity.getExtra().isEmpty()) {
            textView3.setText("");
        } else {
            textView3.setText(liveChannelEntity.getExtra());
        }
        linearLayout.setOnFocusChangeListener(new a(this, v1Var, i10, liveChannelEntity));
        textView.setText(liveChannelEntity.getName());
        String logo = liveChannelEntity.getLogo();
        CustomImageView customImageView = v1Var.f27548d;
        if (logo == null || liveChannelEntity.getLogo().isEmpty()) {
            customImageView.clearImage();
        } else {
            customImageView.load(CustomImageView.Request.raw(liveChannelEntity.getLogo()).radius(UiUtils.dp2px(12.0f)).size(UiUtils.dp2px(60.0f), UiUtils.dp2px(60.0f)).scaleType(ImageView.ScaleType.FIT_CENTER));
        }
    }

    @Override // androidx.recyclerview.widget.d1
    public final void onBindViewHolder(j2 j2Var, int i10, List list) {
        BaseRecycleViewAdapter.BaseViewHolder baseViewHolder = (BaseRecycleViewAdapter.BaseViewHolder) j2Var;
        if (list.isEmpty()) {
            super.onBindViewHolder(baseViewHolder, i10, list);
            return;
        }
        LiveChannelEntity liveChannelEntity = (LiveChannelEntity) getItem(i10);
        v1 v1Var = (v1) baseViewHolder.binding;
        if (v1Var != null) {
            v1Var.f27547c.setText(liveChannelEntity.getExtra());
        }
    }
}
