}
}
- private void queryContactInfo(CallerInfoQuery ciq) {
+ private boolean queryContactInfo(CallerInfoQuery ciq) {
// First check if there was a prior request for the same number
// that was already satisfied
ContactInfo info = mContactInfo.get(ciq.number);
+ boolean needNotify = false;
if (info != null && info != ContactInfo.EMPTY) {
- synchronized (mRequests) {
- if (mRequests.isEmpty()) {
- mHandler.sendEmptyMessage(REDRAW);
- }
- }
+ return true;
} else {
Cursor phonesCursor =
RecentCallsListActivity.this.getContentResolver().query(
mContactInfo.put(ciq.number, info);
// Inform list to update this item, if in view
- synchronized (mRequests) {
- if (mRequests.isEmpty()) {
- mHandler.sendEmptyMessage(REDRAW);
- }
- }
+ needNotify = true;
}
phonesCursor.close();
}
if (info != null) {
updateCallLog(ciq, info);
}
+ return needNotify;
}
/*
* @see java.lang.Runnable#run()
*/
public void run() {
+ boolean needNotify = false;
while (!mDone) {
CallerInfoQuery ciq = null;
synchronized (mRequests) {
if (!mRequests.isEmpty()) {
ciq = mRequests.removeFirst();
} else {
+ if (needNotify) {
+ needNotify = false;
+ mHandler.sendEmptyMessage(REDRAW);
+ }
try {
mRequests.wait(1000);
} catch (InterruptedException ie) {
}
}
}
- if (ciq != null) {
- queryContactInfo(ciq);
+ if (ciq != null && queryContactInfo(ciq)) {
+ needNotify = true;
}
}
}
sFormattingType = FORMATTING_TYPE_INVALID;
}
-
@Override
- protected void onStart() {
- super.onStart();
+ protected void onResume() {
// The adapter caches looked up numbers, clear it so they will get
// looked up again.
if (mAdapter != null) {
}
startQuery();
- }
-
- @Override
- protected void onResume() {
resetNewCallsFlag();
+
super.onResume();
+
mAdapter.mPreDrawListener = null; // Let it restart the thread after next draw
}
@Override
protected void onPause() {
super.onPause();
+
// Kill the requests thread
mAdapter.stopRequestProcessing();
}
@Override
protected void onDestroy() {
super.onDestroy();
+ mAdapter.stopRequestProcessing();
mAdapter.changeCursor(null);
}