diff options
author | Andrew Lee <anwlee@google.com> | 2015-06-12 21:57:24 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-06-12 21:57:24 +0000 |
commit | 383951801bd78a215fd45bed27c9ee7d5b9828b9 (patch) | |
tree | 1006e82b2e84d1da95186e7d0fc646d28dc39e1e | |
parent | 5deebb6eeb79a09dc3658619472376b8c95085c5 (diff) | |
parent | 6a0ba62d864d08223c09fe48b05497ee663443b1 (diff) |
am 6a0ba62d: am 31ace0a0: am 477d4883: Merge "Don\'t pass media player to VM playback layout." into mnc-dev
* commit '6a0ba62d864d08223c09fe48b05497ee663443b1':
Don't pass media player to VM playback layout.
-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); |