package defpackage;

import android.content.Context;
import android.content.ContextWrapper;
import android.view.View;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/* renamed from: ᵧʿᵮ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class ViewOnClickListenerC3628 implements View.OnClickListener {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final String f13518;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final View f13519;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public Context f13520;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public Method f13521;

    public ViewOnClickListenerC3628(View view, String str) {
        this.f13519 = view;
        this.f13518 = str;
    }

    @Override // android.view.View.OnClickListener
    public final void onClick(View view) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
        String str;
        Method method;
        if (this.f13521 == null) {
            View view2 = this.f13519;
            Context context = view2.getContext();
            while (true) {
                String str2 = this.f13518;
                if (context == null) {
                    int id = view2.getId();
                    if (id == -1) {
                        str = "";
                    } else {
                        str = " with id '" + view2.getContext().getResources().getResourceEntryName(id) + "'";
                    }
                    throw new IllegalStateException("Could not find method " + str2 + "(View) in a parent or ancestor Context for android:onClick attribute defined on view " + view2.getClass() + str);
                }
                try {
                    if (!context.isRestricted() && (method = context.getClass().getMethod(str2, View.class)) != null) {
                        this.f13521 = method;
                        this.f13520 = context;
                    }
                } catch (NoSuchMethodException unused) {
                }
                context = context instanceof ContextWrapper ? ((ContextWrapper) context).getBaseContext() : null;
            }
        }
        try {
            this.f13521.invoke(this.f13520, view);
        } catch (IllegalAccessException e) {
            C1260.m3810("Could not execute non-public method for android:onClick", e);
        } catch (InvocationTargetException e2) {
            C1260.m3810("Could not execute method for android:onClick", e2);
        }
    }
}
