package u8;

import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.TextView;
import androidx.core.view.s0;
import kotlin.text.z;

/* loaded from: classes.dex */
public abstract class p {

    /* loaded from: classes.dex */
    public static final class a extends ClickableSpan {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ int f37013p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ dn.a f37014q;

        a(int i10, dn.a aVar) {
            this.f37013p = i10;
            this.f37014q = aVar;
        }

        @Override // android.text.style.ClickableSpan
        public void onClick(View widget) {
            kotlin.jvm.internal.t.g(widget, "widget");
            this.f37014q.invoke();
        }

        @Override // android.text.style.ClickableSpan, android.text.style.CharacterStyle
        public void updateDrawState(TextPaint textPaint) {
            kotlin.jvm.internal.t.g(textPaint, "textPaint");
            super.updateDrawState(textPaint);
            textPaint.setColor(this.f37013p);
            textPaint.setUnderlineText(true);
        }
    }

    public static final void a(TextView textView, int i10, int i11, dn.a onClick) {
        int h02;
        kotlin.jvm.internal.t.g(textView, "<this>");
        kotlin.jvm.internal.t.g(onClick, "onClick");
        String string = textView.getContext().getApplicationContext().getString(i11);
        kotlin.jvm.internal.t.f(string, "getString(...)");
        String string2 = textView.getContext().getApplicationContext().getString(i10, string);
        kotlin.jvm.internal.t.f(string2, "getString(...)");
        o oVar = new o(string2);
        a aVar = new a(textView.getContext().getApplicationContext().getColor(h7.f.f20965f), onClick);
        String obj = oVar.toString();
        kotlin.jvm.internal.t.f(obj, "toString(...)");
        h02 = z.h0(obj, string, 0, false, 6, null);
        oVar.setSpan(aVar, h02, string.length() + h02, 33);
        textView.setMovementMethod(LinkMovementMethod.getInstance());
        textView.setText(oVar);
        s0.i(textView);
    }
}
