Update filter counts when clicked

pull/14/head
Sam Bosley 13 years ago
parent 48eb6c50f0
commit 07e493cedf

@ -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 @Override
public void mainMenuItemSelected(int item, Intent customIntent) { public void mainMenuItemSelected(int item, Intent customIntent) {
TaskListFragment tlf = getTaskListFragment(); TaskListFragment tlf = getTaskListFragment();

@ -601,7 +601,7 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
} else if (!Preferences.getBoolean(R.string.p_showed_lists_help, false)) { } else if (!Preferences.getBoolean(R.string.p_showed_lists_help, false)) {
showListsHelp(); showListsHelp();
} }
refreshFilterCount();
initiateAutomaticSync(); initiateAutomaticSync();
} }
@ -1069,6 +1069,12 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
} }
} }
public void refreshFilterCount() {
if (getActivity() instanceof TaskListActivity) {
((TaskListActivity) getActivity()).refreshFilterCount(filter);
}
}
@Override @Override
public void onListItemClick(ListView l, View v, int position, long id) { public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id); super.onListItemClick(l, v, position, id);

@ -163,7 +163,7 @@ public class FilterAdapter extends ArrayAdapter<Filter> {
filterCounts.put(filter, size); filterCounts.put(filter, size);
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
public void run() { public void run() {
notifyDataSetInvalidated(); notifyDataSetChanged();
} }
}); });
} catch (Exception e) { } catch (Exception e) {
@ -181,7 +181,7 @@ public class FilterAdapter extends ArrayAdapter<Filter> {
@Override @Override
public void add(Filter item) { public void add(Filter item) {
super.add(item); super.add(item);
notifyDataSetChanged();
// load sizes // load sizes
offerFilter(item); offerFilter(item);
} }
@ -197,7 +197,7 @@ public class FilterAdapter extends ArrayAdapter<Filter> {
} }
int newCount = Math.max(filterCount + delta, 0); int newCount = Math.max(filterCount + delta, 0);
filterCounts.put(filter, newCount); filterCounts.put(filter, newCount);
notifyDataSetInvalidated(); notifyDataSetChanged();
return newCount; return newCount;
} }
@ -209,6 +209,23 @@ public class FilterAdapter extends ArrayAdapter<Filter> {
return adjustFilterCount(filter, -1); 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 * Create or reuse a view
* @param convertView * @param convertView

Loading…
Cancel
Save