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

Commit 14f8a0a8 authored by Luca Stefani's avatar Luca Stefani
Browse files

Revert "SystemUI: Update the media notification only when needed"

Whenever the notifications are shown it takes ~1 second for the notification to be updated, go back to the original behavior

This reverts commit cf5cfe3d.

Change-Id: I9379ae15fdae792dde35a9a9fe045c4e6af4f73d
parent 79b51ecb
Loading
Loading
Loading
Loading
+7 −13
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewStub;
import android.view.ViewTreeObserver;
import android.widget.SeekBar;
import android.widget.TextView;

@@ -46,6 +45,7 @@ import com.android.systemui.statusbar.TransformableView;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Wraps a notification containing a media template
@@ -208,19 +208,13 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi

    private void startTimer() {
        clearTimer();
        updateSeekBarView();
    }

    private void updateSeekBarView() {
        mSeekBarView.getViewTreeObserver().addOnPreDrawListener(
                new ViewTreeObserver.OnPreDrawListener(){
        mSeekBarTimer = new Timer(true /* isDaemon */);
        mSeekBarTimer.schedule(new TimerTask() {
            @Override
            public boolean onPreDraw() {
                mSeekBarView.getViewTreeObserver().removeOnPreDrawListener(this);
                mHandler.postDelayed(mOnUpdateTimerTick, PROGRESS_UPDATE_INTERVAL);
                return true;
            public void run() {
                mHandler.post(mOnUpdateTimerTick);
            }
        });
        }, 0, PROGRESS_UPDATE_INTERVAL);
    }

    private void clearTimer() {
@@ -267,7 +261,7 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi
        public void run() {
            if (mMediaController != null && mSeekBar != null) {
                PlaybackState playbackState = mMediaController.getPlaybackState();
                updateSeekBarView();

                if (playbackState != null) {
                    updatePlaybackUi(playbackState);
                } else {