summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/voicemail
diff options
context:
space:
mode:
authoruabdullah <uabdullah@google.com>2017-12-19 17:02:50 -0800
committerEric Erfanian <erfanian@google.com>2017-12-22 08:51:53 -0800
commita06002dcddc6bbf1d01350a2978d00f3c7665e6e (patch)
treef50629fb5ed497b135174e9d75abf65a79b44ddb /java/com/android/dialer/voicemail
parent2bf7d229b18ffdc6ebbc2f07ec3eaa685731e703 (diff)
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
Diffstat (limited to 'java/com/android/dialer/voicemail')
-rw-r--r--java/com/android/dialer/voicemail/listui/NewVoicemailAdapter.java19
1 files changed, 17 insertions, 2 deletions
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<ViewHolder>
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<ViewHolder>
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<ViewHolder>
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<ViewHolder>
}
public void updateCursor(Cursor updatedCursor) {
+ LogUtil.enterBlock("NewVoicemailAdapter.updateCursor");
deletedVoicemailPosition.clear();
this.cursor = updatedCursor;
+ updateHeaderPositions();
notifyDataSetChanged();
}