Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8e8cdbb authored by Neil Fuller's avatar Neil Fuller Committed by Gerrit Code Review
Browse files

Merge "Remove usages of FloatMath"

parents d884c63c e573aa93
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Path;
import android.util.AttributeSet;
import android.util.FloatMath;

/**
 * A PathMotion that generates a curved path along an arc on an imaginary circle containing
@@ -257,7 +256,7 @@ public class ArcMotion extends PathMotion {
            }
            if (newArcDistance2 != 0) {
                float ratio2 = newArcDistance2 / arcDist2;
                float ratio = FloatMath.sqrt(ratio2);
                float ratio = (float) Math.sqrt(ratio2);
                ex = dx + (ratio * (ex - dx));
                ey = dy + (ratio * (ey - dy));
            }
+7 −8
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
package android.transition;

import android.graphics.Rect;
import android.util.FloatMath;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
@@ -87,9 +86,9 @@ public class CircularPropagation extends VisibilityPropagation {
            epicenterY = Math.round(loc[1] + (sceneRoot.getHeight() / 2)
                    + sceneRoot.getTranslationY());
        }
        float distance = distance(viewCenterX, viewCenterY, epicenterX, epicenterY);
        float maxDistance = distance(0, 0, sceneRoot.getWidth(), sceneRoot.getHeight());
        float distanceFraction = distance/maxDistance;
        double distance = distance(viewCenterX, viewCenterY, epicenterX, epicenterY);
        double maxDistance = distance(0, 0, sceneRoot.getWidth(), sceneRoot.getHeight());
        double distanceFraction = distance/maxDistance;

        long duration = transition.getDuration();
        if (duration < 0) {
@@ -99,9 +98,9 @@ public class CircularPropagation extends VisibilityPropagation {
        return Math.round(duration * directionMultiplier / mPropagationSpeed * distanceFraction);
    }

    private static float distance(float x1, float y1, float x2, float y2) {
        float x = x2 - x1;
        float y = y2 - y1;
        return FloatMath.sqrt((x * x) + (y * y));
    private static double distance(float x1, float y1, float x2, float y2) {
        double x = x2 - x1;
        double y = y2 - y1;
        return Math.hypot(x, y);
    }
}
+10 −14
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.animation.TimeInterpolator;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.FloatMath;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
@@ -143,32 +142,29 @@ public class Explode extends Visibility {

        int centerX = bounds.centerX();
        int centerY = bounds.centerY();
        float xVector = centerX - focalX;
        float yVector = centerY - focalY;
        double xVector = centerX - focalX;
        double yVector = centerY - focalY;

        if (xVector == 0 && yVector == 0) {
            // Random direction when View is centered on focal View.
            xVector = (float) (Math.random() * 2) - 1;
            yVector = (float) (Math.random() * 2) - 1;
            xVector = (Math.random() * 2) - 1;
            yVector = (Math.random() * 2) - 1;
        }
        float vectorSize = calculateDistance(xVector, yVector);
        double vectorSize = Math.hypot(xVector, yVector);
        xVector /= vectorSize;
        yVector /= vectorSize;

        float maxDistance =
        double maxDistance =
                calculateMaxDistance(sceneRoot, focalX - sceneRootX, focalY - sceneRootY);

        outVector[0] = Math.round(maxDistance * xVector);
        outVector[1] = Math.round(maxDistance * yVector);
        outVector[0] = (int) Math.round(maxDistance * xVector);
        outVector[1] = (int) Math.round(maxDistance * yVector);
    }

    private static float calculateMaxDistance(View sceneRoot, int focalX, int focalY) {
    private static double calculateMaxDistance(View sceneRoot, int focalX, int focalY) {
        int maxX = Math.max(focalX, sceneRoot.getWidth() - focalX);
        int maxY = Math.max(focalY, sceneRoot.getHeight() - focalY);
        return calculateDistance(maxX, maxY);
        return Math.hypot(maxX, maxY);
    }

    private static float calculateDistance(float x, float y) {
        return FloatMath.sqrt((x * x) + (y * y));
    }
}
+4 −8
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.PathMeasure;
import android.util.AttributeSet;
import android.util.FloatMath;
import android.util.PathParser;

/**
@@ -119,7 +118,7 @@ public class PatternPathMotion extends PathMotion {
        mTempMatrix.setTranslate(-startX, -startY);
        float dx = endX - startX;
        float dy = endY - startY;
        float distance = distance(dx, dy);
        float distance = (float) Math.hypot(dx, dy);
        float scale = 1 / distance;
        mTempMatrix.postScale(scale, scale);
        double angle = Math.atan2(dy, dx);
@@ -130,9 +129,9 @@ public class PatternPathMotion extends PathMotion {

    @Override
    public Path getPath(float startX, float startY, float endX, float endY) {
        float dx = endX - startX;
        float dy = endY - startY;
        float length = distance(dx, dy);
        double dx = endX - startX;
        double dy = endY - startY;
        float length = (float) Math.hypot(dx, dy);
        double angle = Math.atan2(dy, dx);

        mTempMatrix.setScale(length, length);
@@ -143,7 +142,4 @@ public class PatternPathMotion extends PathMotion {
        return path;
    }

    private static float distance(float x, float y) {
        return FloatMath.sqrt((x * x) + (y * y));
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@
package android.transition;

import android.graphics.Rect;
import android.util.FloatMath;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
Loading