diff options
Diffstat (limited to 'src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java')
-rw-r--r-- | src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java index 056dcc64e..3479dce90 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java @@ -39,7 +39,6 @@ import android.widget.SeekBar; import com.android.dialer.R; import com.android.dialer.util.AsyncTaskExecutor; import com.android.dialer.util.AsyncTaskExecutors; - import com.android.common.io.MoreCloseables; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; @@ -48,7 +47,6 @@ import java.io.IOException; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; @@ -94,6 +92,8 @@ public class VoicemailPlaybackPresenter public interface OnVoicemailDeletedListener { void onVoicemailDeleted(Uri uri); + void onVoicemailDeleteUndo(); + void onVoicemailDeletedInDatabase(); } /** The enumeration of {@link AsyncTask} objects we use in this class. */ @@ -240,7 +240,7 @@ public class VoicemailPlaybackPresenter mView = view; mView.setPresenter(this, voicemailUri); - if (mMediaPlayer != null && voicemailUri.equals(mVoicemailUri)) { + if (mMediaPlayer != null && mIsPrepared && voicemailUri.equals(mVoicemailUri)) { // Handles case where MediaPlayer was retained after an orientation change. onPrepared(mMediaPlayer); mView.onSpeakerphoneOn(isSpeakerphoneOn()); @@ -417,9 +417,11 @@ public class VoicemailPlaybackPresenter super(handler); mFetchResultHandler = handler; - mContext.getContentResolver().registerContentObserver( - voicemailUri, false, this); - mFetchResultHandler.postDelayed(this, FETCH_CONTENT_TIMEOUT_MS); + if (mContext != null) { + mContext.getContentResolver().registerContentObserver( + voicemailUri, false, this); + mFetchResultHandler.postDelayed(this, FETCH_CONTENT_TIMEOUT_MS); + } } /** @@ -585,6 +587,10 @@ public class VoicemailPlaybackPresenter * playing. */ public void resumePlayback() { + if (mView == null) { + return; + } + if (!mIsPrepared) { // If we haven't downloaded the voicemail yet, attempt to download it. checkForContent(); @@ -730,12 +736,26 @@ public class VoicemailPlaybackPresenter } /* package */ void onVoicemailDeleted() { - // Trampoline the event notification to the interested listener + // Trampoline the event notification to the interested listener. if (mOnVoicemailDeletedListener != null) { mOnVoicemailDeletedListener.onVoicemailDeleted(mVoicemailUri); } } + /* package */ void onVoicemailDeleteUndo() { + // Trampoline the event notification to the interested listener. + if (mOnVoicemailDeletedListener != null) { + mOnVoicemailDeletedListener.onVoicemailDeleteUndo(); + } + } + + /* package */ void onVoicemailDeletedInDatabase() { + // Trampoline the event notification to the interested listener. + if (mOnVoicemailDeletedListener != null) { + mOnVoicemailDeletedListener.onVoicemailDeletedInDatabase(); + } + } + private static synchronized ScheduledExecutorService getScheduledExecutorServiceInstance() { if (mScheduledExecutorService == null) { mScheduledExecutorService = Executors.newScheduledThreadPool(NUMBER_OF_THREADS_IN_POOL); |