diff options
Diffstat (limited to 'src/com/android/dialer/voicemail')
-rw-r--r-- | src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java | 1 | ||||
-rw-r--r-- | src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java | 44 |
2 files changed, 35 insertions, 10 deletions
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java b/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java index d8fe21bc1..158ed5834 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java @@ -185,6 +185,7 @@ public class VoicemailPlaybackLayout extends LinearLayout } mPresenter.pausePlayback(); CallLogAsyncTaskUtil.deleteVoicemail(mContext, mVoicemailUri, null); + mPresenter.onVoicemailDeleted(); } }; diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java index 90617df79..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. @@ -260,7 +266,17 @@ public class VoicemailPlaybackPresenter } /** - * Reset the presenter for playback. + * Reset the presenter for playback back to its original state. + */ + public void resetAll() { + reset(); + + mView = null; + mVoicemailUri = null; + } + + /** + * Reset the presenter such that it is as if the voicemail has not been played. */ public void reset() { if (mMediaPlayer != null) { @@ -270,13 +286,15 @@ public class VoicemailPlaybackPresenter disableProximitySensor(false /* waitForFarState */); - mView = null; - mVoicemailUri = null; - mIsPrepared = false; mIsPlaying = false; mPosition = 0; mDuration.set(0); + + if (mView != null) { + mView.onPlaybackStopped(); + mView.setClipPosition(0, mDuration.get()); + } } /** @@ -291,16 +309,11 @@ public class VoicemailPlaybackPresenter } // Release the media player, otherwise there may be failures. - if (mMediaPlayer != null) { - mMediaPlayer.release(); - mMediaPlayer = null; - mIsPrepared = false; - } + reset(); if (mActivity != null) { mActivity.getWindow().clearFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); } - disableProximitySensor(false /* waitForFarState */); } /** @@ -708,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); |