Bug 949429 - Properly handle redisplay() calls before HomePager config is loaded (r=margaret)

This commit is contained in:
Lucas Rocha 2013-12-12 12:34:16 -08:00
parent 7df0e90023
commit b9162f335a
2 changed files with 16 additions and 1 deletions

View File

@ -96,6 +96,12 @@ class HomeAdapter extends FragmentStatePagerAdapter {
}
public Page getPageAtPosition(int position) {
// getPageAtPosition() might be called before HomeAdapter
// has got its initial list of PageEntries. Just bail.
if (mPageInfos.isEmpty()) {
return null;
}
PageInfo info = mPageInfos.get(position);
return info.toPage();
}

View File

@ -186,7 +186,16 @@ public class HomePager extends ViewPager {
public void redisplay(LoaderManager lm, FragmentManager fm) {
final HomeAdapter adapter = (HomeAdapter) getAdapter();
Page currentPage = adapter.getPageAtPosition(getCurrentItem());
// If mInitialPage is non-null, this means the HomePager hasn't
// finished loading its config yet. Simply re-show() with the
// current target page.
final Page currentPage;
if (mInitialPage != null) {
currentPage = mInitialPage;
} else {
currentPage = adapter.getPageAtPosition(getCurrentItem());
}
show(lm, fm, currentPage, null);
}