diff --git a/SettingsView.Droid/Cells/EntryCellRenderer.cs b/SettingsView.Droid/Cells/EntryCellRenderer.cs index 60d3808..4cb21c0 100644 --- a/SettingsView.Droid/Cells/EntryCellRenderer.cs +++ b/SettingsView.Droid/Cells/EntryCellRenderer.cs @@ -370,7 +370,7 @@ void IOnFocusChangeListener.OnFocusChange(Android.Views.View v, bool hasFocus) void EntryCell_Focused(object sender, EventArgs e) { - _EditText.RequestFocus(); + _EditText.RequestFocus(); ShowKeyboard(_EditText); } @@ -386,6 +386,18 @@ public AiEditText(Context context) : base(context) { } + protected override void OnFocusChanged(bool gainFocus, [GeneratedEnum] FocusSearchDirection direction, Rect previouslyFocusedRect) + { + base.OnFocusChanged(gainFocus, direction, previouslyFocusedRect); + if(gainFocus) + { + Post(new Runnable(() => + { + SetSelection(Text.Length); + })); + } + } + public override bool OnKeyPreIme(Keycode keyCode, KeyEvent e) { if (keyCode == Keycode.Back && e.Action == KeyEventActions.Up) { diff --git a/SettingsView.Droid/ModelProxy.cs b/SettingsView.Droid/ModelProxy.cs index b91a919..36337cb 100644 --- a/SettingsView.Droid/ModelProxy.cs +++ b/SettingsView.Droid/ModelProxy.cs @@ -5,6 +5,8 @@ using System.Collections.ObjectModel; using Xamarin.Forms.Internals; using System.Collections.Specialized; +using Android.Support.V7.Widget; +using Android.OS; namespace AiForms.Renderers.Droid { @@ -25,12 +27,14 @@ public class ModelProxy:List,IDisposable SettingsModel _model; SettingsRoot _root; SettingsViewRecyclerAdapter _adapter; + RecyclerView _recyclerView; - public ModelProxy(SettingsView settingsView,SettingsViewRecyclerAdapter adapter) + public ModelProxy(SettingsView settingsView,SettingsViewRecyclerAdapter adapter,RecyclerView recyclerView) { _model = settingsView.Model; _root = settingsView.Root; _adapter = adapter; + _recyclerView = recyclerView; _root.SectionCollectionChanged += OnRootSectionCollectionChanged; _root.CollectionChanged += OnRootCollectionChanged; @@ -45,6 +49,7 @@ public void Dispose() _model = null; _root = null; _adapter = null; + _recyclerView = null; this?.Clear(); ViewTypes?.Clear(); ViewTypes = null; @@ -203,7 +208,16 @@ void ReplaceCell(object sender, NotifyCollectionChangedEventArgs e) ViewType = (ViewType)ViewTypes[repCell.GetType()], }; + // Stop animation. + (_recyclerView.GetItemAnimator() as DefaultItemAnimator).SupportsChangeAnimations = false; + _adapter.NotifyItemRangeChanged(startIndex, 1); + + new Handler().PostDelayed(() => + { + // Restart animation. + (_recyclerView.GetItemAnimator() as DefaultItemAnimator).SupportsChangeAnimations = true; + },100); } int RowIndexFromChildCollection(object sender,int index) diff --git a/SettingsView.Droid/SettingsView.Droid.csproj b/SettingsView.Droid/SettingsView.Droid.csproj index f9ccfd7..5eb760f 100644 --- a/SettingsView.Droid/SettingsView.Droid.csproj +++ b/SettingsView.Droid/SettingsView.Droid.csproj @@ -240,7 +240,7 @@ - {8FFB1EF3-FAF3-478C-B9F1-4D02E599C3C6} + {FD2D256D-7898-494A-9FDC-C04482BF8C0E} SettingsView diff --git a/SettingsView.Droid/SettingsViewRecyclerAdapter.cs b/SettingsView.Droid/SettingsViewRecyclerAdapter.cs index 2b82aa4..8392c62 100644 --- a/SettingsView.Droid/SettingsViewRecyclerAdapter.cs +++ b/SettingsView.Droid/SettingsViewRecyclerAdapter.cs @@ -42,7 +42,7 @@ public SettingsViewRecyclerAdapter(Context context, SettingsView settingsView,Re _context = context; _settingsView = settingsView; _recyclerView = recyclerView; - _proxy = new ModelProxy(settingsView, this); + _proxy = new ModelProxy(settingsView, this,recyclerView); _settingsView.ModelChanged += _settingsView_ModelChanged; _settingsView.SectionPropertyChanged += OnSectionPropertyChanged; diff --git a/SettingsView.Droid/SettingsViewRenderer.cs b/SettingsView.Droid/SettingsViewRenderer.cs index 8f6a490..e12c6ba 100644 --- a/SettingsView.Droid/SettingsViewRenderer.cs +++ b/SettingsView.Droid/SettingsViewRenderer.cs @@ -48,6 +48,10 @@ protected override void OnElementChanged(ElementChangedEventArgs e if (e.NewElement != null) { var recyclerView = new RecyclerView(Context); + + // When replaced, No animation. + //(recyclerView.GetItemAnimator() as DefaultItemAnimator).SupportsChangeAnimations = false; + _layoutManager = new SettingsViewLayoutManager(Context,e.NewElement); recyclerView.SetLayoutManager(_layoutManager); diff --git a/SettingsView.iOS/SettingsView.iOS.csproj b/SettingsView.iOS/SettingsView.iOS.csproj index 9df571c..2d9a1f0 100644 --- a/SettingsView.iOS/SettingsView.iOS.csproj +++ b/SettingsView.iOS/SettingsView.iOS.csproj @@ -107,7 +107,7 @@ - {8FFB1EF3-FAF3-478C-B9F1-4D02E599C3C6} + {FD2D256D-7898-494A-9FDC-C04482BF8C0E} SettingsView diff --git a/nuget/AzurePipelines.nuspec b/nuget/AzurePipelines.nuspec index 97264c3..4cdb457 100644 --- a/nuget/AzurePipelines.nuspec +++ b/nuget/AzurePipelines.nuspec @@ -31,6 +31,7 @@ There are various cells such as (LabelCell,ButtonCell,CommandCell,SwitchCell,Che ## Bug fixes +* * [iOS] Crash ScrollToTop ScrollToBottom when no elements. * [Android] Fix reordering bug. * [Android] Fix Sequence contains no elements. #113 #86