diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index bf14b9455..a9754d30a 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -471,6 +471,13 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener } } + public void refreshFilterCount(Filter filter) { + FilterListFragment flf = getFilterListFragment(); + if (flf != null) { + flf.adapter.refreshFilterCount(filter); + } + } + @Override public void mainMenuItemSelected(int item, Intent customIntent) { TaskListFragment tlf = getTaskListFragment(); diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java index c065b66fa..a1d1431cc 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java @@ -601,7 +601,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, } else if (!Preferences.getBoolean(R.string.p_showed_lists_help, false)) { showListsHelp(); } - + refreshFilterCount(); initiateAutomaticSync(); } @@ -1069,6 +1069,12 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, } } + public void refreshFilterCount() { + if (getActivity() instanceof TaskListActivity) { + ((TaskListActivity) getActivity()).refreshFilterCount(filter); + } + } + @Override public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); diff --git a/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java b/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java index 99fe065a2..67fce6c32 100644 --- a/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/FilterAdapter.java @@ -163,7 +163,7 @@ public class FilterAdapter extends ArrayAdapter { filterCounts.put(filter, size); activity.runOnUiThread(new Runnable() { public void run() { - notifyDataSetInvalidated(); + notifyDataSetChanged(); } }); } catch (Exception e) { @@ -181,7 +181,7 @@ public class FilterAdapter extends ArrayAdapter { @Override public void add(Filter item) { super.add(item); - + notifyDataSetChanged(); // load sizes offerFilter(item); } @@ -197,7 +197,7 @@ public class FilterAdapter extends ArrayAdapter { } int newCount = Math.max(filterCount + delta, 0); filterCounts.put(filter, newCount); - notifyDataSetInvalidated(); + notifyDataSetChanged(); return newCount; } @@ -209,6 +209,23 @@ public class FilterAdapter extends ArrayAdapter { return adjustFilterCount(filter, -1); } + public void refreshFilterCount(final Filter filter) { + filterExecutor.submit(new Runnable() { + @Override + public void run() { + int size = taskService.countTasks(filter); + filterCounts.put(filter, size); + activity.runOnUiThread(new Runnable() { + + @Override + public void run() { + notifyDataSetChanged(); + } + }); + } + }); + } + /** * Create or reuse a view * @param convertView