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
부모 082a2f5fef
커밋 810e8eae0d
2개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제

파일 보기

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

파일 보기

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