Skip to content

Commit

Permalink
Merge pull request #44 from muak/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
muak authored Apr 12, 2019
2 parents fbeffa3 + f10531c commit e1bc152
Show file tree
Hide file tree
Showing 32 changed files with 574 additions and 333 deletions.
11 changes: 7 additions & 4 deletions AiForms.Effects.Droid/AddCommandPlatformEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public class AddCommandPlatformEffect : FeedbackPlatformEffect

private GestureDetector _gestureDetector;

protected override void OnAttached()
protected override void OnAttachedOverride()
{
base.OnAttached();
base.OnAttachedOverride();

_view = Control ?? Container;

Expand All @@ -66,7 +66,7 @@ protected override void OnAttached()
_view.Touch += _view_Touch;
}

protected override void OnDetached()
protected override void OnDetachedOverride()
{
if (!IsDisposed) {
_view.Touch -= _view_Touch;
Expand All @@ -90,13 +90,16 @@ protected override void OnDetached()

_view = null;

base.OnDetached();
base.OnDetachedOverride();
}

protected override void OnElementPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(e);

if (!IsSupportedByApi)
return;

if (IsDisposed) {
return;
}
Expand Down
11 changes: 5 additions & 6 deletions AiForms.Effects.Droid/AddDatePickerPlatformEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,16 @@ public class AddDatePickerPlatformEffect : AiEffectBase
DatePickerDialog _dialog;
ICommand _command;

protected override void OnAttached()
protected override void OnAttachedOverride()
{
base.OnAttached();

_view = Control ?? Container;

_view.Touch += _view_Touch;

UpdateCommand();
}

protected override void OnDetached()
protected override void OnDetachedOverride()
{
var renderer = Container as IVisualElementRenderer;
if (!IsDisposed) {
Expand All @@ -41,14 +39,15 @@ protected override void OnDetached()
_view = null;
_command = null;
System.Diagnostics.Debug.WriteLine($"{this.GetType().FullName} Detached completely");

base.OnDetached();
}

protected override void OnElementPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(e);

if (!IsSupportedByApi)
return;

if (IsDisposed) {
return;
}
Expand Down
11 changes: 5 additions & 6 deletions AiForms.Effects.Droid/AddNumberPickerPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ public class AddNumberPickerPlatform : AiEffectBase
private int _max;
private int _number;

protected override void OnAttached()
protected override void OnAttachedOverride()
{
base.OnAttached();

_view = Control ?? Container;

_view.Touch += _view_Touch;
Expand All @@ -40,7 +38,7 @@ void _view_Touch(object sender, Android.Views.View.TouchEventArgs e)
}
}

protected override void OnDetached()
protected override void OnDetachedOverride()
{
if (!IsDisposed) {
_view.Touch -= _view_Touch;
Expand All @@ -53,14 +51,15 @@ protected override void OnDetached()
_view = null;
_command = null;
System.Diagnostics.Debug.WriteLine($"{this.GetType().FullName} Detached completely");

base.OnDetached();
}

protected override void OnElementPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(e);

if (!IsSupportedByApi)
return;

if (IsDisposed) {
return;
}
Expand Down
11 changes: 5 additions & 6 deletions AiForms.Effects.Droid/AddTextPlatformEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ public class AddTextPlatformEffect : AiEffectBase
private ViewGroup _container;
private FastRendererOnLayoutChangeListener _fastListener;

protected override void OnAttached()
protected override void OnAttachedOverride()
{
base.OnAttached();

_container = Container;

_textView = new TextView(_context);
Expand Down Expand Up @@ -50,7 +48,7 @@ protected override void OnAttached()
UpdateLayout(_textView, Element, _container);
}

protected override void OnDetached()
protected override void OnDetachedOverride()
{
System.Diagnostics.Debug.WriteLine(Element.GetType().FullName);

Expand All @@ -74,14 +72,15 @@ protected override void OnDetached()
_fastListener?.Dispose();
_fastListener = null;
System.Diagnostics.Debug.WriteLine($"{this.GetType().FullName} Detached completely");

base.OnDetached();
}

protected override void OnElementPropertyChanged(System.ComponentModel.PropertyChangedEventArgs args)
{
base.OnElementPropertyChanged(args);

if (!IsSupportedByApi)
return;

if (IsDisposed) {
return;
}
Expand Down
11 changes: 5 additions & 6 deletions AiForms.Effects.Droid/AddTimePickerPlatformEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ public class AddTimePickerPlatformEffect : AiEffectBase
ICommand _command;
string _title;

protected override void OnAttached()
protected override void OnAttachedOverride()
{
base.OnAttached();

_view = Control ?? Container;

_view.Touch += _view_Touch;
Expand All @@ -30,7 +28,7 @@ protected override void OnAttached()
UpdateCommand();
}

protected override void OnDetached()
protected override void OnDetachedOverride()
{
if (!IsDisposed) {
_view.Touch -= _view_Touch;
Expand All @@ -43,14 +41,15 @@ protected override void OnDetached()
_view = null;
_command = null;
System.Diagnostics.Debug.WriteLine($"{this.GetType().FullName} Detached completely");

base.OnDetached();
}

protected override void OnElementPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(e);

if (!IsSupportedByApi)
return;

if (IsDisposed) {
return;
}
Expand Down
16 changes: 2 additions & 14 deletions AiForms.Effects.Droid/AddTouchPlatformEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,10 @@ public class AddTouchPlatformEffect:AiEffectBase
TouchRecognizer _recognizer;
Context _context;

protected override void OnAttached()
protected override void OnAttachedOverride()
{
base.OnAttached();

_viewRef = new WeakReference<Android.Views.View>(Control ?? Container);


if (Control is Android.Widget.ListView || Control is Android.Widget.ScrollView)
{
// Except ListView and ScrollView because of Raising Exception.
Device.BeginInvokeOnMainThread(() => AddTouch.SetOn(Element, false));
return;
}

_recognizer = AddTouch.GetRecognizer(Element);

if(_viewRef.TryGetTarget(out var view)){
Expand Down Expand Up @@ -63,7 +53,7 @@ void _view_Touch(object sender, Android.Views.View.TouchEventArgs e)
}


protected override void OnDetached()
protected override void OnDetachedOverride()
{
if (!IsDisposed)
{
Expand All @@ -78,8 +68,6 @@ protected override void OnDetached()
_recognizer = null;
_viewRef = null;
System.Diagnostics.Debug.WriteLine($"{this.GetType().FullName} Detached completely");

base.OnDetached();
}

}
Expand Down
17 changes: 17 additions & 0 deletions AiForms.Effects.Droid/AiEffectBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ protected bool IsNullOrDisposed{
}
}

protected bool IsSupportedByApi => Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop;

protected override void OnAttached()
{
if (!IsSupportedByApi)
return;

var visual = Element as VisualElement;
var page = visual.Navigation.NavigationStack.LastOrDefault();
if(page == null)
Expand All @@ -55,6 +60,7 @@ protected override void OnAttached()
// In case the element in DataTemplate, NavigationProxycan't be got.
// Instead of it, the page dismissal is judged by whether the BindingContext is null.
Element.BindingContextChanged += BindingContextChanged;
OnAttachedOverride();
return;
}
}
Expand All @@ -65,16 +71,27 @@ protected override void OnAttached()
{
SetIsRegistered(page, true);
}

OnAttachedOverride();
}

protected virtual void OnAttachedOverride() { }

protected override void OnDetached()
{
if (!IsSupportedByApi)
return;

OnDetachedOverride();

System.Diagnostics.Debug.WriteLine($"Detached {GetType().Name} from {Element.GetType().FullName}");
Element.BindingContextChanged -= BindingContextChanged;

_renderer = null;
}

protected virtual void OnDetachedOverride() { }


// whether Element is FastRenderer.(Exept Button)
protected bool IsFastRenderer{
Expand Down
Loading

0 comments on commit e1bc152

Please sign in to comment.