-
using System;
using System.ComponentModel;
using System.Threading.Tasks;
if (_masterLayout != null)
{
+ if (_masterLayout.ChildView != null)
+ _masterLayout.ChildView.PropertyChanged -= HandleMasterPropertyChanged;
+
RemoveView(_masterLayout);
_masterLayout.Dispose();
_masterLayout = null;
if (_detailLayout.ChildView == null)
Update();
else
- new Handler(Looper.MainLooper).Post(() => Update());
+ // Queue up disposal of the previous renderers after the current layout updates have finished
+ new Handler(Looper.MainLooper).Post(Update);
void Update()
{
+ if (_detailLayout == null || _detailLayout.IsDisposed())
+ return;
+
Context.HideKeyboard(this);
_detailLayout.ChildView = Element.Detail;
}
void UpdateMaster()
{
-
if (_masterLayout.ChildView == null)
- new Handler(Looper.MainLooper).Post(() => Update());
- else
Update();
+ else
+ // Queue up disposal of the previous renderers after the current layout updates have finished
+ new Handler(Looper.MainLooper).Post(Update);
void Update()
{
- Android.MasterDetailContainer masterContainer = _masterLayout;
- if (masterContainer == null)
+ if (_masterLayout == null || _masterLayout.IsDisposed())
return;
- if (masterContainer.ChildView != null)
- masterContainer.ChildView.PropertyChanged -= HandleMasterPropertyChanged;
+ if (_masterLayout.ChildView != null)
+ _masterLayout.ChildView.PropertyChanged -= HandleMasterPropertyChanged;
- masterContainer.ChildView = Element.Master;
- if (Element.Master != null)
- Element.Master.PropertyChanged += HandleMasterPropertyChanged;
- }
+ _masterLayout.ChildView = Element.Master;
+ if (_masterLayout.ChildView != null)
+ _masterLayout.ChildView.PropertyChanged += HandleMasterPropertyChanged;
+ }
}
void UpdateSplitViewLayout()
using Android.Support.V4.Widget;
using Android.Views;
using AView = Android.Views.View;
-using AColor = Android.Graphics.Drawables.ColorDrawable;
using Android.OS;
using Xamarin.Forms.Platform.Android.FastRenderers;
element.SendViewInitialized(this);
if (element != null && !string.IsNullOrEmpty(element.AutomationId))
- SetAutomationId(element.AutomationId);
+ SetAutomationId(element.AutomationId);
SetContentDescription();
}
if (_masterLayout != null)
{
+ if (_masterLayout.ChildView != null)
+ _masterLayout.ChildView.PropertyChanged -= HandleMasterPropertyChanged;
+
_masterLayout.Dispose();
_masterLayout = null;
}
Update();
else
// Queue up disposal of the previous renderers after the current layout updates have finished
- new Handler(Looper.MainLooper).Post(() => Update());
+ new Handler(Looper.MainLooper).Post(Update);
void Update()
{
+ if (_detailLayout == null || _detailLayout.IsDisposed())
+ return;
+
Context.HideKeyboard(this);
_detailLayout.ChildView = _page.Detail;
}
Update();
else
// Queue up disposal of the previous renderers after the current layout updates have finished
- new Handler(Looper.MainLooper).Post(() => Update());
+ new Handler(Looper.MainLooper).Post(Update);
void Update()
{
- if (_masterLayout != null && _masterLayout.ChildView != null)
+ if (_masterLayout == null || _masterLayout.IsDisposed())
+ return;
+
+ if (_masterLayout.ChildView != null)
_masterLayout.ChildView.PropertyChanged -= HandleMasterPropertyChanged;
+
_masterLayout.ChildView = _page.Master;
- if (_page.Master != null)
- _page.Master.PropertyChanged += HandleMasterPropertyChanged;
+
+ if (_masterLayout.ChildView != null)
+ _masterLayout.ChildView.PropertyChanged += HandleMasterPropertyChanged;
}
}