package X6FRs_4.IMuAHx_6.EuDEkJe_12;

import X6FRs_4.IMuAHx_6.EuDEkJe_12.NzhupJ_29.Mqv2r_3;
import android.os.Build;
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;
/* compiled from: AccessibilityDelegateCompat.java */
/* loaded from: classes.dex */
public class KQgRr5e_0 {
    public static final View.AccessibilityDelegate DEFAULT_DELEGATE = new View.AccessibilityDelegate();
    public final View.AccessibilityDelegate mBridge;
    public final View.AccessibilityDelegate mOriginalDelegate;

    /* compiled from: AccessibilityDelegateCompat.java */
    /* renamed from: X6FRs_4.IMuAHx_6.EuDEkJe_12.KQgRr5e_0$KQgRr5e_0  reason: collision with other inner class name */
    /* loaded from: classes.dex */
    public static final class C0035KQgRr5e_0 extends View.AccessibilityDelegate {
        public final KQgRr5e_0 KQgRr5e_0;

        public C0035KQgRr5e_0(KQgRr5e_0 kQgRr5e_0) {
            this.KQgRr5e_0 = kQgRr5e_0;
        }

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

        @Override // android.view.View.AccessibilityDelegate
        public AccessibilityNodeProvider getAccessibilityNodeProvider(View view) {
            X6FRs_4.IMuAHx_6.EuDEkJe_12.NzhupJ_29.X6FRs_4 accessibilityNodeProvider = this.KQgRr5e_0.getAccessibilityNodeProvider(view);
            if (accessibilityNodeProvider != null) {
                return (AccessibilityNodeProvider) accessibilityNodeProvider.KQgRr5e_0();
            }
            return null;
        }

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

        @Override // android.view.View.AccessibilityDelegate
        public void onInitializeAccessibilityNodeInfo(View view, AccessibilityNodeInfo accessibilityNodeInfo) {
            X6FRs_4.IMuAHx_6.EuDEkJe_12.NzhupJ_29.Mqv2r_3 KQgRr5e_0 = X6FRs_4.IMuAHx_6.EuDEkJe_12.NzhupJ_29.Mqv2r_3.KQgRr5e_0(accessibilityNodeInfo);
            KQgRr5e_0.EuDEkJe_12(ZzDuCHW_20.Nm6q_10(view));
            KQgRr5e_0.Nm6q_10(ZzDuCHW_20.m249IFxWkV_5(view));
            KQgRr5e_0.IFxWkV_5(ZzDuCHW_20.m260KQgRr5e_0(view));
            this.KQgRr5e_0.onInitializeAccessibilityNodeInfo(view, KQgRr5e_0);
            KQgRr5e_0.KQgRr5e_0(accessibilityNodeInfo.getText(), view);
            List<Mqv2r_3.KQgRr5e_0> actionList = KQgRr5e_0.getActionList(view);
            for (int i = 0; i < actionList.size(); i++) {
                KQgRr5e_0.KQgRr5e_0(actionList.get(i));
            }
        }

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

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

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

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

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

    public KQgRr5e_0() {
        this(DEFAULT_DELEGATE);
    }

    public static List<Mqv2r_3.KQgRr5e_0> getActionList(View view) {
        List<Mqv2r_3.KQgRr5e_0> list = (List) view.getTag(X6FRs_4.IMuAHx_6.QxJ9d_1.tag_accessibility_actions);
        return list == null ? Collections.emptyList() : list;
    }

    private boolean isSpanStillValid(ClickableSpan clickableSpan, View view) {
        if (clickableSpan != null) {
            ClickableSpan[] KQgRr5e_0 = X6FRs_4.IMuAHx_6.EuDEkJe_12.NzhupJ_29.Mqv2r_3.KQgRr5e_0(view.createAccessibilityNodeInfo().getText());
            for (int i = 0; KQgRr5e_0 != null && i < KQgRr5e_0.length; i++) {
                if (clickableSpan.equals(KQgRr5e_0[i])) {
                    return true;
                }
            }
        }
        return false;
    }

    private boolean performClickableSpanAction(int i, View view) {
        WeakReference weakReference;
        SparseArray sparseArray = (SparseArray) view.getTag(X6FRs_4.IMuAHx_6.QxJ9d_1.tag_accessibility_clickable_spans);
        if (sparseArray == null || (weakReference = (WeakReference) sparseArray.get(i)) == null) {
            return false;
        }
        ClickableSpan clickableSpan = (ClickableSpan) weakReference.get();
        if (isSpanStillValid(clickableSpan, view)) {
            clickableSpan.onClick(view);
            return true;
        }
        return false;
    }

    public boolean dispatchPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
        return this.mOriginalDelegate.dispatchPopulateAccessibilityEvent(view, accessibilityEvent);
    }

    public X6FRs_4.IMuAHx_6.EuDEkJe_12.NzhupJ_29.X6FRs_4 getAccessibilityNodeProvider(View view) {
        AccessibilityNodeProvider accessibilityNodeProvider;
        if (Build.VERSION.SDK_INT < 16 || (accessibilityNodeProvider = this.mOriginalDelegate.getAccessibilityNodeProvider(view)) == null) {
            return null;
        }
        return new X6FRs_4.IMuAHx_6.EuDEkJe_12.NzhupJ_29.X6FRs_4(accessibilityNodeProvider);
    }

    public View.AccessibilityDelegate getBridge() {
        return this.mBridge;
    }

    public void onInitializeAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
        this.mOriginalDelegate.onInitializeAccessibilityEvent(view, accessibilityEvent);
    }

    public void onInitializeAccessibilityNodeInfo(View view, X6FRs_4.IMuAHx_6.EuDEkJe_12.NzhupJ_29.Mqv2r_3 mqv2r_3) {
        this.mOriginalDelegate.onInitializeAccessibilityNodeInfo(view, mqv2r_3.m225KQgRr5e_0());
    }

    public void onPopulateAccessibilityEvent(View view, AccessibilityEvent accessibilityEvent) {
        this.mOriginalDelegate.onPopulateAccessibilityEvent(view, accessibilityEvent);
    }

    public boolean onRequestSendAccessibilityEvent(ViewGroup viewGroup, View view, AccessibilityEvent accessibilityEvent) {
        return this.mOriginalDelegate.onRequestSendAccessibilityEvent(viewGroup, view, accessibilityEvent);
    }

    public boolean performAccessibilityAction(View view, int i, Bundle bundle) {
        List<Mqv2r_3.KQgRr5e_0> actionList = getActionList(view);
        boolean z = false;
        int i2 = 0;
        while (true) {
            if (i2 >= actionList.size()) {
                break;
            }
            Mqv2r_3.KQgRr5e_0 kQgRr5e_0 = actionList.get(i2);
            if (kQgRr5e_0.KQgRr5e_0() == i) {
                z = kQgRr5e_0.KQgRr5e_0(view, bundle);
                break;
            }
            i2++;
        }
        if (!z && Build.VERSION.SDK_INT >= 16) {
            z = this.mOriginalDelegate.performAccessibilityAction(view, i, bundle);
        }
        return (z || i != X6FRs_4.IMuAHx_6.QxJ9d_1.accessibility_action_clickable_span) ? z : performClickableSpanAction(bundle.getInt("ACCESSIBILITY_CLICKABLE_SPAN_ID", -1), view);
    }

    public void sendAccessibilityEvent(View view, int i) {
        this.mOriginalDelegate.sendAccessibilityEvent(view, i);
    }

    public void sendAccessibilityEventUnchecked(View view, AccessibilityEvent accessibilityEvent) {
        this.mOriginalDelegate.sendAccessibilityEventUnchecked(view, accessibilityEvent);
    }

    public KQgRr5e_0(View.AccessibilityDelegate accessibilityDelegate) {
        this.mOriginalDelegate = accessibilityDelegate;
        this.mBridge = new C0035KQgRr5e_0(this);
    }
}
