From bae7b937b6cf6e7eb26d07bec95de38083923614 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 15 Jun 2015 16:06:14 -0700 Subject: Add play voicemail primary action to call log. + Add voicemail primary action button, which expands the call log and plays immediately when clicked. + Pass expand/collapse listener into the view holder. This is necessary because it needs to be triggered when the "play" primary action is clicked so that the CallLogAdapter correctly registers what has been added and binded. + Update primary action button state when showing or hiding actions, so the visibility of the voicemail play button is managed properly. + Ensure voicemail playback state is consistent between multiple call log items when the user initiates a collapse or expand. Add reset function to help manage this. + With the reset, protect against the possibility of functions in the presenter being called when no voicemail playback view is set. Bug: 21654755 Change-Id: I7bcf67d27fa08fe77d1334dc084b52effe8d3ccc --- .../voicemail/VoicemailPlaybackPresenter.java | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/com/android/dialer/voicemail') diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java index d47e9e213..cc6437627 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java @@ -178,6 +178,18 @@ public class VoicemailPlaybackPresenter mMediaPlayer.setOnCompletionListener(this); } + public void reset() { + pausePlayback(); + + mView = null; + mVoicemailUri = null; + + mIsPrepared = false; + mIsPlaying = false; + mPosition = 0; + mDuration.set(0); + } + /** * Specify the view which this presenter controls and the voicemail for playback. */ @@ -204,7 +216,6 @@ public class VoicemailPlaybackPresenter mView.onSpeakerphoneOn(false); checkForContent(); - } } @@ -341,7 +352,9 @@ public class VoicemailPlaybackPresenter public void run() { if (mIsWaitingForResult.getAndSet(false)) { mContext.getContentResolver().unregisterContentObserver(this); - mView.setFetchContentTimeout(); + if (mView != null) { + mView.setFetchContentTimeout(); + } } } @@ -384,7 +397,11 @@ public class VoicemailPlaybackPresenter * and it will call {@link #onError()} otherwise. */ private void prepareToPlayContent() { + if (mView == null) { + return; + } mIsPrepared = false; + mView.setIsBuffering(); try { @@ -402,7 +419,11 @@ public class VoicemailPlaybackPresenter */ @Override public void onPrepared(MediaPlayer mp) { + if (mView == null) { + return; + } mIsPrepared = true; + mDuration.set(mMediaPlayer.getDuration()); mView.enableUiElements(); @@ -421,7 +442,7 @@ public class VoicemailPlaybackPresenter */ @Override public boolean onError(MediaPlayer mp, int what, int extra) { - handleError(new IllegalStateException("MediaPlayer error listener invoked")); + handleError(new IllegalStateException("MediaPlayer error listener invoked: " + extra)); return true; } -- cgit v1.2.3