Commit b9e0157c authored by Geoffrey Métais's avatar Geoffrey Métais

Improve fragments mgmt on activity restoration

parent 8dbc0b8c
......@@ -130,18 +130,21 @@ public class MainActivity extends ContentActivity implements FilterQueryProvider
initAudioPlayerContainerActivity();
if (savedInstanceState != null) {
FragmentManager fm = getSupportFragmentManager();
final FragmentManager fm = getSupportFragmentManager();
//Restore fragments stack
if (fm != null && fm.getFragments() != null)
if (fm != null && fm.getFragments() != null) {
final FragmentTransaction ft = fm.beginTransaction();
for (Fragment fragment : fm.getFragments())
if (fragment != null) {
if (fragment instanceof ExtensionBrowser) {
fm.beginTransaction().remove(fragment).commit();
} else {
ft.remove(fragment);
} else if ((fragment instanceof MediaBrowserFragment)) {
mFragmentsStack.put(fragment.getTag(), new WeakReference<>(fragment));
fm.beginTransaction().hide(fragment).commit();
ft.hide(fragment);
}
}
ft.commit();
}
mCurrentFragmentId = savedInstanceState.getInt("current", mSettings.getInt("fragment_id", R.id.nav_video));
} else
reloadPreferences();
......
......@@ -125,7 +125,6 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.setVisibility(View.VISIBLE);
if (AndroidUtil.isJellyBeanMR1OrLater) {
DEFAULT_BACKGROUND_DARKER_ID = UiTools.getResourceFromAttribute(view.getContext(), R.attr.background_default_darker);
DEFAULT_BACKGROUND_ID = UiTools.getResourceFromAttribute(view.getContext(), R.attr.background_default);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment