package androidx.recyclerview.widget;

import android.view.View;
import androidx.recyclerview.widget.RecyclerView;

/* JADX INFO: loaded from: classes.dex */
class ap {
    public static int a(RecyclerView.ac acVar, ak akVar, View view, View view2, RecyclerView.o oVar, boolean z) {
        if (oVar.getChildCount() == 0 || acVar.b() == 0 || view == null || view2 == null) {
            return 0;
        }
        if (!z) {
            return Math.abs(oVar.getPosition(view) - oVar.getPosition(view2)) + 1;
        }
        return Math.min(akVar.n(), akVar.d(view2) - akVar.g(view));
    }

    public static int b(RecyclerView.ac acVar, ak akVar, View view, View view2, RecyclerView.o oVar, boolean z, boolean z2) {
        if (oVar.getChildCount() == 0 || acVar.b() == 0 || view == null || view2 == null) {
            return 0;
        }
        int iMax = z2 ? Math.max(0, (acVar.b() - Math.max(oVar.getPosition(view), oVar.getPosition(view2))) - 1) : Math.max(0, Math.min(oVar.getPosition(view), oVar.getPosition(view2)));
        if (z) {
            return Math.round((iMax * (Math.abs(akVar.d(view2) - akVar.g(view)) / (Math.abs(oVar.getPosition(view) - oVar.getPosition(view2)) + 1))) + (akVar.m() - akVar.g(view)));
        }
        return iMax;
    }

    public static int c(RecyclerView.ac acVar, ak akVar, View view, View view2, RecyclerView.o oVar, boolean z) {
        if (oVar.getChildCount() == 0 || acVar.b() == 0 || view == null || view2 == null) {
            return 0;
        }
        if (!z) {
            return acVar.b();
        }
        return (int) (((akVar.d(view2) - akVar.g(view)) / (Math.abs(oVar.getPosition(view) - oVar.getPosition(view2)) + 1)) * acVar.b());
    }
}
