package mf;

import android.app.Activity;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.d1;
import androidx.recyclerview.widget.j2;
import com.bumptech.glide.u;
import ie.b2;
import ie.s4;
import java.util.ArrayList;
import java.util.List;
import org.drive_hunter.R;
import xyz.stream.api.entity.MatchEntity;
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 i extends d1 {

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

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final Activity f30687b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public OnItemListener f30688c;

    public i(ArrayList arrayList, Activity activity) {
        this.f30686a = arrayList;
        this.f30687b = activity;
    }

    @Override // androidx.recyclerview.widget.d1
    public final int getItemCount() {
        return this.f30686a.size();
    }

    @Override // androidx.recyclerview.widget.d1
    public final int getItemViewType(int i10) {
        return ((MatchEntity) this.f30686a.get(i10)).getLeagueId().intValue() < 0 ? 0 : 1;
    }

    @Override // androidx.recyclerview.widget.d1
    public final void onBindViewHolder(j2 j2Var, int i10) {
        Typeface typeface;
        int i11;
        int itemViewType = j2Var.getItemViewType();
        List list = this.f30686a;
        if (itemViewType == 0) {
            s4.a(((SingleTypeAdapter.HeaderViewHolder) j2Var).itemView).f27485b.setText(kotlinx.coroutines.flow.h.k(((MatchEntity) list.get(i10)).getTime(), "yyyy-MM-dd", "MMM dd, EEE"));
            return;
        }
        boolean z10 = xyz.stream.utils.e.d().f36119h;
        b2 b2Var = ((h) j2Var).f30685b;
        if (z10 || xyz.stream.utils.e.d().f36121j) {
            UiUtils.setUnFocusable(b2Var.f26671a);
        }
        MatchEntity matchEntity = (MatchEntity) list.get(i10);
        u uVarE = com.bumptech.glide.c.e(b2Var.f26671a);
        ImageView imageView = b2Var.f26672b;
        uVarE.f(imageView);
        ConstraintLayout constraintLayout = b2Var.f26671a;
        u uVarE2 = com.bumptech.glide.c.e(constraintLayout);
        ImageView imageView2 = b2Var.f26673c;
        uVarE2.f(imageView2);
        com.bumptech.glide.c.e(constraintLayout).load(matchEntity.getTeam1Logo()).y(imageView);
        com.bumptech.glide.c.e(constraintLayout).load(matchEntity.getTeam2Logo()).y(imageView2);
        b2Var.f26680j.setText(matchEntity.getTeam1Name());
        b2Var.f26681k.setText(matchEntity.getTeam2Name());
        b2Var.f26682l.setText(matchEntity.getTime());
        b2Var.f26678h.setText(matchEntity.getLeagueName());
        int iIntValue = matchEntity.getState().intValue();
        Activity activity = this.f30687b;
        PlayingView playingView = b2Var.f26674d;
        ImageView imageView3 = b2Var.f26675e;
        TextView textView = b2Var.f26679i;
        if ((iIntValue == 1 || matchEntity.getState().intValue() == 4) && matchEntity.getChannelList() != null && !matchEntity.getChannelList().isEmpty()) {
            imageView3.setImageResource(R.drawable.icon_alarms);
            imageView3.setVisibility(0);
            playingView.setVisibility(8);
            textView.setText(activity.getString(R.string.pending));
            textView.setTextColor(activity.getResources().getColor(R.color.black_9));
            textView.setTypeface(null, 0);
        } else if (matchEntity.getState().intValue() == 2 && matchEntity.getChannelList() != null && !matchEntity.getChannelList().isEmpty()) {
            imageView3.setVisibility(8);
            playingView.setVisibility(0);
            textView.setText(matchEntity.getTeam1Score() + " : " + matchEntity.getTeam2Score());
            textView.setTextColor(activity.getResources().getColor(R.color.white));
            textView.setTypeface(null, 1);
        } else if (matchEntity.getState().intValue() != 3 || matchEntity.getPlaybackList() == null || matchEntity.getPlaybackList().isEmpty()) {
            imageView3.setVisibility(8);
            playingView.setVisibility(8);
            if (matchEntity.getState().intValue() == 1) {
                typeface = null;
                i11 = R.string.pending;
            } else if (matchEntity.getState().intValue() == 4) {
                i11 = R.string.pending;
                typeface = null;
            } else {
                textView.setText(matchEntity.getTeam1Score() + " : " + matchEntity.getTeam2Score());
                textView.setTextColor(activity.getResources().getColor(R.color.white));
                textView.setTypeface(null, 1);
            }
            textView.setText(activity.getString(i11));
            textView.setTextColor(activity.getResources().getColor(R.color.black_9));
            textView.setTypeface(typeface, 0);
        } else {
            imageView3.setImageResource(R.drawable.icon_replay);
            imageView3.setVisibility(0);
            playingView.setVisibility(8);
            textView.setText(matchEntity.getTeam1Score() + " : " + matchEntity.getTeam2Score());
            textView.setTextColor(activity.getResources().getColor(R.color.white));
            textView.setTypeface(null, 1);
        }
        b2Var.f26677g.setVisibility(i10 == list.size() - 1 ? 8 : 0);
        constraintLayout.setOnClickListener(new ke.a(this, i10, 8));
        constraintLayout.setOnKeyListener(new g(this, i10, 0));
        b2Var.f26676f.setBackgroundResource(R.drawable.selector_transparent_button);
        constraintLayout.setOnFocusChangeListener(new oe.h(this, b2Var, i10, 18));
    }

    @Override // androidx.recyclerview.widget.d1
    public final j2 onCreateViewHolder(ViewGroup viewGroup, int i10) {
        Activity activity = this.f30687b;
        UiUtils.adaptActivityDensity(activity);
        if (i10 == 0) {
            return new SingleTypeAdapter.HeaderViewHolder(s4.inflate(activity.getLayoutInflater(), viewGroup, false).f27484a);
        }
        b2 b2VarInflate = b2.inflate(LayoutInflater.from(activity), viewGroup, false);
        h hVar = new h(b2VarInflate.f26671a);
        hVar.f30685b = b2VarInflate;
        return hVar;
    }
}
