From a06002dcddc6bbf1d01350a2978d00f3c7665e6e Mon Sep 17 00:00:00 2001 From: uabdullah Date: Tue, 19 Dec 2017 17:02:50 -0800 Subject: Register content observer when voicemail table changes. When a new voicemail is received, it is written in the voicemail table by the Voicemail service. However the new voicemail will not get updated/shown in the New Voicemail UI as the annotated call log would be stale. This CL ensures that when the voicemail is added, the annotated call log is marked dirty and refreshed. This way the new voicemail will be shown in the new voicemail UI. Since a new voicemail is also added, we want to make sure the headers for "today" and "older", their positions are also updated accordingly. Bug: 64882313 Test: Unit tests PiperOrigin-RevId: 179623267 Change-Id: I5dfc84f62f9f37c57ffb2dbbe7e848a58306a19d --- .../dialer/voicemail/listui/NewVoicemailAdapter.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'java/com/android/dialer/voicemail') diff --git a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java index d94a21465..93d5cda3e 100644 --- a/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java +++ b/java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java @@ -67,9 +67,9 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter private final Clock clock; /** {@link Integer#MAX_VALUE} when the "Today" header should not be displayed. */ - private final int todayHeaderPosition; + private int todayHeaderPosition = Integer.MAX_VALUE; /** {@link Integer#MAX_VALUE} when the "Older" header should not be displayed. */ - private final int olderHeaderPosition; + private int olderHeaderPosition = Integer.MAX_VALUE; private final FragmentManager fragmentManager; /** A valid id for {@link VoicemailEntry} is greater than 0 */ @@ -107,7 +107,15 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter this.clock = clock; this.fragmentManager = fragmentManager; initializeMediaPlayerListeners(); + updateHeaderPositions(); + } + private void updateHeaderPositions() { + LogUtil.i( + "NewVoicemailAdapter.updateHeaderPositions", + "before updating todayPos:%d, olderPos:%d", + todayHeaderPosition, + olderHeaderPosition); // Calculate header adapter positions by reading cursor. long currentTimeMillis = clock.currentTimeMillis(); if (cursor.moveToNext()) { @@ -134,6 +142,11 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter this.todayHeaderPosition = Integer.MAX_VALUE; this.olderHeaderPosition = Integer.MAX_VALUE; } + LogUtil.i( + "NewVoicemailAdapter.updateHeaderPositions", + "after updating todayPos:%d, olderPos:%d", + todayHeaderPosition, + olderHeaderPosition); } private void initializeMediaPlayerListeners() { @@ -143,8 +156,10 @@ final class NewVoicemailAdapter extends RecyclerView.Adapter } public void updateCursor(Cursor updatedCursor) { + LogUtil.enterBlock("NewVoicemailAdapter.updateCursor"); deletedVoicemailPosition.clear(); this.cursor = updatedCursor; + updateHeaderPositions(); notifyDataSetChanged(); } -- cgit v1.2.3