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.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import ie.u1;
import java.util.ArrayList;
import org.drive_hunter.R;
import xyz.stream.api.entity.LiveCategoryEntity;
import xyz.stream.view.OnItemListener;
import xyz.stream.view.SingleTypeAdapter;
import xyz.stream.view.UiUtils;

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

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

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

    public static void e(b bVar, int i10, LiveCategoryEntity liveCategoryEntity, u1 u1Var, View view, boolean z10) {
        if (z10) {
            OnItemListener onItemListener = bVar.onItemListener;
            if (onItemListener != null) {
                onItemListener.onItemFocus(view, i10);
            }
            if (liveCategoryEntity.getCategoryId().intValue() == -3) {
                UiUtils.setSvgPicture(u1Var.f27522b, R.drawable.live_search, Integer.valueOf(R.color.main_text));
            }
            TextView textView = u1Var.f27524d;
            Activity activity = bVar.context;
            Object obj = g0.d.f26125a;
            textView.setTextColor(activity.getColor(R.color.main_text));
            u1Var.f27523c.setTextColor(bVar.context.getColor(R.color.main_text));
            u1Var.f27524d.setSelected(true);
            u1Var.f27521a.setBackgroundResource(R.drawable.shape_radius_red_select_12);
            return;
        }
        bVar.getClass();
        int iIntValue = liveCategoryEntity.getCategoryId().intValue();
        int i11 = R.color.black_9;
        if (iIntValue == -3) {
            UiUtils.setSvgPicture(u1Var.f27522b, R.drawable.live_search, Integer.valueOf(R.color.black_9));
        }
        TextView textView2 = u1Var.f27524d;
        Activity activity2 = bVar.context;
        int i12 = liveCategoryEntity.getCategoryId().intValue() == bVar.f34282b ? R.color.white : R.color.black_9;
        Object obj2 = g0.d.f26125a;
        textView2.setTextColor(activity2.getColor(i12));
        Activity activity3 = bVar.context;
        if (liveCategoryEntity.getCategoryId().intValue() == bVar.f34282b) {
            i11 = R.color.white;
        }
        u1Var.f27523c.setTextColor(activity3.getColor(i11));
        u1Var.f27524d.setSelected(false);
        u1Var.f27521a.setBackgroundResource(liveCategoryEntity.getCategoryId().intValue() == bVar.f34282b ? R.drawable.shape_radius_black4_12 : R.color.transparent);
    }

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

    public final void f(int i10) {
        int i11 = this.f34282b;
        this.f34282b = i10;
        int i12 = 0;
        while (true) {
            if (i12 >= this.dataList.size()) {
                break;
            }
            if (((LiveCategoryEntity) this.dataList.get(i12)).getCategoryId().intValue() == i11) {
                notifyItemChanged(i12);
                break;
            }
            i12++;
        }
        for (int i13 = 0; i13 < this.dataList.size(); i13++) {
            if (((LiveCategoryEntity) this.dataList.get(i13)).getCategoryId().intValue() == i10) {
                notifyItemChanged(i13);
                return;
            }
        }
    }

    @Override // xyz.stream.view.SingleTypeAdapter
    public final void onBindData(v3.a aVar, Object obj, int i10) {
        u1 u1Var = (u1) aVar;
        LiveCategoryEntity liveCategoryEntity = (LiveCategoryEntity) obj;
        u1Var.f27524d.setText(liveCategoryEntity.getName());
        String strValueOf = liveCategoryEntity.getProgramTotal().intValue() >= 0 ? String.valueOf(liveCategoryEntity.getProgramTotal()) : "";
        TextView textView = u1Var.f27523c;
        textView.setText(strValueOf);
        int iIntValue = liveCategoryEntity.getCategoryId().intValue();
        int i11 = R.color.main_text;
        ImageView imageView = u1Var.f27522b;
        ConstraintLayout constraintLayout = u1Var.f27521a;
        if (iIntValue == -3) {
            imageView.setVisibility(0);
            UiUtils.setSvgPicture(imageView, R.drawable.live_search, Integer.valueOf(constraintLayout.isFocused() ? R.color.main_text : R.color.black_9));
        } else {
            imageView.setVisibility(8);
        }
        int iIntValue2 = liveCategoryEntity.getCategoryId().intValue();
        int i12 = this.f34282b;
        TextView textView2 = u1Var.f27524d;
        if (iIntValue2 == i12) {
            Activity activity = this.context;
            int i13 = constraintLayout.isFocused() ? R.color.main_text : R.color.white;
            Object obj2 = g0.d.f26125a;
            textView2.setTextColor(activity.getColor(i13));
            Activity activity2 = this.context;
            if (!constraintLayout.isFocused()) {
                i11 = R.color.white;
            }
            textView.setTextColor(activity2.getColor(i11));
            constraintLayout.setBackgroundResource(constraintLayout.isFocused() ? R.drawable.shape_radius_red_select_12 : R.drawable.shape_radius_black4_12);
            textView2.setTypeface(null, 1);
            textView.setTypeface(null, 1);
        } else {
            Activity activity3 = this.context;
            Object obj3 = g0.d.f26125a;
            textView2.setTextColor(activity3.getColor(R.color.black_9));
            textView.setTextColor(this.context.getColor(R.color.black_9));
            textView2.setTypeface(null, 0);
            textView.setTypeface(null, 0);
            constraintLayout.setBackgroundResource(R.color.transparent);
        }
        constraintLayout.setOnFocusChangeListener(new a(this, i10, liveCategoryEntity, u1Var, 0));
    }
}
