package androidx.recyclerview.widget;

import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import androidx.core.view.s0;
import java.util.Map;
import java.util.WeakHashMap;

/* loaded from: classes.dex */
public class p extends androidx.core.view.a {

    /* renamed from: d, reason: collision with root package name */
    final RecyclerView f5466d;

    /* renamed from: e, reason: collision with root package name */
    private final a f5467e;

    /* loaded from: classes.dex */
    public static class a extends androidx.core.view.a {

        /* renamed from: d, reason: collision with root package name */
        final p f5468d;

        /* renamed from: e, reason: collision with root package name */
        private Map f5469e = new WeakHashMap();

        public a(p pVar) {
            this.f5468d = pVar;
        }

        @Override // androidx.core.view.a
        public boolean a(View view, AccessibilityEvent accessibilityEvent) {
            androidx.core.view.a aVar = (androidx.core.view.a) this.f5469e.get(view);
            return aVar != null ? aVar.a(view, accessibilityEvent) : super.a(view, accessibilityEvent);
        }

        @Override // androidx.core.view.a
        public t3.i b(View view) {
            androidx.core.view.a aVar = (androidx.core.view.a) this.f5469e.get(view);
            return aVar != null ? aVar.b(view) : super.b(view);
        }

        @Override // androidx.core.view.a
        public void f(View view, AccessibilityEvent accessibilityEvent) {
            androidx.core.view.a aVar = (androidx.core.view.a) this.f5469e.get(view);
            if (aVar != null) {
                aVar.f(view, accessibilityEvent);
            } else {
                super.f(view, accessibilityEvent);
            }
        }

        @Override // androidx.core.view.a
        public void g(View view, t3.h hVar) {
            if (this.f5468d.o() || this.f5468d.f5466d.getLayoutManager() == null) {
                super.g(view, hVar);
                return;
            }
            this.f5468d.f5466d.getLayoutManager().V0(view, hVar);
            androidx.core.view.a aVar = (androidx.core.view.a) this.f5469e.get(view);
            if (aVar != null) {
                aVar.g(view, hVar);
            } else {
                super.g(view, hVar);
            }
        }

        @Override // androidx.core.view.a
        public void h(View view, AccessibilityEvent accessibilityEvent) {
            androidx.core.view.a aVar = (androidx.core.view.a) this.f5469e.get(view);
            if (aVar != null) {
                aVar.h(view, accessibilityEvent);
            } else {
                super.h(view, accessibilityEvent);
            }
        }

        @Override // androidx.core.view.a
        public boolean i(ViewGroup viewGroup, View view, AccessibilityEvent accessibilityEvent) {
            androidx.core.view.a aVar = (androidx.core.view.a) this.f5469e.get(viewGroup);
            return aVar != null ? aVar.i(viewGroup, view, accessibilityEvent) : super.i(viewGroup, view, accessibilityEvent);
        }

        @Override // androidx.core.view.a
        public boolean j(View view, int i10, Bundle bundle) {
            if (this.f5468d.o() || this.f5468d.f5466d.getLayoutManager() == null) {
                return super.j(view, i10, bundle);
            }
            androidx.core.view.a aVar = (androidx.core.view.a) this.f5469e.get(view);
            if (aVar != null) {
                if (aVar.j(view, i10, bundle)) {
                    return true;
                }
            } else if (super.j(view, i10, bundle)) {
                return true;
            }
            return this.f5468d.f5466d.getLayoutManager().p1(view, i10, bundle);
        }

        @Override // androidx.core.view.a
        public void l(View view, int i10) {
            androidx.core.view.a aVar = (androidx.core.view.a) this.f5469e.get(view);
            if (aVar != null) {
                aVar.l(view, i10);
            } else {
                super.l(view, i10);
            }
        }

        @Override // androidx.core.view.a
        public void m(View view, AccessibilityEvent accessibilityEvent) {
            androidx.core.view.a aVar = (androidx.core.view.a) this.f5469e.get(view);
            if (aVar != null) {
                aVar.m(view, accessibilityEvent);
            } else {
                super.m(view, accessibilityEvent);
            }
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        public androidx.core.view.a n(View view) {
            return (androidx.core.view.a) this.f5469e.remove(view);
        }

        /* JADX INFO: Access modifiers changed from: package-private */
        public void o(View view) {
            androidx.core.view.a l10 = s0.l(view);
            if (l10 == null || l10 == this) {
                return;
            }
            this.f5469e.put(view, l10);
        }
    }

    public p(RecyclerView recyclerView) {
        this.f5466d = recyclerView;
        androidx.core.view.a n10 = n();
        if (n10 == null || !(n10 instanceof a)) {
            this.f5467e = new a(this);
        } else {
            this.f5467e = (a) n10;
        }
    }

    @Override // androidx.core.view.a
    public void f(View view, AccessibilityEvent accessibilityEvent) {
        super.f(view, accessibilityEvent);
        if (!(view instanceof RecyclerView) || o()) {
            return;
        }
        RecyclerView recyclerView = (RecyclerView) view;
        if (recyclerView.getLayoutManager() != null) {
            recyclerView.getLayoutManager().R0(accessibilityEvent);
        }
    }

    @Override // androidx.core.view.a
    public void g(View view, t3.h hVar) {
        super.g(view, hVar);
        if (o() || this.f5466d.getLayoutManager() == null) {
            return;
        }
        this.f5466d.getLayoutManager().U0(hVar);
    }

    @Override // androidx.core.view.a
    public boolean j(View view, int i10, Bundle bundle) {
        if (super.j(view, i10, bundle)) {
            return true;
        }
        if (o() || this.f5466d.getLayoutManager() == null) {
            return false;
        }
        return this.f5466d.getLayoutManager().n1(i10, bundle);
    }

    public androidx.core.view.a n() {
        return this.f5467e;
    }

    boolean o() {
        return this.f5466d.o0();
    }
}
