Last active
September 10, 2017 17:41
-
-
Save tomwis/285404c8a932e6517a88ab73072d1498 to your computer and use it in GitHub Desktop.
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