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

Commit 58955276 authored by Tetsutoki Shiozawa's avatar Tetsutoki Shiozawa Committed by Alan Viverette
Browse files

[ProgressBar] Fix: Media volume bar indicates a wrong value

Symptom:
Media volume bar shows non-zero value even during the mute state.

Root cause:
A request for updating progress of ProgressBar has 2 kind of updating
ways, animated and non-animated. If a non-animated request is invoked
before completing an animated request, the visual progress can be
overwritten by the old animated request. As a result, the visual
progress value becomes different from the actual value.

Solution:
A running animation on the primary progress should be canceled
before handling a new non-animated request.

Bug: 148759348
Test: atest CtsWidgetTestCases:ProgressBarTest
Change-Id: I569dbea4c6346ecfff8141d8378b4952fb1fa530
parent ac21f749
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.widget;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.annotation.InterpolatorRes;
import android.annotation.NonNull;
@@ -245,6 +247,8 @@ public class ProgressBar extends View {

    private final ArrayList<RefreshData> mRefreshData = new ArrayList<RefreshData>();

    private ObjectAnimator mLastProgressAnimator;

    /**
     * Create a new progress bar with range 0...100 and initial progress of 0.
     * @param context the application environment
@@ -1546,8 +1550,19 @@ public class ProgressBar extends View {
            animator.setAutoCancel(true);
            animator.setDuration(PROGRESS_ANIM_DURATION);
            animator.setInterpolator(PROGRESS_ANIM_INTERPOLATOR);
            animator.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    mLastProgressAnimator = null;
                }
            });
            animator.start();
            mLastProgressAnimator = animator;
        } else {
            if (isPrimary && mLastProgressAnimator != null) {
                mLastProgressAnimator.cancel();
                mLastProgressAnimator = null;
            }
            setVisualProgress(id, scale);
        }