mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 06:35:42 +00:00
Bug 863803 - Part 1: Prevent multiple AboutHome fragments from being created after restore. r=lucasr
This commit is contained in:
parent
b1fb07137b
commit
0464db2da4
@ -123,6 +123,10 @@ abstract public class BrowserApp extends GeckoApp
|
|||||||
|
|
||||||
private Integer mPrefObserverId;
|
private Integer mPrefObserverId;
|
||||||
|
|
||||||
|
// Tag for the AboutHome fragment. The fragment is automatically attached
|
||||||
|
// after restoring from a saved state, so we use this tag to identify it.
|
||||||
|
private static final String ABOUTHOME_TAG = "abouthome";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
|
public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
|
||||||
switch(msg) {
|
switch(msg) {
|
||||||
@ -358,6 +362,10 @@ abstract public class BrowserApp extends GeckoApp
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Find the Fragment if it was already added from a restored instance state.
|
||||||
|
mAboutHome = (AboutHome) getSupportFragmentManager().findFragmentByTag(ABOUTHOME_TAG);
|
||||||
|
|
||||||
|
if (mAboutHome == null) {
|
||||||
// AboutHome will be dynamically attached and detached as
|
// AboutHome will be dynamically attached and detached as
|
||||||
// about:home is shown. Adding/removing the fragment is not synchronous,
|
// about:home is shown. Adding/removing the fragment is not synchronous,
|
||||||
// so we can't use Fragment#isVisible() to determine whether the
|
// so we can't use Fragment#isVisible() to determine whether the
|
||||||
@ -365,6 +373,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||||||
// with the hint we set ourselves.
|
// with the hint we set ourselves.
|
||||||
mAboutHome = AboutHome.newInstance();
|
mAboutHome = AboutHome.newInstance();
|
||||||
mAboutHome.setUserVisibleHint(false);
|
mAboutHome.setUserVisibleHint(false);
|
||||||
|
}
|
||||||
|
|
||||||
mBrowserToolbar = new BrowserToolbar(this);
|
mBrowserToolbar = new BrowserToolbar(this);
|
||||||
mBrowserToolbar.from(actionBar);
|
mBrowserToolbar.from(actionBar);
|
||||||
@ -1092,7 +1101,7 @@ abstract public class BrowserApp extends GeckoApp
|
|||||||
// it can't be used between the Activity's onSaveInstanceState() and
|
// it can't be used between the Activity's onSaveInstanceState() and
|
||||||
// onResume().
|
// onResume().
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.add(R.id.gecko_layout, mAboutHome).commitAllowingStateLoss();
|
.add(R.id.gecko_layout, mAboutHome, ABOUTHOME_TAG).commitAllowingStateLoss();
|
||||||
mAboutHome.setUserVisibleHint(true);
|
mAboutHome.setUserVisibleHint(true);
|
||||||
|
|
||||||
mBrowserToolbar.setNextFocusDownId(R.id.abouthome_content);
|
mBrowserToolbar.setNextFocusDownId(R.id.abouthome_content);
|
||||||
|
Loading…
Reference in New Issue
Block a user