package com.google.android.material.appbar;

import android.os.Bundle;
import android.view.View;
import android.widget.ScrollView;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.appbar.AppBarLayout;

/* JADX INFO: loaded from: classes2.dex */
public final class d extends androidx.core.view.b {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final /* synthetic */ AppBarLayout f22191d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final /* synthetic */ CoordinatorLayout f22192e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ AppBarLayout.BaseBehavior f22193f;

    public d(CoordinatorLayout coordinatorLayout, AppBarLayout.BaseBehavior baseBehavior, AppBarLayout appBarLayout) {
        this.f22193f = baseBehavior;
        this.f22191d = appBarLayout;
        this.f22192e = coordinatorLayout;
    }

    @Override // androidx.core.view.b
    public final void c(View view, q0.f fVar) {
        this.f1715a.onInitializeAccessibilityNodeInfo(view, fVar.f32077a);
        fVar.j(ScrollView.class.getName());
        AppBarLayout appBarLayout = this.f22191d;
        if (appBarLayout.getTotalScrollRange() == 0) {
            return;
        }
        AppBarLayout.BaseBehavior baseBehavior = this.f22193f;
        View childWithScrollingBehavior = baseBehavior.getChildWithScrollingBehavior(this.f22192e);
        if (childWithScrollingBehavior == null) {
            return;
        }
        int childCount = appBarLayout.getChildCount();
        for (int i10 = 0; i10 < childCount; i10++) {
            if (((k) appBarLayout.getChildAt(i10).getLayoutParams()).f22201a != 0) {
                if (baseBehavior.z() != (-appBarLayout.getTotalScrollRange())) {
                    fVar.b(q0.c.f32062h);
                    fVar.n(true);
                }
                if (baseBehavior.z() != 0) {
                    if (!childWithScrollingBehavior.canScrollVertically(-1)) {
                        fVar.b(q0.c.f32063i);
                        fVar.n(true);
                        return;
                    } else {
                        if ((-appBarLayout.getDownNestedPreScrollRange()) != 0) {
                            fVar.b(q0.c.f32063i);
                            fVar.n(true);
                            return;
                        }
                        return;
                    }
                }
                return;
            }
        }
    }

    @Override // androidx.core.view.b
    public final boolean performAccessibilityAction(View view, int i10, Bundle bundle) {
        AppBarLayout appBarLayout = this.f22191d;
        if (i10 == 4096) {
            appBarLayout.setExpanded(false);
            return true;
        }
        if (i10 != 8192) {
            return super.performAccessibilityAction(view, i10, bundle);
        }
        AppBarLayout.BaseBehavior baseBehavior = this.f22193f;
        if (baseBehavior.z() != 0) {
            View childWithScrollingBehavior = baseBehavior.getChildWithScrollingBehavior(this.f22192e);
            if (!childWithScrollingBehavior.canScrollVertically(-1)) {
                appBarLayout.setExpanded(true);
                return true;
            }
            int i11 = -appBarLayout.getDownNestedPreScrollRange();
            if (i11 != 0) {
                this.f22193f.F(this.f22192e, this.f22191d, childWithScrollingBehavior, i11, new int[]{0, 0});
                return true;
            }
        }
        return false;
    }
}
