summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2015-09-16 17:34:34 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-09-16 17:34:34 +0000
commit76639fcf8c897595395692055e011945461a9bc7 (patch)
tree4a930339265faecd2378742416fba215a4dfeb36 /src
parent05e4466ce905eaa21440f4f3fb347a614949a4a1 (diff)
parent74e886898a9283cc033c44d2809592e0d85f17e1 (diff)
Merge "Update "X mins ago" on each minute change." into ub-contactsdialer-a-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index 8762f1822..26e39651b 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -34,6 +34,7 @@ import android.database.Cursor;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Message;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract;
@@ -89,6 +90,10 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
private static final int READ_CALL_LOG_PERMISSION_REQUEST_CODE = 1;
+ private static final int EVENT_UPDATE_DISPLAY = 1;
+
+ private static final long MILLIS_IN_MINUTE = 60 * 1000;
+
private RecyclerView mRecyclerView;
private LinearLayoutManager mLayoutManager;
private CallLogAdapter mAdapter;
@@ -106,6 +111,18 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
private boolean mCallLogFetched;
private boolean mVoicemailStatusFetched;
+ private final Handler mDisplayUpdateHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case EVENT_UPDATE_DISPLAY:
+ refreshData();
+ rescheduleDisplayUpdate();
+ break;
+ }
+ }
+ };
+
private final Handler mHandler = new Handler();
private class CustomContentObserver extends ContentObserver {
@@ -343,10 +360,14 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
mHasReadCallLogPermission = hasReadCallLogPermission;
refreshData();
mAdapter.startCache();
+
+ rescheduleDisplayUpdate();
}
@Override
public void onPause() {
+ cancelDisplayUpdate();
+
if (mVoicemailPlaybackPresenter != null) {
mVoicemailPlaybackPresenter.onPause();
}
@@ -517,4 +538,25 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis
}
}
}
+
+ /**
+ * Schedules an update to the relative call times (X mins ago).
+ */
+ private void rescheduleDisplayUpdate() {
+ if (!mDisplayUpdateHandler.hasMessages(EVENT_UPDATE_DISPLAY)) {
+ long time = System.currentTimeMillis();
+ // This value allows us to change the display relatively close to when the time changes
+ // from one minute to the next.
+ long millisUtilNextMinute = MILLIS_IN_MINUTE - (time % MILLIS_IN_MINUTE);
+ mDisplayUpdateHandler.sendEmptyMessageDelayed(
+ EVENT_UPDATE_DISPLAY, millisUtilNextMinute);
+ }
+ }
+
+ /**
+ * Cancels any pending update requests to update the relative call times (X mins ago).
+ */
+ private void cancelDisplayUpdate() {
+ mDisplayUpdateHandler.removeMessages(EVENT_UPDATE_DISPLAY);
+ }
}