diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-12-12 23:18:50 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-12-12 23:18:50 +0000 |
commit | 888e6b1499f7be68f2d33f870a57cd7e2a58dd93 (patch) | |
tree | 85148446a15528867fba0d7353b024081d9e0a5a /java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java | |
parent | ab544521b21566b12a42e539d119c76dd5243a2d (diff) | |
parent | 75d67f5d83bdb28c6254cf064d09ac24fc9ae928 (diff) |
Merge changes I45978ea4,Ia85b1008,I9e68c561,I9255dd3c
* changes:
BEGIN_PUBLIC Automated rollback of changelist 172683494
BEGIN_PUBLIC Automated rollback of changelist 172956409
Download and play voicemails from server when not locally available.
Updated writing of PhoneLookup columns in annotated call log.
Diffstat (limited to 'java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java')
-rw-r--r-- | java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java index 955c7daee..671a39a67 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java @@ -56,7 +56,7 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder> int VOICEMAIL_ENTRY = 2; } - private final Cursor cursor; + private Cursor cursor; private final Clock clock; /** {@link Integer#MAX_VALUE} when the "Today" header should not be displayed. */ @@ -129,6 +129,11 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder> mediaPlayer.setOnErrorListener(onErrorListener); } + public void updateCursor(Cursor updatedCursor) { + this.cursor = updatedCursor; + notifyDataSetChanged(); + } + @Override public ViewHolder onCreateViewHolder(ViewGroup viewGroup, @RowType int viewType) { LogUtil.enterBlock("NewVoicemailAdapter.onCreateViewHolder"); @@ -714,7 +719,7 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder> // returned when currentlyExpandedViewHolderId = -1 (viewholder was collapsed) LogUtil.i( "NewVoicemailAdapter.getCurrentlyExpandedViewHolder", - "no view holder found in newVoicemailViewHolderArrayMap size:%d for %d", + "no view holder found in hashmap size:%d for %d", newVoicemailViewHolderArrayMap.size(), currentlyExpandedViewHolderId); // TODO(uabdullah): a bug Remove logging, temporarily here for debugging. @@ -749,4 +754,34 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter<ViewHolder> } return RowType.VOICEMAIL_ENTRY; } + + /** + * This will be called once the voicemail that was attempted to be played (and was not locally + * available) was downloaded from the server. However it is possible that by the time the download + * was completed, the view holder was collapsed. In that case we shouldn't play the voicemail. + */ + public void checkAndPlayVoicemail() { + LogUtil.i( + "NewVoicemailAdapter.checkAndPlayVoicemail", + "expandedViewHolder:%d, inViewHolderSet:%b, MPRequestToDownload:%s", + currentlyExpandedViewHolderId, + isCurrentlyExpandedViewHolderInViewHolderSet(), + String.valueOf(mediaPlayer.getVoicemailRequestedToDownload())); + + NewVoicemailViewHolder currentlyExpandedViewHolder = getCurrentlyExpandedViewHolder(); + if (currentlyExpandedViewHolderId != -1 + && isCurrentlyExpandedViewHolderInViewHolderSet() + && currentlyExpandedViewHolder != null + // Used to differentiate underlying table changes from voicemail downloads and other changes + // (e.g delete) + && mediaPlayer.getVoicemailRequestedToDownload() != null + && (mediaPlayer + .getVoicemailRequestedToDownload() + .equals(currentlyExpandedViewHolder.getViewHolderVoicemailUri()))) { + currentlyExpandedViewHolder.clickPlayButtonOfViewHoldersMediaPlayerView( + currentlyExpandedViewHolder); + } else { + LogUtil.i("NewVoicemailAdapter.checkAndPlayVoicemail", "not playing downloaded voicemail"); + } + } } |