mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 03:08:19 +00:00
am 50bdf7e0: Merge "Only postpone animations if app is visible" into jb-mr2-dev
* commit '50bdf7e04483455f2b9d112373ce1cb6a738141b': Only postpone animations if app is visible
This commit is contained in:
@@ -43,6 +43,7 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter
|
||||
|
||||
private static ViewTreeObserver.OnDrawListener sGlobalDrawListener;
|
||||
private static long sGlobalFrameCounter;
|
||||
private static boolean sVisible;
|
||||
|
||||
public FirstFrameAnimatorHelper(ValueAnimator animator, View target) {
|
||||
mTarget = target;
|
||||
@@ -61,6 +62,10 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter
|
||||
onAnimationUpdate(va);
|
||||
}
|
||||
|
||||
public static void setIsVisible(boolean visible) {
|
||||
sVisible = visible;
|
||||
}
|
||||
|
||||
public static void initializeDrawListener(View view) {
|
||||
if (sGlobalDrawListener != null) {
|
||||
view.getViewTreeObserver().removeOnDrawListener(sGlobalDrawListener);
|
||||
@@ -77,6 +82,7 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter
|
||||
}
|
||||
};
|
||||
view.getViewTreeObserver().addOnDrawListener(sGlobalDrawListener);
|
||||
sVisible = true;
|
||||
}
|
||||
|
||||
public void onAnimationUpdate(final ValueAnimator animation) {
|
||||
@@ -87,6 +93,7 @@ public class FirstFrameAnimatorHelper extends AnimatorListenerAdapter
|
||||
}
|
||||
|
||||
if (!mHandlingOnAnimationUpdate &&
|
||||
sVisible &&
|
||||
// If the current play time exceeds the duration, the animation
|
||||
// will get finished, even if we call setCurrentPlayTime -- therefore
|
||||
// don't adjust the animation in that case
|
||||
|
||||
@@ -717,6 +717,18 @@ public final class Launcher extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
FirstFrameAnimatorHelper.setIsVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
FirstFrameAnimatorHelper.setIsVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
Reference in New Issue
Block a user