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

Commit b54cc701 authored by Paulsu Su's avatar Paulsu Su
Browse files

uibench: Fix ResizeHWLayerActivity to cancel the animation when the activity is paused.

Bug: 358345639
Test: local build and run
Flag: TEST_ONLY
Change-Id: Ice440d5dfc6d3bfc664c3e4fc9e2de9bbee5a382
parent 310588dd
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();
        }
    }
}