Skip to content

Commit

Permalink
Merge pull request #127 from muak/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
muak authored Sep 15, 2020
2 parents 072fb62 + 6351c30 commit ffb1228
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 5 deletions.
14 changes: 13 additions & 1 deletion SettingsView.Droid/Cells/EntryCellRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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) {
Expand Down
16 changes: 15 additions & 1 deletion SettingsView.Droid/ModelProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -25,12 +27,14 @@ public class ModelProxy:List<RowInfo>,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;
Expand All @@ -45,6 +49,7 @@ public void Dispose()
_model = null;
_root = null;
_adapter = null;
_recyclerView = null;
this?.Clear();
ViewTypes?.Clear();
ViewTypes = null;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion SettingsView.Droid/SettingsView.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SettingsView\SettingsView.csproj">
<Project>{8FFB1EF3-FAF3-478C-B9F1-4D02E599C3C6}</Project>
<Project>{FD2D256D-7898-494A-9FDC-C04482BF8C0E}</Project>
<Name>SettingsView</Name>
</ProjectReference>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion SettingsView.Droid/SettingsViewRecyclerAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions SettingsView.Droid/SettingsViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ protected override void OnElementChanged(ElementChangedEventArgs<SettingsView> 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);

Expand Down
2 changes: 1 addition & 1 deletion SettingsView.iOS/SettingsView.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SettingsView\SettingsView.csproj">
<Project>{8FFB1EF3-FAF3-478C-B9F1-4D02E599C3C6}</Project>
<Project>{FD2D256D-7898-494A-9FDC-C04482BF8C0E}</Project>
<Name>SettingsView</Name>
</ProjectReference>
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions nuget/AzurePipelines.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ffb1228

Please sign in to comment.