Use the broadcast refresh mechanism for sync finished callbacks in TLA and TVA. This gives better consistency and fewer crashes."

pull/14/head
Sam Bosley 14 years ago
parent bcb47384e3
commit dc40e65b1d

@ -259,9 +259,7 @@ public class TagViewActivity extends TaskListActivity {
R.id.progressBar, new Runnable() { R.id.progressBar, new Runnable() {
@Override @Override
public void run() { public void run() {
setUpMembersGallery(); ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH));
loadTaskListContent(true);
((TextView)taskListView.findViewById(android.R.id.empty)).setText(R.string.TLA_no_items);
} }
})); }));
Preferences.setLong(LAST_FETCH_KEY + tagData.getId(), DateUtilities.now()); Preferences.setLong(LAST_FETCH_KEY + tagData.getId(), DateUtilities.now());
@ -472,4 +470,11 @@ public class TagViewActivity extends TaskListActivity {
return super.onMenuItemSelected(featureId, item); return super.onMenuItemSelected(featureId, item);
} }
@Override
protected void refresh() {
setUpMembersGallery();
loadTaskListContent(true);
((TextView)taskListView.findViewById(android.R.id.empty)).setText(R.string.TLA_no_items);
}
} }

@ -639,13 +639,22 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
taskAdapter.flushCaches(); refresh();
loadTaskListContent(true);
} }
}); });
} }
} }
/**
* Called by the RefreshReceiver when the task list receives a refresh
* broadcast. Subclasses should override this.
*/
protected void refresh() {
taskAdapter.flushCaches();
loadTaskListContent(true);
}
/** /**
* Receiver which receives sync provider intents * Receiver which receives sync provider intents
* *
@ -1133,12 +1142,7 @@ public class TaskListActivity extends ListActivity implements OnScrollListener,
R.id.progressBar, new Runnable() { R.id.progressBar, new Runnable() {
@Override @Override
public void run() { public void run() {
try { ContextManager.getContext().sendBroadcast(new Intent(AstridApiConstants.BROADCAST_EVENT_REFRESH));
loadTaskListContent(true);
} catch (IllegalStateException e) {
// Activity was killed, maybe by a rotation or list switch or something.
// Don't worry about it
}
} }
})); }));
Preferences.setLong(PREF_LAST_AUTO_SYNC, DateUtilities.now()); Preferences.setLong(PREF_LAST_AUTO_SYNC, DateUtilities.now());

Loading…
Cancel
Save