Task counts now update correctly in filter list view

pull/14/head
Sam Bosley 14 years ago
parent c34a38be4b
commit 573e9167bd

@ -1,9 +1,9 @@
package com.todoroo.astrid.api; package com.todoroo.astrid.api;
import android.app.Activity;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.ContentValues; import android.content.ContentValues;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcel; import android.os.Parcel;
@ -37,13 +37,13 @@ public class FilterWithCustomIntent extends Filter {
super(listingTitle, title, sqlQuery, valuesForNewTasks); super(listingTitle, title, sqlQuery, valuesForNewTasks);
} }
public void start(Context context) { public void start(Activity activity, int resultCode) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtra("filter", this); //$NON-NLS-1$ intent.putExtra("filter", this); //$NON-NLS-1$
intent.setComponent(customTaskList); intent.setComponent(customTaskList);
if(customExtras != null) if(customExtras != null)
intent.putExtras(customExtras); intent.putExtras(customExtras);
context.startActivity(intent); activity.startActivityForResult(intent, resultCode);
} }
// --- parcelable // --- parcelable

@ -58,7 +58,7 @@ public class GtasksListAdder extends Activity {
StoreObject newList = gtasksListService.addNewList(service.createGtaskList(title)); StoreObject newList = gtasksListService.addNewList(service.createGtaskList(title));
if (newList != null) { if (newList != null) {
FilterWithCustomIntent listFilter = (FilterWithCustomIntent) GtasksFilterExposer.filterFromList(activity, newList); FilterWithCustomIntent listFilter = (FilterWithCustomIntent) GtasksFilterExposer.filterFromList(activity, newList);
listFilter.start(activity); listFilter.start(activity, 0);
} }
} catch (IOException e) { } catch (IOException e) {

@ -71,18 +71,20 @@ public class TagFilterExposer extends BroadcastReceiver {
/** Create filter from new tag object */ /** Create filter from new tag object */
@SuppressWarnings("nls") @SuppressWarnings("nls")
public static FilterWithCustomIntent filterFromTag(Context context, Tag tag, Criterion criterion) { public static FilterWithCustomIntent filterFromTag(Context context, Tag tag, Criterion criterion) {
String listTitle = tag.tag + " (" + tag.count + ")";
String title = context.getString(R.string.tag_FEx_name, tag.tag); String title = context.getString(R.string.tag_FEx_name, tag.tag);
QueryTemplate tagTemplate = tag.queryTemplate(criterion); QueryTemplate tagTemplate = tag.queryTemplate(criterion);
ContentValues contentValues = new ContentValues(); ContentValues contentValues = new ContentValues();
contentValues.put(Metadata.KEY.name, TagService.KEY); contentValues.put(Metadata.KEY.name, TagService.KEY);
contentValues.put(TagService.TAG.name, tag.tag); contentValues.put(TagService.TAG.name, tag.tag);
FilterWithUpdate filter = new FilterWithUpdate(listTitle, FilterWithUpdate filter = new FilterWithUpdate(tag.tag,
title, tagTemplate, title, tagTemplate,
contentValues); contentValues);
if(tag.count == 0) if(tag.remoteId > 0) {
filter.color = Color.GRAY; filter.listingTitle += " (" + tag.count + ")";
if(tag.count == 0)
filter.color = Color.GRAY;
}
filter.contextMenuLabels = new String[] { filter.contextMenuLabels = new String[] {
context.getString(R.string.tag_cm_rename), context.getString(R.string.tag_cm_rename),

@ -79,6 +79,7 @@ public class FilterListActivity extends ExpandableListActivity {
private static final int CONTEXT_MENU_INTENT = Menu.FIRST + 4; private static final int CONTEXT_MENU_INTENT = Menu.FIRST + 4;
private static final int REQUEST_CUSTOM_INTENT = 1; private static final int REQUEST_CUSTOM_INTENT = 1;
private static final int REQUEST_VIEW_TASKS = 2;
// --- instance variables // --- instance variables
@ -231,11 +232,11 @@ public class FilterListActivity extends ExpandableListActivity {
Filter filter = (Filter)item; Filter filter = (Filter)item;
if(filter instanceof FilterWithCustomIntent) { if(filter instanceof FilterWithCustomIntent) {
FilterWithCustomIntent customFilter = ((FilterWithCustomIntent)filter); FilterWithCustomIntent customFilter = ((FilterWithCustomIntent)filter);
customFilter.start(this); customFilter.start(this, REQUEST_VIEW_TASKS);
} else { } else {
Intent intent = new Intent(FilterListActivity.this, TaskListActivity.class); Intent intent = new Intent(FilterListActivity.this, TaskListActivity.class);
intent.putExtra(TaskListActivity.TOKEN_FILTER, filter); intent.putExtra(TaskListActivity.TOKEN_FILTER, filter);
startActivity(intent); startActivityForResult(intent, REQUEST_VIEW_TASKS);
} }
AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", //$NON-NLS-1$ AndroidUtilities.callApiMethod(5, this, "overridePendingTransition", //$NON-NLS-1$
new Class<?>[] { Integer.TYPE, Integer.TYPE }, new Class<?>[] { Integer.TYPE, Integer.TYPE },
@ -479,9 +480,8 @@ public class FilterListActivity extends ExpandableListActivity {
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode != RESULT_CANCELED)
adapter.clear();
// will get lists automatically // will get lists automatically
adapter.clear();
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
} }

Loading…
Cancel
Save