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

Commit 5eb51def authored by Xavier Ducrohet's avatar Xavier Ducrohet
Browse files

Add some new native deletage to layoutlib.

Change-Id: Ib53df6c944ecd9680bf929afe03b08bcaa61ad70
parent 34a75df6
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
 */
public class SystemClock_Delegate {
    private static long sBootTime = System.currentTimeMillis();
    private static long sBootTimeNano = System.nanoTime();

    @LayoutlibDelegate
    /*package*/ static boolean setCurrentTimeMillis(long millis) {
@@ -59,6 +60,16 @@ public class SystemClock_Delegate {
        return System.currentTimeMillis() - sBootTime;
    }

    /**
     * Returns nanoseconds since boot, including time spent in sleep.
     *
     * @return elapsed nanoseconds since boot.
     */
    @LayoutlibDelegate
    /*package*/ static long elapsedRealtimeNano() {
        return System.nanoTime() - sBootTimeNano;
    }

    /**
     * Returns milliseconds running in the current thread.
     *
+38 −0
Original line number Diff line number Diff line
@@ -91,4 +91,42 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
    /*package*/ static float sqrt(float value) {
        return (float)Math.sqrt(value);
    }

    /**
     * Returns the closest float approximation of the raising "e" to the power
     * of the argument.
     *
     * @param value to compute the exponential of
     * @return the exponential of value
     */
    @LayoutlibDelegate
    /*package*/ static float exp(float value) {
        return (float)Math.exp(value);
    }

    /**
     * Returns the closest float approximation of the result of raising {@code
     * x} to the power of {@code y}.
     *
     * @param x the base of the operation.
     * @param y the exponent of the operation.
     * @return {@code x} to the power of {@code y}.
     */
    @LayoutlibDelegate
    /*package*/ static float pow(float x, float y) {
        return (float)Math.pow(x, y);
    }

    /**
     * Returns {@code sqrt(}<i>{@code x}</i><sup>{@code 2}</sup>{@code +} <i>
     * {@code y}</i><sup>{@code 2}</sup>{@code )}.
     *
     * @param x a float number
     * @param y a float number
     * @return the hypotenuse
     */
    @LayoutlibDelegate
    /*package*/ static float hypot(float x, float y) {
        return (float)Math.sqrt(x*x + y*y);
    }
}