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

Commit a8cb6e11 authored by Beth Thibodeau's avatar Beth Thibodeau Committed by Android (Google) Code Review
Browse files

Merge "Fix null pointer exceptions"

parents 9b6ae901 58e0ee0d
Loading
Loading
Loading
Loading
+22 −14
Original line number Diff line number Diff line
@@ -200,21 +200,25 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi

    private boolean canSeekMedia() {
        if (mMediaController == null || mMediaController.getPlaybackState() == null) {
            Log.d(TAG, "Cannot seek media because the controller is invalid");
            return false;
        }

        long actions = mMediaController.getPlaybackState().getActions();
        Log.d(TAG, "Playback state actions are " + actions);
        return (actions == 0 || (actions & PlaybackState.ACTION_SEEK_TO) != 0);
    }

    protected final Runnable mUpdatePlaybackUi = new Runnable() {
        @Override
        public void run() {
            if (mMediaController != null && mMediaController.getMetadata() != null
                    && mSeekBar != null) {
                long position = mMediaController.getPlaybackState().getPosition();
                long duration = mMediaController.getMetadata().getLong(
                        MediaMetadata.METADATA_KEY_DURATION);
            if (mMediaController != null && mSeekBar != null) {
                MediaMetadata metadata = mMediaController.getMetadata();
                PlaybackState playbackState = mMediaController.getPlaybackState();

                if (metadata != null && playbackState != null) {
                    long position = playbackState.getPosition();
                    long duration = metadata.getLong(MediaMetadata.METADATA_KEY_DURATION);

                    if (mDuration != duration) {
                        mDuration = duration;
@@ -225,7 +229,11 @@ public class NotificationMediaTemplateViewWrapper extends NotificationTemplateVi

                    mSeekBarElapsedTime.setText(millisecondsToTimeString(position));
                } else {
                // We no longer have a media session / notification
                    Log.d(TAG, "Controller missing data " + metadata + " " + playbackState);
                    clearTimer();
                }
            } else {
                Log.d(TAG, "No longer have a valid media controller");
                clearTimer();
            }
        }