mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 18:55:30 +00:00
Bug 949429 - Properly handle redisplay() calls before HomePager config is loaded (r=margaret)
This commit is contained in:
parent
7df0e90023
commit
b9162f335a
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user