Merge "Handle when AnimationUtils getExpectedPresentationTimeNanos is not called in a callback" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
c4c0ca1eba
@@ -32,6 +32,7 @@ import android.os.SystemClock;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.TimeUtils;
|
||||
import android.util.Xml;
|
||||
import android.view.Choreographer;
|
||||
import android.view.InflateException;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
@@ -153,7 +154,13 @@ public class AnimationUtils {
|
||||
*/
|
||||
public static long getExpectedPresentationTimeNanos() {
|
||||
AnimationState state = sAnimationState.get();
|
||||
return state.mExpectedPresentationTimeNanos;
|
||||
if (state.animationClockLocked) {
|
||||
return state.mExpectedPresentationTimeNanos;
|
||||
}
|
||||
// When this methoed is called outside of a Choreographer callback,
|
||||
// we obtain the value of expectedPresentTimeNanos from the Choreographer.
|
||||
// This helps avoid returning a time that could potentially be earlier than current time.
|
||||
return Choreographer.getInstance().getLatestExpectedPresentTimeNanos();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user