package com.google.android.material.transformation;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewTreeObserver;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.view.s0;
import java.util.List;

@Deprecated
/* loaded from: classes3.dex */
public abstract class ExpandableBehavior extends CoordinatorLayout.c {

    /* renamed from: a, reason: collision with root package name */
    private int f13784a;

    /* loaded from: classes3.dex */
    class a implements ViewTreeObserver.OnPreDrawListener {

        /* renamed from: p, reason: collision with root package name */
        final /* synthetic */ View f13785p;

        /* renamed from: q, reason: collision with root package name */
        final /* synthetic */ int f13786q;

        /* renamed from: r, reason: collision with root package name */
        final /* synthetic */ fj.a f13787r;

        a(View view, int i10, fj.a aVar) {
            this.f13785p = view;
            this.f13786q = i10;
            this.f13787r = aVar;
        }

        /* JADX WARN: Multi-variable type inference failed */
        @Override // android.view.ViewTreeObserver.OnPreDrawListener
        public boolean onPreDraw() {
            this.f13785p.getViewTreeObserver().removeOnPreDrawListener(this);
            if (ExpandableBehavior.this.f13784a == this.f13786q) {
                ExpandableBehavior expandableBehavior = ExpandableBehavior.this;
                fj.a aVar = this.f13787r;
                expandableBehavior.H((View) aVar, this.f13785p, aVar.a(), false);
            }
            return false;
        }
    }

    public ExpandableBehavior() {
        this.f13784a = 0;
    }

    private boolean F(boolean z10) {
        if (!z10) {
            return this.f13784a == 1;
        }
        int i10 = this.f13784a;
        return i10 == 0 || i10 == 2;
    }

    /* JADX WARN: Multi-variable type inference failed */
    protected fj.a G(CoordinatorLayout coordinatorLayout, View view) {
        List r10 = coordinatorLayout.r(view);
        int size = r10.size();
        for (int i10 = 0; i10 < size; i10++) {
            View view2 = (View) r10.get(i10);
            if (e(coordinatorLayout, view, view2)) {
                return (fj.a) view2;
            }
        }
        return null;
    }

    protected abstract boolean H(View view, View view2, boolean z10, boolean z11);

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public abstract boolean e(CoordinatorLayout coordinatorLayout, View view, View view2);

    /* JADX WARN: Multi-variable type inference failed */
    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean h(CoordinatorLayout coordinatorLayout, View view, View view2) {
        fj.a aVar = (fj.a) view2;
        if (!F(aVar.a())) {
            return false;
        }
        this.f13784a = aVar.a() ? 1 : 2;
        return H((View) aVar, view, aVar.a(), true);
    }

    @Override // androidx.coordinatorlayout.widget.CoordinatorLayout.c
    public boolean l(CoordinatorLayout coordinatorLayout, View view, int i10) {
        fj.a G;
        if (s0.Q(view) || (G = G(coordinatorLayout, view)) == null || !F(G.a())) {
            return false;
        }
        int i11 = G.a() ? 1 : 2;
        this.f13784a = i11;
        view.getViewTreeObserver().addOnPreDrawListener(new a(view, i11, G));
        return false;
    }

    public ExpandableBehavior(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.f13784a = 0;
    }
}
