package defpackage;

import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.media3.container.NalUnitUtil;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.card.MaterialCardView;
import com.strmr.ps.R;
import com.strmr.ps.ui.mobile.settings.MobileAccountsFragment;
import java.util.ArrayList;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\u000e\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b\n\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001¨\u0006\u0003"}, d2 = {"Liy5;", "Landroidx/recyclerview/widget/RecyclerView$g;", "Landroidx/recyclerview/widget/RecyclerView$ag;", "app_sideloadRelease"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class iy5 extends RecyclerView.g<RecyclerView.ag> {
    public co a;
    public final /* synthetic */ ArrayList b;
    public final /* synthetic */ MobileAccountsFragment c;

    public iy5(ArrayList arrayList, MobileAccountsFragment mobileAccountsFragment) {
        this.b = arrayList;
        this.c = mobileAccountsFragment;
    }

    @Override // androidx.recyclerview.widget.RecyclerView.g
    public final int getItemCount() {
        return this.b.size();
    }

    @Override // androidx.recyclerview.widget.RecyclerView.g
    public final void onBindViewHolder(RecyclerView.ag agVar, int i) {
        String str;
        cr4.g(agVar, "holder");
        fy5 fy5Var = (fy5) this.b.get(i);
        View view = agVar.itemView;
        cr4.f(view, "itemView");
        MaterialCardView materialCardView = (MaterialCardView) view;
        TextView textView = (TextView) view.findViewById(R.id.account_icon);
        String str2 = fy5Var.c;
        boolean z = fy5Var.e;
        textView.setText(str2);
        int color = sf1.getColor(materialCardView.getContext(), fy5Var.d);
        Drawable background = textView.getBackground();
        String quantityString = null;
        GradientDrawable gradientDrawable = background instanceof GradientDrawable ? (GradientDrawable) background : null;
        if (gradientDrawable != null) {
            gradientDrawable.setColor(color);
        } else {
            GradientDrawable gradientDrawable2 = new GradientDrawable();
            gradientDrawable2.setShape(1);
            gradientDrawable2.setColor(color);
            textView.setBackground(gradientDrawable2);
        }
        ((TextView) view.findViewById(R.id.account_name)).setText(fy5Var.b);
        TextView textView2 = (TextView) view.findViewById(R.id.account_status);
        if (z) {
            str = fy5Var.f;
            if (str == null) {
                str = "Connected";
            }
        } else {
            str = "Premium link generator";
        }
        textView2.setText(str);
        TextView textView3 = (TextView) view.findViewById(R.id.connect_text);
        LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.connected_indicator);
        MobileAccountsFragment mobileAccountsFragment = this.c;
        if (z) {
            textView3.setVisibility(8);
            linearLayout.setVisibility(0);
            Drawable background2 = view.findViewById(R.id.status_dot).getBackground();
            GradientDrawable gradientDrawable3 = background2 instanceof GradientDrawable ? (GradientDrawable) background2 : null;
            if (gradientDrawable3 != null) {
                gradientDrawable3.setColor(sf1.getColor(materialCardView.getContext(), R.color.success_color));
            }
            materialCardView.setStrokeWidth(mobileAccountsFragment.getResources().getDimensionPixelSize(R.dimen.stroke_width_thin));
            TypedValue typedValue = new TypedValue();
            materialCardView.getContext().getTheme().resolveAttribute(R.attr.colorAccentBorder, typedValue, true);
            materialCardView.setStrokeColor(typedValue.data);
        } else {
            textView3.setVisibility(0);
            linearLayout.setVisibility(8);
            materialCardView.setStrokeWidth(mobileAccountsFragment.getResources().getDimensionPixelSize(R.dimen.stroke_width_thin));
            materialCardView.setStrokeColor(sf1.getColor(materialCardView.getContext(), R.color.mobile_card_stroke));
        }
        TextView textView4 = (TextView) view.findViewById(R.id.account_info);
        Integer num = fy5Var.g;
        if (num != null) {
            int iIntValue = num.intValue();
            quantityString = mobileAccountsFragment.getResources().getQuantityString(R.plurals.plural_days_remaining, iIntValue, Integer.valueOf(iIntValue));
        }
        if (quantityString == null || !z) {
            textView4.setVisibility(8);
        } else {
            textView4.setText(quantityString);
            textView4.setVisibility(0);
        }
        materialCardView.setOnClickListener(new ua(fy5Var, 9));
        ((ImageView) view.findViewById(R.id.drag_handle)).setOnTouchListener(new gy5(this, agVar, 0));
    }

    @Override // androidx.recyclerview.widget.RecyclerView.g
    public final RecyclerView.ag onCreateViewHolder(ViewGroup viewGroup, int i) {
        return new hy5(n41.d(viewGroup, "parent", R.layout.item_mobile_debrid_card, viewGroup, false));
    }
}
