fixes #3705
This commit is contained in:
Samantha Houts 2018-09-10 10:06:25 -07:00 коммит произвёл Jason Smith
Родитель 3a0ccccc5c
Коммит 58992d8a5d
1 изменённых файлов: 16 добавлений и 11 удалений

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

@ -7,6 +7,7 @@ using Android.OS;
using Android.Views;
using Android.Views.Animations;
using ARelativeLayout = Android.Widget.RelativeLayout;
using AView = Android.Views.View;
using Xamarin.Forms.Internals;
namespace Xamarin.Forms.Platform.Android.AppCompat
@ -218,7 +219,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
for (var i = 0; i < _renderer.ChildCount; i++)
{
global::Android.Views.View child = _renderer.GetChildAt(i);
AView child = _renderer.GetChildAt(i);
if (child is ModalContainer)
{
child.Measure(MeasureSpecFactory.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly), MeasureSpecFactory.MakeMeasureSpec(t - b, MeasureSpecMode.Exactly));
@ -265,7 +266,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
{
var layout = false;
var viewsToRemove = new List<global::Android.Views.View>();
var viewsToRemove = new List<AView>();
var renderersToDispose = new List<IVisualElementRenderer>();
if (Page != null)
@ -273,10 +274,8 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
for (int i = 0; i < _renderer.ChildCount; i++)
viewsToRemove.Add(_renderer.GetChildAt(i));
foreach (IVisualElementRenderer rootRenderer in _navModel.Roots.Select(Android.Platform.GetRenderer))
{
rootRenderer?.Dispose();
}
foreach (var root in _navModel.Roots)
renderersToDispose.Add(Android.Platform.GetRenderer(root));
_navModel = new NavigationModel();
@ -300,13 +299,19 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
Application.Current.NavigationProxy.Inner = this;
}
void Cleanup(List<global::Android.Views.View> viewsToRemove, List<IVisualElementRenderer> renderersToDispose)
void Cleanup(List<AView> viewsToRemove, List<IVisualElementRenderer> renderersToDispose)
{
foreach (var view in viewsToRemove)
for (int i = 0; i < viewsToRemove.Count; i++)
{
AView view = viewsToRemove[i];
_renderer?.RemoveView(view);
}
foreach (IVisualElementRenderer rootRenderer in renderersToDispose)
for (int i = 0; i < renderersToDispose.Count; i++)
{
IVisualElementRenderer rootRenderer = renderersToDispose[i];
rootRenderer?.Dispose();
}
}
void AddChild(Page page, bool layout = false)
@ -381,7 +386,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
sealed class ModalContainer : ViewGroup
{
global::Android.Views.View _backgroundView;
AView _backgroundView;
bool _disposed;
Page _modal;
IVisualElementRenderer _renderer;
@ -390,7 +395,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
{
_modal = modal;
_backgroundView = new global::Android.Views.View(context);
_backgroundView = new AView(context);
_backgroundView.SetWindowBackground();
AddView(_backgroundView);