Remove memory inefficient droid layouts
This commit is contained in:
Родитель
0f5d2a482f
Коммит
c91e6a3066
|
@ -208,9 +208,6 @@ namespace MvvmCross.Binding.Droid
|
|||
registry.AddOrOverwrite(typeof(MvxListView), nameof(MvxListView.ItemsSource));
|
||||
registry.AddOrOverwrite(typeof(MvxLinearLayout), nameof(MvxLinearLayout.ItemsSource));
|
||||
registry.AddOrOverwrite(typeof(MvxGridView), nameof(MvxGridView.ItemsSource));
|
||||
registry.AddOrOverwrite(typeof(MvxRelativeLayout), nameof(MvxRelativeLayout.ItemsSource));
|
||||
registry.AddOrOverwrite(typeof(MvxFrameLayout), nameof(MvxFrameLayout.ItemsSource));
|
||||
registry.AddOrOverwrite(typeof(MvxTableLayout), nameof(MvxTableLayout.ItemsSource));
|
||||
registry.AddOrOverwrite(typeof(MvxFrameControl), nameof(MvxFrameControl.DataContext));
|
||||
registry.AddOrOverwrite(typeof(MvxImageView), nameof(MvxImageView.ImageUrl));
|
||||
registry.AddOrOverwrite(typeof(MvxDatePicker), nameof(MvxDatePicker.Value));
|
||||
|
|
|
@ -1,126 +0,0 @@
|
|||
// MvxFrameLayout.cs
|
||||
|
||||
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
|
||||
// Contributions and inspirations noted in readme.md and license.txt
|
||||
//
|
||||
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using Android.Content;
|
||||
using Android.Runtime;
|
||||
using Android.Util;
|
||||
using Android.Widget;
|
||||
using MvvmCross.Binding.Attributes;
|
||||
using MvvmCross.Binding.BindingContext;
|
||||
|
||||
namespace MvvmCross.Binding.Droid.Views
|
||||
{
|
||||
[Register("mvvmcross.binding.droid.views.MvxFrameLayout")]
|
||||
public class MvxFrameLayout
|
||||
: FrameLayout, IMvxWithChangeAdapter
|
||||
{
|
||||
public MvxFrameLayout(Context context, IAttributeSet attrs)
|
||||
: this(context, attrs, new MvxAdapterWithChangedEvent(context))
|
||||
{
|
||||
}
|
||||
|
||||
public MvxFrameLayout(Context context, IAttributeSet attrs, IMvxAdapterWithChangedEvent adapter)
|
||||
: base(context, attrs)
|
||||
{
|
||||
var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs);
|
||||
if (adapter != null)
|
||||
{
|
||||
Adapter = adapter;
|
||||
Adapter.ItemTemplateId = itemTemplateId;
|
||||
}
|
||||
ChildViewRemoved += OnChildViewRemoved;
|
||||
}
|
||||
|
||||
protected MvxFrameLayout(IntPtr javaReference, JniHandleOwnership transfer)
|
||||
: base(javaReference, transfer)
|
||||
{
|
||||
}
|
||||
|
||||
public void AdapterOnDataSetChanged(object sender, NotifyCollectionChangedEventArgs eventArgs)
|
||||
{
|
||||
this.UpdateDataSetFromChange(sender, eventArgs);
|
||||
}
|
||||
|
||||
private void OnChildViewRemoved(object sender, ChildViewRemovedEventArgs childViewRemovedEventArgs)
|
||||
{
|
||||
var boundChild = childViewRemovedEventArgs.Child as IMvxBindingContextOwner;
|
||||
boundChild?.ClearAllBindings();
|
||||
}
|
||||
|
||||
private IMvxAdapterWithChangedEvent _adapter;
|
||||
|
||||
public IMvxAdapterWithChangedEvent Adapter
|
||||
{
|
||||
get
|
||||
{
|
||||
return _adapter;
|
||||
}
|
||||
protected set
|
||||
{
|
||||
var existing = _adapter;
|
||||
if (existing == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
existing.DataSetChanged -= AdapterOnDataSetChanged;
|
||||
if (value != null)
|
||||
{
|
||||
value.ItemsSource = existing.ItemsSource;
|
||||
value.ItemTemplateId = existing.ItemTemplateId;
|
||||
}
|
||||
}
|
||||
|
||||
_adapter = value;
|
||||
|
||||
if (_adapter != null)
|
||||
{
|
||||
_adapter.DataSetChanged += AdapterOnDataSetChanged;
|
||||
}
|
||||
else
|
||||
{
|
||||
MvxBindingLog.Warning(
|
||||
"Setting Adapter to null is not recommended - you may lose ItemsSource binding when doing this");
|
||||
}
|
||||
|
||||
if (existing != null)
|
||||
existing.ItemsSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
[MvxSetToNullAfterBinding]
|
||||
public IEnumerable ItemsSource
|
||||
{
|
||||
get { return Adapter.ItemsSource; }
|
||||
set { Adapter.ItemsSource = value; }
|
||||
}
|
||||
|
||||
public int ItemTemplateId
|
||||
{
|
||||
get { return Adapter.ItemTemplateId; }
|
||||
set { Adapter.ItemTemplateId = value; }
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (_adapter != null)
|
||||
_adapter.DataSetChanged -= AdapterOnDataSetChanged;
|
||||
|
||||
ChildViewRemoved -= OnChildViewRemoved;
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
// MvxRelativeLayout.cs
|
||||
|
||||
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
|
||||
// Contributions and inspirations noted in readme.md and license.txt
|
||||
//
|
||||
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using Android.Content;
|
||||
using Android.Runtime;
|
||||
using Android.Util;
|
||||
using Android.Widget;
|
||||
using MvvmCross.Binding.Attributes;
|
||||
using MvvmCross.Binding.BindingContext;
|
||||
|
||||
namespace MvvmCross.Binding.Droid.Views
|
||||
{
|
||||
[Register("mvvmcross.binding.droid.views.MvxRelativeLayout")]
|
||||
public class MvxRelativeLayout
|
||||
: RelativeLayout, IMvxWithChangeAdapter
|
||||
{
|
||||
public MvxRelativeLayout(Context context, IAttributeSet attrs)
|
||||
: this(context, attrs, new MvxAdapterWithChangedEvent(context))
|
||||
{
|
||||
}
|
||||
|
||||
public MvxRelativeLayout(Context context, IAttributeSet attrs, IMvxAdapterWithChangedEvent adapter)
|
||||
: base(context, attrs)
|
||||
{
|
||||
var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs);
|
||||
if (adapter != null)
|
||||
{
|
||||
Adapter = adapter;
|
||||
Adapter.ItemTemplateId = itemTemplateId;
|
||||
}
|
||||
ChildViewRemoved += OnChildViewRemoved;
|
||||
}
|
||||
|
||||
protected MvxRelativeLayout(IntPtr javaReference, JniHandleOwnership transfer)
|
||||
: base(javaReference, transfer)
|
||||
{
|
||||
}
|
||||
|
||||
public void AdapterOnDataSetChanged(object sender, NotifyCollectionChangedEventArgs eventArgs)
|
||||
{
|
||||
this.UpdateDataSetFromChange(sender, eventArgs);
|
||||
}
|
||||
|
||||
private void OnChildViewRemoved(object sender, ChildViewRemovedEventArgs childViewRemovedEventArgs)
|
||||
{
|
||||
var boundChild = childViewRemovedEventArgs.Child as IMvxBindingContextOwner;
|
||||
boundChild?.ClearAllBindings();
|
||||
}
|
||||
|
||||
private IMvxAdapterWithChangedEvent _adapter;
|
||||
|
||||
public IMvxAdapterWithChangedEvent Adapter
|
||||
{
|
||||
get
|
||||
{
|
||||
return _adapter;
|
||||
}
|
||||
protected set
|
||||
{
|
||||
var existing = _adapter;
|
||||
if (existing == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
existing.DataSetChanged -= AdapterOnDataSetChanged;
|
||||
if (value != null)
|
||||
{
|
||||
value.ItemsSource = existing.ItemsSource;
|
||||
value.ItemTemplateId = existing.ItemTemplateId;
|
||||
}
|
||||
}
|
||||
|
||||
_adapter = value;
|
||||
|
||||
if (_adapter != null)
|
||||
{
|
||||
_adapter.DataSetChanged += AdapterOnDataSetChanged;
|
||||
}
|
||||
else
|
||||
{
|
||||
MvxBindingLog.Warning(
|
||||
"Setting Adapter to null is not recommended - you may lose ItemsSource binding when doing this");
|
||||
}
|
||||
|
||||
if (existing != null)
|
||||
existing.ItemsSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
[MvxSetToNullAfterBinding]
|
||||
public IEnumerable ItemsSource
|
||||
{
|
||||
get { return Adapter.ItemsSource; }
|
||||
set { Adapter.ItemsSource = value; }
|
||||
}
|
||||
|
||||
public int ItemTemplateId
|
||||
{
|
||||
get { return Adapter.ItemTemplateId; }
|
||||
set { Adapter.ItemTemplateId = value; }
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
ChildViewRemoved -= OnChildViewRemoved;
|
||||
|
||||
if (_adapter != null)
|
||||
_adapter.DataSetChanged -= AdapterOnDataSetChanged;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
// MvxTableLayout.cs
|
||||
|
||||
// MvvmCross is licensed using Microsoft Public License (Ms-PL)
|
||||
// Contributions and inspirations noted in readme.md and license.txt
|
||||
//
|
||||
// Project Lead - Stuart Lodge, @slodge, me@slodge.com
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using Android.Content;
|
||||
using Android.Runtime;
|
||||
using Android.Util;
|
||||
using Android.Widget;
|
||||
using MvvmCross.Binding.Attributes;
|
||||
using MvvmCross.Binding.BindingContext;
|
||||
|
||||
namespace MvvmCross.Binding.Droid.Views
|
||||
{
|
||||
[Register("mvvmcross.binding.droid.views.MvxTableLayout")]
|
||||
public class MvxTableLayout
|
||||
: TableLayout, IMvxWithChangeAdapter
|
||||
{
|
||||
public MvxTableLayout(Context context, IAttributeSet attrs)
|
||||
: this(context, attrs, new MvxAdapterWithChangedEvent(context))
|
||||
{
|
||||
}
|
||||
|
||||
public MvxTableLayout(Context context, IAttributeSet attrs, IMvxAdapterWithChangedEvent adapter)
|
||||
: base(context, attrs)
|
||||
{
|
||||
var itemTemplateId = MvxAttributeHelpers.ReadListItemTemplateId(context, attrs);
|
||||
if (adapter != null)
|
||||
{
|
||||
Adapter = adapter;
|
||||
Adapter.ItemTemplateId = itemTemplateId;
|
||||
}
|
||||
ChildViewRemoved += OnChildViewRemoved;
|
||||
}
|
||||
|
||||
protected MvxTableLayout(IntPtr javaReference, JniHandleOwnership transfer)
|
||||
: base(javaReference, transfer)
|
||||
{
|
||||
}
|
||||
|
||||
public void AdapterOnDataSetChanged(object sender, NotifyCollectionChangedEventArgs eventArgs)
|
||||
{
|
||||
this.UpdateDataSetFromChange(sender, eventArgs);
|
||||
}
|
||||
|
||||
private void OnChildViewRemoved(object sender, ChildViewRemovedEventArgs childViewRemovedEventArgs)
|
||||
{
|
||||
var boundChild = childViewRemovedEventArgs.Child as IMvxBindingContextOwner;
|
||||
boundChild?.ClearAllBindings();
|
||||
}
|
||||
|
||||
private IMvxAdapterWithChangedEvent _adapter;
|
||||
|
||||
public IMvxAdapterWithChangedEvent Adapter
|
||||
{
|
||||
get
|
||||
{
|
||||
return _adapter;
|
||||
}
|
||||
protected set
|
||||
{
|
||||
var existing = _adapter;
|
||||
if (existing == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (existing != null)
|
||||
{
|
||||
existing.DataSetChanged -= AdapterOnDataSetChanged;
|
||||
if (value != null)
|
||||
{
|
||||
value.ItemsSource = existing.ItemsSource;
|
||||
value.ItemTemplateId = existing.ItemTemplateId;
|
||||
}
|
||||
}
|
||||
|
||||
_adapter = value;
|
||||
|
||||
if (_adapter != null)
|
||||
{
|
||||
_adapter.DataSetChanged += AdapterOnDataSetChanged;
|
||||
}
|
||||
else
|
||||
{
|
||||
MvxBindingLog.Warning(
|
||||
"Setting Adapter to null is not recommended - you may lose ItemsSource binding when doing this");
|
||||
}
|
||||
|
||||
if (existing != null)
|
||||
existing.ItemsSource = null;
|
||||
}
|
||||
}
|
||||
|
||||
[MvxSetToNullAfterBinding]
|
||||
public IEnumerable ItemsSource
|
||||
{
|
||||
get { return Adapter.ItemsSource; }
|
||||
set { Adapter.ItemsSource = value; }
|
||||
}
|
||||
|
||||
public int ItemTemplateId
|
||||
{
|
||||
get { return Adapter.ItemTemplateId; }
|
||||
set { Adapter.ItemTemplateId = value; }
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (_adapter != null)
|
||||
_adapter.DataSetChanged -= AdapterOnDataSetChanged;
|
||||
|
||||
ChildViewRemoved -= OnChildViewRemoved;
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче