Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01de9dad authored by Paulsu Su's avatar Paulsu Su Committed by Android (Google) Code Review
Browse files

Merge "uibench: Fix ResizeHWLayerActivity to cancel the animation when the...

Merge "uibench: Fix ResizeHWLayerActivity to cancel the animation when the activity is paused." into main
parents 361c5c1b b54cc701
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ import android.widget.FrameLayout;
 */
public class ResizeHWLayerActivity extends AppCompatActivity {

    private ValueAnimator mAnimator;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -43,10 +45,10 @@ public class ResizeHWLayerActivity extends AppCompatActivity {
        PropertyValuesHolder pvhWidth = PropertyValuesHolder.ofInt("width", width, 1);
        PropertyValuesHolder pvhHeight = PropertyValuesHolder.ofInt("height", height, 1);
        final LayoutParams params = child.getLayoutParams();
        ValueAnimator animator = ValueAnimator.ofPropertyValuesHolder(pvhWidth, pvhHeight);
        animator.setRepeatMode(ValueAnimator.REVERSE);
        animator.setRepeatCount(ValueAnimator.INFINITE);
        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        mAnimator = ValueAnimator.ofPropertyValuesHolder(pvhWidth, pvhHeight);
        mAnimator.setRepeatMode(ValueAnimator.REVERSE);
        mAnimator.setRepeatCount(ValueAnimator.INFINITE);
        mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                params.width = (Integer)valueAnimator.getAnimatedValue("width");
@@ -54,7 +56,15 @@ public class ResizeHWLayerActivity extends AppCompatActivity {
                child.requestLayout();
            }
        });
        animator.start();
        mAnimator.start();
        setContentView(child);
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (mAnimator != null) {
            mAnimator.cancel();
        }
    }
}