diff options
author | Andrew Lee <anwlee@google.com> | 2015-06-12 21:44:47 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-06-12 21:44:47 +0000 |
commit | 6a0ba62d864d08223c09fe48b05497ee663443b1 (patch) | |
tree | fb50a5f1e1f6b61cc8a8f3ef274b6908fac28ea1 /src | |
parent | f764f247d74c454030a790f6f69a6a64f4086064 (diff) | |
parent | 31ace0a01cc0d23f00b9de342cc4077dcfb19ff5 (diff) |
am 31ace0a0: am 477d4883: Merge "Don\'t pass media player to VM playback layout." into mnc-dev
* commit '31ace0a01cc0d23f00b9de342cc4077dcfb19ff5':
Don't pass media player to VM playback layout.
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java | 20 | ||||
-rw-r--r-- | src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java | 9 |
2 files changed, 14 insertions, 15 deletions
diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java b/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java index 0313f4004..73f4b3b1c 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackLayout.java @@ -69,17 +69,13 @@ public class VoicemailPlaybackLayout extends LinearLayout /** Update rate for the slider, 30fps. */ private static final int SLIDER_UPDATE_PERIOD_MILLIS = 1000 / 30; - private final MediaPlayer mMediaPlayer; - private final int mDuration; + private int mDuration; private final ScheduledExecutorService mExecutorService; private final Object mLock = new Object(); @GuardedBy("mLock") private ScheduledFuture<?> mScheduledFuture; - public PositionUpdater( - MediaPlayer mediaPlayer, - ScheduledExecutorService executorService) { - mMediaPlayer = mediaPlayer; - mDuration = mediaPlayer.getDuration(); + public PositionUpdater(int duration, ScheduledExecutorService executorService) { + mDuration = duration; mExecutorService = executorService; } @@ -90,11 +86,11 @@ public class VoicemailPlaybackLayout extends LinearLayout public void run() { int currentPosition = 0; synchronized (mLock) { - if (mScheduledFuture == null) { + if (mScheduledFuture == null || mPresenter == null) { // This task has been canceled. Just stop now. return; } - currentPosition = mMediaPlayer.getCurrentPosition(); + currentPosition = mPresenter.getMediaPlayerPosition(); } setClipPosition(currentPosition, mDuration); } @@ -234,9 +230,7 @@ public class VoicemailPlaybackLayout extends LinearLayout } @Override - public void onPlaybackStarted( - MediaPlayer mediaPlayer, - ScheduledExecutorService executorService) { + public void onPlaybackStarted(int duration, ScheduledExecutorService executorService) { mIsPlaying = true; mStartStopButton.setImageResource(R.drawable.ic_hold_pause); @@ -245,7 +239,7 @@ public class VoicemailPlaybackLayout extends LinearLayout onSpeakerphoneOn(mPresenter.isSpeakerphoneOn()); } - mPositionUpdater = new PositionUpdater(mediaPlayer, executorService); + mPositionUpdater = new PositionUpdater(duration, executorService); mPositionUpdater.startUpdating(); } diff --git a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java index 5b4478f53..d47e9e213 100644 --- a/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java +++ b/src/com/android/dialer/voicemail/VoicemailPlaybackPresenter.java @@ -78,7 +78,7 @@ public class VoicemailPlaybackPresenter void disableUiElements(); void enableUiElements(); void onPlaybackError(Exception e); - void onPlaybackStarted(MediaPlayer mediaPlayer, ScheduledExecutorService executorService); + void onPlaybackStarted(int duration, ScheduledExecutorService executorService); void onPlaybackStopped(); void onSpeakerphoneOn(boolean on); void setClipPosition(int clipPositionInMillis, int clipLengthInMillis); @@ -197,6 +197,7 @@ public class VoicemailPlaybackPresenter } else { mVoicemailUri = voicemailUri; mPosition = 0; + mDuration.set(0); mIsPlaying = startPlayingImmediately; // Default to earpiece. @@ -498,7 +499,7 @@ public class VoicemailPlaybackPresenter } enableProximitySensor(); - mView.onPlaybackStarted(mMediaPlayer, getScheduledExecutorServiceInstance()); + mView.onPlaybackStarted(mDuration.get(), getScheduledExecutorServiceInstance()); } /** @@ -584,6 +585,10 @@ public class VoicemailPlaybackPresenter return mVoicemailUri; } + public int getMediaPlayerPosition() { + return mIsPrepared ? mMediaPlayer.getCurrentPosition() : 0; + } + private static synchronized ScheduledExecutorService getScheduledExecutorServiceInstance() { if (mScheduledExecutorService == null) { mScheduledExecutorService = Executors.newScheduledThreadPool(NUMBER_OF_THREADS_IN_POOL); |