diff options
Diffstat (limited to 'Xamarin.Forms.Platform.Android/AndroidTicker.cs')
-rw-r--r-- | Xamarin.Forms.Platform.Android/AndroidTicker.cs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Android/AndroidTicker.cs b/Xamarin.Forms.Platform.Android/AndroidTicker.cs new file mode 100644 index 00000000..2f5104e3 --- /dev/null +++ b/Xamarin.Forms.Platform.Android/AndroidTicker.cs @@ -0,0 +1,43 @@ +using System; +using Android.Animation; + +namespace Xamarin.Forms.Platform.Android +{ + internal class AndroidTicker : Ticker, IDisposable + { + ValueAnimator _val; + + public AndroidTicker() + { + _val = new ValueAnimator(); + _val.SetIntValues(0, 100); // avoid crash + _val.RepeatCount = ValueAnimator.Infinite; + _val.Update += OnValOnUpdate; + } + + public void Dispose() + { + if (_val != null) + { + _val.Update -= OnValOnUpdate; + _val.Dispose(); + } + _val = null; + } + + protected override void DisableTimer() + { + _val?.Cancel(); + } + + protected override void EnableTimer() + { + _val?.Start(); + } + + void OnValOnUpdate(object sender, ValueAnimator.AnimatorUpdateEventArgs e) + { + SendSignals(); + } + } +}
\ No newline at end of file |