Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1936)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/ChromeAnimation.java

Issue 1801363006: Adding callback for finished property animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding unit test Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/ChromeAnimation.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/ChromeAnimation.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/ChromeAnimation.java
index e873636dfc01383566eeb9b26584bab67a8f3282..5933a66a8e46883d77b32d6ee32565aec3c7377a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/ChromeAnimation.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/ChromeAnimation.java
@@ -219,6 +219,7 @@ public class ChromeAnimation<T> {
private long mDuration;
private long mStartDelay;
private boolean mDelayStartValue;
+ private boolean mHasFinished;
private Interpolator mInterpolator = getDecelerateInterpolator();
/**
@@ -313,6 +314,7 @@ public class ChromeAnimation<T> {
* Starts the animation and calls setProperty() with the initial value.
*/
public void start() {
+ mHasFinished = false;
mCurrentTime = 0;
update(0);
}
@@ -321,10 +323,12 @@ public class ChromeAnimation<T> {
* @return Whether or not this current animation is finished.
*/
public boolean finished() {
- if (mCurrentTime >= mDuration + mStartDelay) {
- return true;
+ if (!mHasFinished && mCurrentTime >= mDuration + mStartDelay) {
+ mHasFinished = true;
+ onPropertyAnimationFinished();
}
- return false;
+
+ return mHasFinished;
}
/**
@@ -342,6 +346,11 @@ public class ChromeAnimation<T> {
* @param p The current animated value based on the current time and the Interpolator.
*/
public abstract void setProperty(float p);
+
+ /**
+ * The abstract method that gets called when the property animation finished.
+ */
+ public abstract void onPropertyAnimationFinished();
}
/**
@@ -359,6 +368,12 @@ public class ChromeAnimation<T> {
*/
public void setProperty(T prop, float val);
+ /**
+ * Notifies that the animation for a certain property has finished.
+ *
+ * @param prop The property that has finished animating.
+ */
+ public void onPropertyAnimationFinished(T prop);
}
/**
@@ -391,6 +406,11 @@ public class ChromeAnimation<T> {
mAnimatedObject.setProperty(mProperty, p);
}
+ @Override
+ public void onPropertyAnimationFinished() {
+ mAnimatedObject.onPropertyAnimationFinished(mProperty);
+ }
+
/**
* Helper method to add an {@link ChromeAnimation.AnimatableAnimation}
* to a {@link ChromeAnimation}

Powered by Google App Engine
This is Rietveld 408576698