Fix summary lifecycle
Once more and probably not for all Don't let multiple listening state changes get queued, this can cause rapid changes like listening->not listening->listening. Also store listening state on the worker thread now that we drop some state messages and only notify summaries when there is a state change. Change-Id: I93a5f364e9b35929f9088e044ebefd9be69740e6 Fixes: 28319383
This commit is contained in:
@@ -51,6 +51,7 @@ public class SummaryLoader {
|
||||
|
||||
private DashboardAdapter mAdapter;
|
||||
private boolean mListening;
|
||||
private boolean mWorkerListening;
|
||||
private ArrayList<BroadcastReceiver> mReceivers = new ArrayList<>();
|
||||
|
||||
public SummaryLoader(Activity activity, List<DashboardCategory> categories) {
|
||||
@@ -105,6 +106,7 @@ public class SummaryLoader {
|
||||
mActivity.unregisterReceiver(mReceivers.get(i));
|
||||
}
|
||||
mReceivers.clear();
|
||||
mWorker.removeMessages(Worker.MSG_SET_LISTENING);
|
||||
mWorker.obtainMessage(Worker.MSG_SET_LISTENING, listening ? 1 : 0, 0).sendToTarget();
|
||||
}
|
||||
|
||||
@@ -164,6 +166,8 @@ public class SummaryLoader {
|
||||
}
|
||||
|
||||
private synchronized void setListeningW(boolean listening) {
|
||||
if (mWorkerListening == listening) return;
|
||||
mWorkerListening = listening;
|
||||
if (DEBUG) Log.d(TAG, "Listening " + listening);
|
||||
for (SummaryProvider p : mSummaryMap.keySet()) {
|
||||
try {
|
||||
|
Reference in New Issue
Block a user