Merge "Do not run background animation without a Looper" into sc-dev am: c359d54b49

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15474611

Change-Id: Ic8a5a56e5c1a37790d5397df0c08af5a2cde9dd9
This commit is contained in:
Lucas Dupin
2021-08-05 23:05:24 +00:00
committed by Automerger Merge Worker

View File

@@ -49,7 +49,9 @@ import android.graphics.RecordingCanvas;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Shader; import android.graphics.Shader;
import android.os.Build; import android.os.Build;
import android.os.Looper;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator; import android.view.animation.LinearInterpolator;
@@ -113,6 +115,7 @@ import java.util.Arrays;
* @attr ref android.R.styleable#RippleDrawable_color * @attr ref android.R.styleable#RippleDrawable_color
*/ */
public class RippleDrawable extends LayerDrawable { public class RippleDrawable extends LayerDrawable {
private static final String TAG = "RippleDrawable";
/** /**
* Radius value that specifies the ripple radius should be computed based * Radius value that specifies the ripple radius should be computed based
* on the size of the ripple's container. * on the size of the ripple's container.
@@ -848,6 +851,10 @@ public class RippleDrawable extends LayerDrawable {
private void startBackgroundAnimation() { private void startBackgroundAnimation() {
mRunBackgroundAnimation = false; mRunBackgroundAnimation = false;
if (Looper.myLooper() == null) {
Log.w(TAG, "Thread doesn't have a looper. Skipping animation.");
return;
}
mBackgroundAnimation = ValueAnimator.ofFloat(mBackgroundOpacity, mTargetBackgroundOpacity); mBackgroundAnimation = ValueAnimator.ofFloat(mBackgroundOpacity, mTargetBackgroundOpacity);
mBackgroundAnimation.setInterpolator(LINEAR_INTERPOLATOR); mBackgroundAnimation.setInterpolator(LINEAR_INTERPOLATOR);
mBackgroundAnimation.setDuration(BACKGROUND_OPACITY_DURATION); mBackgroundAnimation.setDuration(BACKGROUND_OPACITY_DURATION);