From 927ea5403b13da0a464490f5c018013d25f638bf Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Wed, 25 Apr 2012 12:24:28 -0700 Subject: [PATCH] Fixed a bug that prevented subtasks toggling from working correctly in lists --- .../todoroo/astrid/actfm/TagViewFragment.java | 17 ++++++++++------- .../astrid/activity/TaskListActivity.java | 2 +- .../astrid/ui/TaskListFragmentPager.java | 9 +++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java index 2dd1ee450..ff53db73c 100644 --- a/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java +++ b/astrid/plugin-src/com/todoroo/astrid/actfm/TagViewFragment.java @@ -515,16 +515,19 @@ public class TagViewFragment extends TaskListFragment { @Override protected void toggleDragDrop(boolean newState) { - Filter newFilter = TagFilterExposer.filterFromTagData(getActivity(), tagData); + Class customComponent; if(newState) - ((FilterWithCustomIntent)newFilter).customTaskList = - new ComponentName(getActivity(), SubtasksTagListFragment.class); - else - ((FilterWithCustomIntent)newFilter).customTaskList = - new ComponentName(getActivity(), TagViewFragment.class); + customComponent = SubtasksTagListFragment.class; + else { + filter.setFilterQueryOverride(null); + customComponent = TagViewFragment.class; + } + + ((FilterWithCustomIntent) filter).customTaskList = new ComponentName(getActivity(), customComponent); - ((AstridActivity)getActivity()).onFilterItemClicked(newFilter); + ((AstridActivity)getActivity()).setupTasklistFragmentWithFilterAndCustomTaskList(filter, + extras, customComponent); } @Override diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java index 342084f31..e80382ccd 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListActivity.java @@ -244,7 +244,7 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener public void setupTasklistFragmentWithFilterAndCustomTaskList(Filter filter, Bundle extras, Class customTaskList) { if (swipeIsEnabled()) { tlfPager.showFilterWithCustomTaskList(filter, customTaskList); - tlfPager.setAdapter(tlfPagerAdapter); // Hack to force reload of current page + tlfPager.forceReload(); // Hack to force reload of current page } else { super.setupTasklistFragmentWithFilterAndCustomTaskList(filter, extras, customTaskList); } diff --git a/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java b/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java index b1a60aa19..c6350c9bd 100644 --- a/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java +++ b/astrid/src/com/todoroo/astrid/ui/TaskListFragmentPager.java @@ -30,6 +30,15 @@ public class TaskListFragmentPager extends ViewPager { super.setAdapter(adapter); } + /** + * Hack to enable reloading fragments while they are being viewed + */ + public void forceReload() { + int position = getCurrentItem(); + setAdapter(getAdapter()); + setCurrentItem(position, false); + } + /** * Show the supplied filter, adding it to the data source if it doesn't exist * @param f