Use initLoader instead of resetartLoader. Call onResume after setting category.

While investigating the infamous issue #606, I noticed these two things which
were a little off. Firstly, we were doing more queries than required, because the
loader was being forceably recreated when it could instead be reused in onResume.

Also, the onResume method (which results in a cursor beign created) should be
called _after_ setting the selected category. This ensures that the query
which is run has the correct category the first time, and needn't be run again.

I am not confident that this fixes the issue, but it seems to help, and I believe
it is the correct thing to do even if it doesn't fix 606.
This commit is contained in:
Peter Serwylo 2016-05-26 10:58:17 +10:00
parent 082a2f5fef
commit 810e8eae0d
2 changed files with 2 additions and 2 deletions

View File

@ -117,7 +117,7 @@ public abstract class AppListFragment extends ListFragment implements
super.onResume();
//Starts a new or restarts an existing Loader in this manager
getLoaderManager().restartLoader(0, null, this);
getLoaderManager().initLoader(0, null, this);
}
@Override

View File

@ -206,7 +206,6 @@ public class AvailableAppsFragment extends AppListFragment implements
@Override
public void onResume() {
super.onResume();
/* restore the saved Category Spinner position */
Activity activity = getActivity();
SharedPreferences p = activity.getSharedPreferences(PREFERENCES_FILE, Context.MODE_PRIVATE);
@ -222,6 +221,7 @@ public class AvailableAppsFragment extends AppListFragment implements
}
setCurrentCategory(currentCategory);
super.onResume();
}
@Override