[Android] Refresh main page on activity resume if main page has been changed when activity was paused (#9257) fixes #9093 fixes #5236

This commit is contained in:
Kevin Petit 2020-01-29 12:55:49 +01:00 коммит произвёл GitHub
Родитель 06c41ad09a
Коммит b04b5a1a1e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -55,6 +55,7 @@ namespace Xamarin.Forms.Platform.Android
bool _renderersAdded;
bool _activityCreated;
bool _needMainPageAssign;
bool _powerSaveReceiverRegistered;
PowerSaveModeBroadcastReceiver _powerSaveModeBroadcastReceiver;
@ -341,6 +342,13 @@ namespace Xamarin.Forms.Platform.Android
_previousState = _currentState;
_currentState = AndroidApplicationLifecycleState.OnResume;
if (_needMainPageAssign)
{
_needMainPageAssign = false;
SetMainPage();
}
if (!_powerSaveReceiverRegistered && Forms.IsLollipopOrNewer)
{
// Start listening for power save mode changes
@ -397,6 +405,12 @@ namespace Xamarin.Forms.Platform.Android
// Activity in pause must not react to application changes
if (_currentState >= AndroidApplicationLifecycleState.OnPause)
{
// If the main page is set after the activity has been paused, delay it to resume step
if (args.PropertyName == nameof(_application.MainPage))
{
_needMainPageAssign = true;
}
return;
}