package p023h0;

import android.os.Bundle;
import android.text.style.ClickableSpan;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeProvider;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.List;
import p026i0.C1022c0;
import p026i0.C1025d0;
import p064v.C1751b;

/* renamed from: h0.a */
/* loaded from: classes.dex */
public class C0764a {

    /* renamed from: c */
    public static final View.AccessibilityDelegate f2402c = new View.AccessibilityDelegate();

    /* renamed from: a */
    public final View.AccessibilityDelegate f2403a;

    /* renamed from: b */
    public final View.AccessibilityDelegate f2404b;

    /* renamed from: h0.a$a */
    /* loaded from: classes.dex */
    public static final class C0765a extends View.AccessibilityDelegate {

        /* renamed from: a */
        public final C0764a f2405a;

        public C0765a(C0764a c0764a) {
            this.f2405a = c0764a;
        }

        @Override // android.view.View.AccessibilityDelegate
        public boolean dispatchPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
            return this.f2405a.m2957a(view, accessibilityEvent);
        }

        @Override // android.view.View.AccessibilityDelegate
        public AccessibilityNodeProvider getAccessibilityNodeProvider(View view) {
            C1025d0 m2956b = this.f2405a.m2956b(view);
            if (m2956b != null) {
                return (AccessibilityNodeProvider) m2956b.m2330a();
            }
            return null;
        }

        @Override // android.view.View.AccessibilityDelegate
        public void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
            this.f2405a.mo2952f(view, accessibilityEvent);
        }

        @Override // android.view.View.AccessibilityDelegate
        public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfo accessibilityNodeInfo) {
            C1022c0 m2361Q = C1022c0.m2361Q(accessibilityNodeInfo);
            m2361Q.m2365M(C0829h1.m2860C(view));
            m2361Q.m2367K(C0829h1.m2808z(view));
            m2361Q.m2366L(C0829h1.m2821m(view));
            m2361Q.m2363O(C0829h1.m2812v(view));
            this.f2405a.mo2951g(view, m2361Q);
            m2361Q.m2358c(accessibilityNodeInfo.getText(), view);
            List<C1022c0.C1023a> m2955c = C0764a.m2955c(view);
            for (int i = 0; i < m2955c.size(); i++) {
                m2361Q.m2360a(m2955c.get(i));
            }
        }

        @Override // android.view.View.AccessibilityDelegate
        public void onPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
            this.f2405a.m2950h(view, accessibilityEvent);
        }

        @Override // android.view.View.AccessibilityDelegate
        public boolean onRequestSendAccessibilityEvent(ViewGroup viewGroup, View view, AccessibilityEvent accessibilityEvent) {
            return this.f2405a.m2949i(viewGroup, view, accessibilityEvent);
        }

        @Override // android.view.View.AccessibilityDelegate
        public boolean performAccessibilityAction(View view, int i, Bundle bundle) {
            return this.f2405a.mo2948j(view, i, bundle);
        }

        @Override // android.view.View.AccessibilityDelegate
        public void sendAccessibilityEvent(View view, int i) {
            this.f2405a.m2946l(view, i);
        }

        @Override // android.view.View.AccessibilityDelegate
        public void sendAccessibilityEventUnchecked(View view, AccessibilityEvent accessibilityEvent) {
            this.f2405a.m2945m(view, accessibilityEvent);
        }
    }

    /* renamed from: h0.a$b */
    /* loaded from: classes.dex */
    public static class C0766b {
        /* renamed from: a */
        public static AccessibilityNodeProvider m2944a(View.AccessibilityDelegate accessibilityDelegate, View view) {
            return accessibilityDelegate.getAccessibilityNodeProvider(view);
        }

        /* renamed from: b */
        public static boolean m2943b(View.AccessibilityDelegate accessibilityDelegate, View view, int i, Bundle bundle) {
            return accessibilityDelegate.performAccessibilityAction(view, i, bundle);
        }
    }

    public C0764a() {
        this(f2402c);
    }

    public C0764a(View.AccessibilityDelegate accessibilityDelegate) {
        this.f2403a = accessibilityDelegate;
        this.f2404b = new C0765a(this);
    }

    /* renamed from: c */
    public static List<C1022c0.C1023a> m2955c(View view) {
        List<C1022c0.C1023a> list = (List) view.getTag(C1751b.tag_accessibility_actions);
        return list == null ? Collections.emptyList() : list;
    }

    /* renamed from: a */
    public boolean m2957a(View view, AccessibilityEvent accessibilityEvent) {
        return this.f2403a.dispatchPopulateAccessibilityEvent(view, accessibilityEvent);
    }

    /* renamed from: b */
    public C1025d0 m2956b(View view) {
        AccessibilityNodeProvider m2944a = C0766b.m2944a(this.f2403a, view);
        if (m2944a != null) {
            return new C1025d0(m2944a);
        }
        return null;
    }

    /* renamed from: d */
    public View.AccessibilityDelegate m2954d() {
        return this.f2404b;
    }

    /* renamed from: e */
    public final boolean m2953e(ClickableSpan clickableSpan, View view) {
        if (clickableSpan != null) {
            ClickableSpan[] m2349l = C1022c0.m2349l(view.createAccessibilityNodeInfo().getText());
            for (int i = 0; m2349l != null && i < m2349l.length; i++) {
                if (clickableSpan.equals(m2349l[i])) {
                    return true;
                }
            }
        }
        return false;
    }

    /* renamed from: f */
    public void mo2952f(View view, AccessibilityEvent accessibilityEvent) {
        this.f2403a.onInitializeAccessibilityEvent(view, accessibilityEvent);
    }

    /* renamed from: g */
    public void mo2951g(View view, C1022c0 c1022c0) {
        this.f2403a.onInitializeAccessibilityNodeInfo(view, c1022c0.m2362P());
    }

    /* renamed from: h */
    public void m2950h(View view, AccessibilityEvent accessibilityEvent) {
        this.f2403a.onPopulateAccessibilityEvent(view, accessibilityEvent);
    }

    /* renamed from: i */
    public boolean m2949i(ViewGroup viewGroup, View view, AccessibilityEvent accessibilityEvent) {
        return this.f2403a.onRequestSendAccessibilityEvent(viewGroup, view, accessibilityEvent);
    }

    /* renamed from: j */
    public boolean mo2948j(View view, int i, Bundle bundle) {
        List<C1022c0.C1023a> m2955c = m2955c(view);
        boolean z = false;
        int i2 = 0;
        while (true) {
            if (i2 >= m2955c.size()) {
                break;
            }
            C1022c0.C1023a c1023a = m2955c.get(i2);
            if (c1023a.m2334a() == i) {
                z = c1023a.m2332c(view, bundle);
                break;
            }
            i2++;
        }
        if (!z) {
            z = C0766b.m2943b(this.f2403a, view, i, bundle);
        }
        return (z || i != C1751b.accessibility_action_clickable_span || bundle == null) ? z : m2947k(bundle.getInt("ACCESSIBILITY_CLICKABLE_SPAN_ID", -1), view);
    }

    /* renamed from: k */
    public final boolean m2947k(int i, View view) {
        WeakReference weakReference;
        SparseArray sparseArray = (SparseArray) view.getTag(C1751b.tag_accessibility_clickable_spans);
        if (sparseArray == null || (weakReference = (WeakReference) sparseArray.get(i)) == null) {
            return false;
        }
        ClickableSpan clickableSpan = (ClickableSpan) weakReference.get();
        if (m2953e(clickableSpan, view)) {
            clickableSpan.onClick(view);
            return true;
        }
        return false;
    }

    /* renamed from: l */
    public void m2946l(View view, int i) {
        this.f2403a.sendAccessibilityEvent(view, i);
    }

    /* renamed from: m */
    public void m2945m(View view, AccessibilityEvent accessibilityEvent) {
        this.f2403a.sendAccessibilityEventUnchecked(view, accessibilityEvent);
    }
}