Refresh filter list when tags changed

pull/14/head
Sam Bosley 13 years ago
parent 0cb19515ac
commit a6fd67d109

@ -102,6 +102,7 @@ import com.todoroo.astrid.ui.NestableViewPager;
import com.todoroo.astrid.ui.ReminderControlSet; import com.todoroo.astrid.ui.ReminderControlSet;
import com.todoroo.astrid.ui.TaskEditMoreControls; import com.todoroo.astrid.ui.TaskEditMoreControls;
import com.todoroo.astrid.ui.WebServicesView; import com.todoroo.astrid.ui.WebServicesView;
import com.todoroo.astrid.utility.Flags;
import com.todoroo.astrid.voice.VoiceInputAssistant; import com.todoroo.astrid.voice.VoiceInputAssistant;
import com.viewpagerindicator.TabPageIndicator; import com.viewpagerindicator.TabPageIndicator;
@ -173,6 +174,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
public static final String TOKEN_TASK_WAS_ASSIGNED = "task_assigned"; //$NON-NLS-1$ public static final String TOKEN_TASK_WAS_ASSIGNED = "task_assigned"; //$NON-NLS-1$
public static final String TOKEN_ASSIGNED_TO = "task_assigned_to"; //$NON-NLS-1$ public static final String TOKEN_ASSIGNED_TO = "task_assigned_to"; //$NON-NLS-1$
public static final String TOKEN_TAGS_CHANGED = "tags_changed"; //$NON-NLS-1$
// --- services // --- services
@ -884,26 +886,32 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
boolean cancelFinish = !onPause && peopleControlSet != null boolean cancelFinish = !onPause && peopleControlSet != null
&& !peopleControlSet.saveSharingSettings(processedToast); && !peopleControlSet.saveSharingSettings(processedToast);
boolean tagsChanged = Flags.check(Flags.TAGS_CHANGED);
model.putTransitory("task-edit-save", true); //$NON-NLS-1$ model.putTransitory("task-edit-save", true); //$NON-NLS-1$
taskService.save(model); taskService.save(model);
if (!onPause && !cancelFinish) { if (!onPause && !cancelFinish) {
boolean setActivityResult = (getActivity() instanceof TaskEditActivity); boolean setActivityResult = (getActivity() instanceof TaskEditActivity);
boolean isAssignedToMe = peopleControlSet.isAssignedToMe();
if (!peopleControlSet.isAssignedToMe()) { String assignedTo = peopleControlSet.getAssignedToString();
String assignedTo = peopleControlSet.getAssignedToString(); if (setActivityResult) {
if (setActivityResult) { Intent data = new Intent();
Intent data = new Intent(); if (!isAssignedToMe) {
data.putExtra(TOKEN_TASK_WAS_ASSIGNED, true); data.putExtra(TOKEN_TASK_WAS_ASSIGNED, true);
data.putExtra(TOKEN_ASSIGNED_TO, data.putExtra(TOKEN_ASSIGNED_TO,
assignedTo); assignedTo);
getActivity().setResult(Activity.RESULT_OK, data);
} else {
// Notify task list fragment in multi-column case
// since the activity isn't actually finishing
TaskListActivity tla = (TaskListActivity) getActivity();
tla.switchToAssignedFilter(assignedTo);
} }
data.putExtra(TOKEN_TAGS_CHANGED, tagsChanged);
getActivity().setResult(Activity.RESULT_OK, data);
} else {
// Notify task list fragment in multi-column case
// since the activity isn't actually finishing
TaskListActivity tla = (TaskListActivity) getActivity();
if (!isAssignedToMe)
tla.switchToAssignedFilter(assignedTo);
if (tagsChanged)
tla.tagsChanged();
} }
shouldSaveState = false; shouldSaveState = false;

@ -387,12 +387,13 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
// For cases when we're in a multi-frame layout, the TaskEditFragment will notify us here directly // For cases when we're in a multi-frame layout, the TaskEditFragment will notify us here directly
TaskListFragment tlf = getTaskListFragment(); TaskListFragment tlf = getTaskListFragment();
if (tlf != null) { if (tlf != null) {
if (data != null if (data != null) {
&& data.hasExtra(TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED) if (data.getBooleanExtra(TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED, false)) {
&& data.getBooleanExtra( String assignedTo = data.getStringExtra(TaskEditFragment.TOKEN_ASSIGNED_TO);
TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED, false)) { switchToAssignedFilter(assignedTo);
String assignedTo = data.getStringExtra(TaskEditFragment.TOKEN_ASSIGNED_TO); }
switchToAssignedFilter(assignedTo); if (data.getBooleanExtra(TaskEditFragment.TOKEN_TAGS_CHANGED, false))
tagsChanged(true);
} else { } else {
tlf.refresh(); tlf.refresh();
} }
@ -402,6 +403,20 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
} }
protected void tagsChanged() {
tagsChanged(false);
}
private void tagsChanged(boolean onActivityResult) {
FilterListFragment flf = getFilterListFragment();
if (flf != null) {
if (onActivityResult)
flf.clear();
else
flf.refresh();
}
}
protected void switchToAssignedFilter(final String assignedEmail) { protected void switchToAssignedFilter(final String assignedEmail) {
TaskListFragment tlf = getTaskListFragment(); TaskListFragment tlf = getTaskListFragment();
if (tlf != null && !tlf.isFilter()) { if (tlf != null && !tlf.isFilter()) {

Loading…
Cancel
Save