Skip to content

Commit e1bc152

Browse files
authored
Merge pull request #44 from muak/development
Development
2 parents fbeffa3 + f10531c commit e1bc152

32 files changed

+574
-333
lines changed

AiForms.Effects.Droid/AddCommandPlatformEffect.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public class AddCommandPlatformEffect : FeedbackPlatformEffect
3939

4040
private GestureDetector _gestureDetector;
4141

42-
protected override void OnAttached()
42+
protected override void OnAttachedOverride()
4343
{
44-
base.OnAttached();
44+
base.OnAttachedOverride();
4545

4646
_view = Control ?? Container;
4747

@@ -66,7 +66,7 @@ protected override void OnAttached()
6666
_view.Touch += _view_Touch;
6767
}
6868

69-
protected override void OnDetached()
69+
protected override void OnDetachedOverride()
7070
{
7171
if (!IsDisposed) {
7272
_view.Touch -= _view_Touch;
@@ -90,13 +90,16 @@ protected override void OnDetached()
9090

9191
_view = null;
9292

93-
base.OnDetached();
93+
base.OnDetachedOverride();
9494
}
9595

9696
protected override void OnElementPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e)
9797
{
9898
base.OnElementPropertyChanged(e);
9999

100+
if (!IsSupportedByApi)
101+
return;
102+
100103
if (IsDisposed) {
101104
return;
102105
}

AiForms.Effects.Droid/AddDatePickerPlatformEffect.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,16 @@ public class AddDatePickerPlatformEffect : AiEffectBase
1616
DatePickerDialog _dialog;
1717
ICommand _command;
1818

19-
protected override void OnAttached()
19+
protected override void OnAttachedOverride()
2020
{
21-
base.OnAttached();
22-
2321
_view = Control ?? Container;
2422

2523
_view.Touch += _view_Touch;
2624

2725
UpdateCommand();
2826
}
2927

30-
protected override void OnDetached()
28+
protected override void OnDetachedOverride()
3129
{
3230
var renderer = Container as IVisualElementRenderer;
3331
if (!IsDisposed) {
@@ -41,14 +39,15 @@ protected override void OnDetached()
4139
_view = null;
4240
_command = null;
4341
System.Diagnostics.Debug.WriteLine($"{this.GetType().FullName} Detached completely");
44-
45-
base.OnDetached();
4642
}
4743

4844
protected override void OnElementPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e)
4945
{
5046
base.OnElementPropertyChanged(e);
5147

48+
if (!IsSupportedByApi)
49+
return;
50+
5251
if (IsDisposed) {
5352
return;
5453
}

AiForms.Effects.Droid/AddNumberPickerPlatform.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ public class AddNumberPickerPlatform : AiEffectBase
2121
private int _max;
2222
private int _number;
2323

24-
protected override void OnAttached()
24+
protected override void OnAttachedOverride()
2525
{
26-
base.OnAttached();
27-
2826
_view = Control ?? Container;
2927

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

43-
protected override void OnDetached()
41+
protected override void OnDetachedOverride()
4442
{
4543
if (!IsDisposed) {
4644
_view.Touch -= _view_Touch;
@@ -53,14 +51,15 @@ protected override void OnDetached()
5351
_view = null;
5452
_command = null;
5553
System.Diagnostics.Debug.WriteLine($"{this.GetType().FullName} Detached completely");
56-
57-
base.OnDetached();
5854
}
5955

6056
protected override void OnElementPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e)
6157
{
6258
base.OnElementPropertyChanged(e);
6359

60+
if (!IsSupportedByApi)
61+
return;
62+
6463
if (IsDisposed) {
6564
return;
6665
}

AiForms.Effects.Droid/AddTextPlatformEffect.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ public class AddTextPlatformEffect : AiEffectBase
1919
private ViewGroup _container;
2020
private FastRendererOnLayoutChangeListener _fastListener;
2121

22-
protected override void OnAttached()
22+
protected override void OnAttachedOverride()
2323
{
24-
base.OnAttached();
25-
2624
_container = Container;
2725

2826
_textView = new TextView(_context);
@@ -50,7 +48,7 @@ protected override void OnAttached()
5048
UpdateLayout(_textView, Element, _container);
5149
}
5250

53-
protected override void OnDetached()
51+
protected override void OnDetachedOverride()
5452
{
5553
System.Diagnostics.Debug.WriteLine(Element.GetType().FullName);
5654

@@ -74,14 +72,15 @@ protected override void OnDetached()
7472
_fastListener?.Dispose();
7573
_fastListener = null;
7674
System.Diagnostics.Debug.WriteLine($"{this.GetType().FullName} Detached completely");
77-
78-
base.OnDetached();
7975
}
8076

8177
protected override void OnElementPropertyChanged(System.ComponentModel.PropertyChangedEventArgs args)
8278
{
8379
base.OnElementPropertyChanged(args);
8480

81+
if (!IsSupportedByApi)
82+
return;
83+
8584
if (IsDisposed) {
8685
return;
8786
}

AiForms.Effects.Droid/AddTimePickerPlatformEffect.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ public class AddTimePickerPlatformEffect : AiEffectBase
1818
ICommand _command;
1919
string _title;
2020

21-
protected override void OnAttached()
21+
protected override void OnAttachedOverride()
2222
{
23-
base.OnAttached();
24-
2523
_view = Control ?? Container;
2624

2725
_view.Touch += _view_Touch;
@@ -30,7 +28,7 @@ protected override void OnAttached()
3028
UpdateCommand();
3129
}
3230

33-
protected override void OnDetached()
31+
protected override void OnDetachedOverride()
3432
{
3533
if (!IsDisposed) {
3634
_view.Touch -= _view_Touch;
@@ -43,14 +41,15 @@ protected override void OnDetached()
4341
_view = null;
4442
_command = null;
4543
System.Diagnostics.Debug.WriteLine($"{this.GetType().FullName} Detached completely");
46-
47-
base.OnDetached();
4844
}
4945

5046
protected override void OnElementPropertyChanged(System.ComponentModel.PropertyChangedEventArgs e)
5147
{
5248
base.OnElementPropertyChanged(e);
5349

50+
if (!IsSupportedByApi)
51+
return;
52+
5453
if (IsDisposed) {
5554
return;
5655
}

AiForms.Effects.Droid/AddTouchPlatformEffect.cs

+2-14
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,10 @@ public class AddTouchPlatformEffect:AiEffectBase
1616
TouchRecognizer _recognizer;
1717
Context _context;
1818

19-
protected override void OnAttached()
19+
protected override void OnAttachedOverride()
2020
{
21-
base.OnAttached();
22-
2321
_viewRef = new WeakReference<Android.Views.View>(Control ?? Container);
2422

25-
26-
if (Control is Android.Widget.ListView || Control is Android.Widget.ScrollView)
27-
{
28-
// Except ListView and ScrollView because of Raising Exception.
29-
Device.BeginInvokeOnMainThread(() => AddTouch.SetOn(Element, false));
30-
return;
31-
}
32-
3323
_recognizer = AddTouch.GetRecognizer(Element);
3424

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

6555

66-
protected override void OnDetached()
56+
protected override void OnDetachedOverride()
6757
{
6858
if (!IsDisposed)
6959
{
@@ -78,8 +68,6 @@ protected override void OnDetached()
7868
_recognizer = null;
7969
_viewRef = null;
8070
System.Diagnostics.Debug.WriteLine($"{this.GetType().FullName} Detached completely");
81-
82-
base.OnDetached();
8371
}
8472

8573
}

AiForms.Effects.Droid/AiEffectBase.cs

+17
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@ protected bool IsNullOrDisposed{
4444
}
4545
}
4646

47+
protected bool IsSupportedByApi => Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop;
48+
4749
protected override void OnAttached()
4850
{
51+
if (!IsSupportedByApi)
52+
return;
53+
4954
var visual = Element as VisualElement;
5055
var page = visual.Navigation.NavigationStack.LastOrDefault();
5156
if(page == null)
@@ -55,6 +60,7 @@ protected override void OnAttached()
5560
// In case the element in DataTemplate, NavigationProxycan't be got.
5661
// Instead of it, the page dismissal is judged by whether the BindingContext is null.
5762
Element.BindingContextChanged += BindingContextChanged;
63+
OnAttachedOverride();
5864
return;
5965
}
6066
}
@@ -65,16 +71,27 @@ protected override void OnAttached()
6571
{
6672
SetIsRegistered(page, true);
6773
}
74+
75+
OnAttachedOverride();
6876
}
6977

78+
protected virtual void OnAttachedOverride() { }
79+
7080
protected override void OnDetached()
7181
{
82+
if (!IsSupportedByApi)
83+
return;
84+
85+
OnDetachedOverride();
86+
7287
System.Diagnostics.Debug.WriteLine($"Detached {GetType().Name} from {Element.GetType().FullName}");
7388
Element.BindingContextChanged -= BindingContextChanged;
7489

7590
_renderer = null;
7691
}
7792

93+
protected virtual void OnDetachedOverride() { }
94+
7895

7996
// whether Element is FastRenderer.(Exept Button)
8097
protected bool IsFastRenderer{

0 commit comments

Comments
 (0)