From c7b413058c765603d5c65d39e4042a55ab170ef0 Mon Sep 17 00:00:00 2001 From: uabdullah Date: Tue, 14 Nov 2017 12:28:52 -0800 Subject: Combine voicemail uri and duration for NUI media player Voicemail URI and duration are both retrieved from VoicemailEntry. This CL combines it. This was a todo added from http://cl/175585919 Test: unit tests PiperOrigin-RevId: 175718355 Change-Id: I7d2748cf6e110e494f6895c512ce355aa2d048a7 --- .../voicemail/listui/NewVoicemailMediaPlayerView.java | 14 +++++++------- .../dialer/voicemail/listui/NewVoicemailViewHolder.java | 3 +-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java index b2d93b17c..4629ce277 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailMediaPlayerView.java @@ -25,6 +25,7 @@ import android.media.MediaPlayer.OnErrorListener; import android.media.MediaPlayer.OnPreparedListener; import android.net.Uri; import android.provider.VoicemailContract; +import android.support.annotation.VisibleForTesting; import android.support.v4.util.Pair; import android.util.AttributeSet; import android.view.LayoutInflater; @@ -174,6 +175,7 @@ public class NewVoicemailMediaPlayerView extends LinearLayout { } }; + @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) OnCompletionListener onCompletionListener = new OnCompletionListener() { @@ -199,6 +201,7 @@ public class NewVoicemailMediaPlayerView extends LinearLayout { } }; + @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) OnErrorListener onErrorListener = new OnErrorListener() { @Override @@ -211,20 +214,17 @@ public class NewVoicemailMediaPlayerView extends LinearLayout { } }; - void setVoicemailUri(Uri voicemailUri) { - Assert.isNotNull(voicemailUri); - this.voicemailUri = voicemailUri; - } - void setFragmentManager(FragmentManager fragmentManager) { this.fragmentManager = fragmentManager; } - // TODO(uabdullah): Merge with voicemailUri (http://cl/175585919) - void setVoicemailDuration(VoicemailEntry voicemailEntry) { + void setVoicemailEntryValues(VoicemailEntry voicemailEntry) { Assert.isNotNull(voicemailEntry); + Uri uri = Uri.parse(voicemailEntry.voicemailUri()); + Assert.isNotNull(uri); Assert.isNotNull(totalDurationView); + voicemailUri = uri; totalDurationView.setText( VoicemailEntryText.getVoicemailDuration(getContext(), voicemailEntry)); } diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java index d5546c33f..f8de01f58 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailViewHolder.java @@ -79,9 +79,8 @@ final class NewVoicemailViewHolder extends RecyclerView.ViewHolder implements On itemView.setOnClickListener(this); setPhoto(voicemailEntry); - mediaPlayerView.setVoicemailUri(Uri.parse(voicemailEntry.voicemailUri())); + mediaPlayerView.setVoicemailEntryValues(voicemailEntry); mediaPlayerView.setFragmentManager(fragmentManager); - mediaPlayerView.setVoicemailDuration(voicemailEntry); } // TODO(uabdullah): Consider/Implement TYPE (e.g Spam, TYPE_VOICEMAIL) -- cgit v1.2.3