diff options
Diffstat (limited to 'src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java')
-rw-r--r-- | src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java index fb9e3edfb..7270af787 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java @@ -92,6 +92,10 @@ public class VoicemailPlaybackPresenter void setPresenter(VoicemailPlaybackPresenter presenter, Uri voicemailUri); } + public interface OnVoicemailDeletedListener { + void onVoicemailDeleted(Uri uri); + } + /** The enumeration of {@link AsyncTask} objects we use in this class. */ public enum Tasks { CHECK_FOR_CONTENT, @@ -155,6 +159,8 @@ public class VoicemailPlaybackPresenter private PowerManager.WakeLock mProximityWakeLock; private AudioManager mAudioManager; + private OnVoicemailDeletedListener mOnVoicemailDeletedListener; + /** * Obtain singleton instance of this class. Use a single instance to provide a consistent * listener to the AudioManager when requesting and abandoning audio focus. @@ -634,7 +640,8 @@ public class VoicemailPlaybackPresenter mMediaPlayer.pause(); } - mPosition = mMediaPlayer.getCurrentPosition(); + mPosition = mMediaPlayer == null ? 0 : mMediaPlayer.getCurrentPosition(); + Log.d(TAG, "Paused playback at " + mPosition + "."); if (mView != null) { @@ -653,7 +660,9 @@ public class VoicemailPlaybackPresenter * playing to know whether to resume playback once the user selects a new position. */ public void pausePlaybackForSeeking() { - mShouldResumePlaybackAfterSeeking = mMediaPlayer.isPlaying(); + if (mMediaPlayer != null) { + mShouldResumePlaybackAfterSeeking = mMediaPlayer.isPlaying(); + } pausePlayback(); } @@ -712,10 +721,21 @@ public class VoicemailPlaybackPresenter return mAudioManager.isSpeakerphoneOn(); } + public void setOnVoicemailDeletedListener(OnVoicemailDeletedListener listener) { + mOnVoicemailDeletedListener = listener; + } + public int getMediaPlayerPosition() { return mIsPrepared && mMediaPlayer != null ? mMediaPlayer.getCurrentPosition() : 0; } + /* package */ void onVoicemailDeleted() { + // Trampoline the event notification to the interested listener + if (mOnVoicemailDeletedListener != null) { + mOnVoicemailDeletedListener.onVoicemailDeleted(mVoicemailUri); + } + } + private static synchronized ScheduledExecutorService getScheduledExecutorServiceInstance() { if (mScheduledExecutorService == null) { mScheduledExecutorService = Executors.newScheduledThreadPool(NUMBER_OF_THREADS_IN_POOL); |