This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Type> _fragmentsQueue; | |
bool _instanceStateSaved; | |
protected override void OnSaveInstanceState(Bundle outState) | |
{ | |
_instanceStateSaved = true; // Zaznaczamy, że nie możemy już dodawać fragmentów | |
base.OnSaveInstanceState(outState); | |
} | |
protected override void OnPostResume() | |
{ | |
base.OnPostResume(); | |
_instanceStateSaved = false; // Aplikacja została już wznowiona, więc możemy znowu dodawać fragmenty | |
// Sprawdzamy, czy mamy coś w kolejce, a jeśli tak, to dodajemy te fragmenty do widoku | |
for(int i = 0; i < _fragmentsQueue.Count;) | |
{ | |
AddFragment(_fragmentsQueue[i]); | |
_fragmentsQueue.RemoveAt(0); | |
} | |
} | |
protected override void OnStop() | |
{ | |
base.OnStop(); | |
if (_instanceStateSaved) | |
{ | |
_fragmentsQueue.Add(typeof(MyFragment)); | |
} | |
else | |
{ | |
AddFragment(typeof(MyFragment)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment