Set not previewer flag early (#8406)
This commit is contained in:
Родитель
df5dc1c232
Коммит
4c3e2b228b
|
@ -265,6 +265,7 @@ namespace Xamarin.Forms.Platform.Android
|
|||
_powerSaveModeBroadcastReceiver = new PowerSaveModeBroadcastReceiver();
|
||||
}
|
||||
|
||||
ContextExtensions.SetDesignerContext(_layout);
|
||||
Profile.FrameEnd();
|
||||
}
|
||||
|
||||
|
@ -433,7 +434,6 @@ namespace Xamarin.Forms.Platform.Android
|
|||
PopupManager.ResetBusyCount(this);
|
||||
|
||||
Platform = new AppCompat.Platform(this);
|
||||
|
||||
Platform.SetPage(page);
|
||||
_layout.AddView(Platform);
|
||||
_layout.BringToFront();
|
||||
|
|
|
@ -130,14 +130,32 @@ namespace Xamarin.Forms.Platform.Android
|
|||
if (_isDesignerContext.HasValue)
|
||||
return _isDesignerContext.Value;
|
||||
|
||||
context.SetDesignerContext();
|
||||
return _isDesignerContext.Value;
|
||||
}
|
||||
|
||||
internal static void SetDesignerContext(this Context context)
|
||||
{
|
||||
if (_isDesignerContext.HasValue)
|
||||
return;
|
||||
|
||||
if (context == null)
|
||||
_isDesignerContext = false;
|
||||
else if ($"{context}".Contains("com.android.layoutlib.bridge.android.BridgeContext"))
|
||||
_isDesignerContext = true;
|
||||
else if (context is ContextWrapper contextWrapper)
|
||||
return contextWrapper.BaseContext.IsDesignerContext();
|
||||
else
|
||||
_isDesignerContext = false;
|
||||
}
|
||||
|
||||
internal static void SetDesignerContext(global::Android.Views.View view)
|
||||
{
|
||||
_isDesignerContext = view.IsInEditMode;
|
||||
}
|
||||
|
||||
internal static bool IsDesignerContext(this global::Android.Views.View view)
|
||||
{
|
||||
if (!_isDesignerContext.HasValue)
|
||||
SetDesignerContext(view);
|
||||
|
||||
return _isDesignerContext.Value;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче