package defpackage;

import android.graphics.Rect;
import android.view.ViewGroup;

/* JADX INFO: loaded from: classes.dex */
public class h01 extends rma {
    /* JADX WARN: Removed duplicated region for block: B:17:0x0026  */
    @Override // defpackage.cv9
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public final long b(ViewGroup viewGroup, au9 au9Var, hv9 hv9Var, hv9 hv9Var2) {
        int i;
        int iRound;
        int iCenterX;
        Integer num;
        if (hv9Var == null && hv9Var2 == null) {
            return 0L;
        }
        if (hv9Var2 == null) {
            i = -1;
        } else {
            if (((hv9Var == null || (num = (Integer) hv9Var.a.get("android:visibilityPropagation:visibility")) == null) ? 8 : num.intValue()) != 0) {
                hv9Var = hv9Var2;
                i = 1;
            }
        }
        int iC = rma.c(hv9Var, 0);
        int iC2 = rma.c(hv9Var, 1);
        Rect epicenter = au9Var.getEpicenter();
        if (epicenter != null) {
            iCenterX = epicenter.centerX();
            iRound = epicenter.centerY();
        } else {
            viewGroup.getLocationOnScreen(new int[2]);
            int iRound2 = Math.round(viewGroup.getTranslationX() + (viewGroup.getWidth() / 2) + r6[0]);
            iRound = Math.round(viewGroup.getTranslationY() + (viewGroup.getHeight() / 2) + r6[1]);
            iCenterX = iRound2;
        }
        float f = iCenterX - iC;
        float f2 = iRound - iC2;
        float fSqrt = (float) Math.sqrt((f2 * f2) + (f * f));
        float width = viewGroup.getWidth() - 0.0f;
        float height = viewGroup.getHeight() - 0.0f;
        float fSqrt2 = fSqrt / ((float) Math.sqrt((height * height) + (width * width)));
        long duration = au9Var.getDuration();
        if (duration < 0) {
            duration = 300;
        }
        return Math.round(((duration * ((long) i)) / 0.0f) * fSqrt2);
    }
}
