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:
parent
082a2f5fef
commit
810e8eae0d
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user