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.TaskEditMoreControls;
import com.todoroo.astrid.ui.WebServicesView;
import com.todoroo.astrid.utility.Flags;
import com.todoroo.astrid.voice.VoiceInputAssistant;
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_ASSIGNED_TO = "task_assigned_to"; //$NON-NLS-1$
public static final String TOKEN_TAGS_CHANGED = "tags_changed"; //$NON-NLS-1$
// --- services
@ -884,26 +886,32 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
boolean cancelFinish = !onPause && peopleControlSet != null
&& !peopleControlSet.saveSharingSettings(processedToast);
boolean tagsChanged = Flags.check(Flags.TAGS_CHANGED);
model.putTransitory("task-edit-save", true); //$NON-NLS-1$
taskService.save(model);
if (!onPause && !cancelFinish) {
boolean setActivityResult = (getActivity() instanceof TaskEditActivity);
if (!peopleControlSet.isAssignedToMe()) {
String assignedTo = peopleControlSet.getAssignedToString();
if (setActivityResult) {
Intent data = new Intent();
boolean isAssignedToMe = peopleControlSet.isAssignedToMe();
String assignedTo = peopleControlSet.getAssignedToString();
if (setActivityResult) {
Intent data = new Intent();
if (!isAssignedToMe) {
data.putExtra(TOKEN_TASK_WAS_ASSIGNED, true);
data.putExtra(TOKEN_ASSIGNED_TO,
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;

@ -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
TaskListFragment tlf = getTaskListFragment();
if (tlf != null) {
if (data != null
&& data.hasExtra(TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED)
&& data.getBooleanExtra(
TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED, false)) {
String assignedTo = data.getStringExtra(TaskEditFragment.TOKEN_ASSIGNED_TO);
switchToAssignedFilter(assignedTo);
if (data != null) {
if (data.getBooleanExtra(TaskEditFragment.TOKEN_TASK_WAS_ASSIGNED, false)) {
String assignedTo = data.getStringExtra(TaskEditFragment.TOKEN_ASSIGNED_TO);
switchToAssignedFilter(assignedTo);
}
if (data.getBooleanExtra(TaskEditFragment.TOKEN_TAGS_CHANGED, false))
tagsChanged(true);
} else {
tlf.refresh();
}
@ -402,6 +403,20 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
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) {
TaskListFragment tlf = getTaskListFragment();
if (tlf != null && !tlf.isFilter()) {

Loading…
Cancel
Save