summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jian-Syuan (Shane) Wong <shanewong@google.com> 2023-07-01 00:18:24 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-07-01 00:18:24 +0000
commitfebbb93f9a9583e51262109b00a2bb313ec22046 (patch)
treee2b972783e403676b578a535c296c3b634213ef3
parent72c3553ce9d1b42f014c72ba0456ba053751971b (diff)
parent7e50a5827417115af52c5f3a9dd5e7b7e592d0f8 (diff)
Merge "Add getExpectedPresentationTimeMillis"
-rw-r--r--core/api/current.txt1
-rw-r--r--core/java/android/view/animation/AnimationUtils.java13
2 files changed, 14 insertions, 0 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index db6dc5d5dc38..e53f9445b8a0 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -54946,6 +54946,7 @@ package android.view.animation {
public class AnimationUtils {
ctor public AnimationUtils();
method public static long currentAnimationTimeMillis();
+ method public static long getExpectedPresentationTimeMillis();
method public static long getExpectedPresentationTimeNanos();
method public static android.view.animation.Animation loadAnimation(android.content.Context, @AnimRes int) throws android.content.res.Resources.NotFoundException;
method public static android.view.animation.Interpolator loadInterpolator(android.content.Context, @AnimRes @InterpolatorRes int) throws android.content.res.Resources.NotFoundException;
diff --git a/core/java/android/view/animation/AnimationUtils.java b/core/java/android/view/animation/AnimationUtils.java
index f31a43f5924f..8ba8b8cca5ed 100644
--- a/core/java/android/view/animation/AnimationUtils.java
+++ b/core/java/android/view/animation/AnimationUtils.java
@@ -30,6 +30,7 @@ import android.content.res.Resources.Theme;
import android.content.res.XmlResourceParser;
import android.os.SystemClock;
import android.util.AttributeSet;
+import android.util.TimeUtils;
import android.util.Xml;
import android.view.InflateException;
@@ -156,6 +157,18 @@ public class AnimationUtils {
}
/**
+ * The expected presentation time of a frame in the {@link SystemClock#uptimeMillis()}.
+ * Developers should prefer using this method over {@link #currentAnimationTimeMillis()}
+ * because it offers a more accurate time for the calculating animation progress.
+ *
+ * @return the expected presentation time of a frame in the
+ * {@link SystemClock#uptimeMillis()} time base.
+ */
+ public static long getExpectedPresentationTimeMillis() {
+ return getExpectedPresentationTimeNanos() / TimeUtils.NANOS_PER_MS;
+ }
+
+ /**
* Loads an {@link Animation} object from a resource
*
* @param context Application context used to access resources