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

Commit 34cd48bc authored by Alan Viverette's avatar Alan Viverette Committed by Gerrit Code Review
Browse files

Merge "Chronometer: Update the value only if displayed on screen"

parents f1f13f98 814e1f51
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.os.SystemClock;
import android.text.format.DateUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.widget.RemoteViews.RemoteView;

@@ -226,6 +227,12 @@ public class Chronometer extends TextView {
        updateRunning();
    }

    @Override
    protected void onVisibilityChanged(View changedView, int visibility) {
        super.onVisibilityChanged(changedView, visibility);
        updateRunning();
    }

    private synchronized void updateText(long now) {
        mNow = now;
        long seconds = now - mBase;
@@ -254,7 +261,7 @@ public class Chronometer extends TextView {
    }

    private void updateRunning() {
        boolean running = mVisible && mStarted;
        boolean running = mVisible && mStarted && isShown();
        if (running != mRunning) {
            if (running) {
                updateText(SystemClock.elapsedRealtime());