summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Forms.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Forms.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Forms.cs53
1 files changed, 8 insertions, 45 deletions
diff --git a/Xamarin.Forms.Platform.Android/Forms.cs b/Xamarin.Forms.Platform.Android/Forms.cs
index 3d2a735c..1ecf76d3 100644
--- a/Xamarin.Forms.Platform.Android/Forms.cs
+++ b/Xamarin.Forms.Platform.Android/Forms.cs
@@ -410,22 +410,15 @@ namespace Xamarin.Forms
public void StartTimer(TimeSpan interval, Func<bool> callback)
{
- Timer timer = null;
- bool invoking = false;
- TimerCallback onTimeout = o =>
+ var handler = new Handler(Looper.MainLooper);
+ handler.PostDelayed(() =>
{
- if (!invoking)
- {
- invoking = true;
- BeginInvokeOnMainThread(() =>
- {
- if (!callback())
- timer.Dispose();
- invoking = false;
- });
- }
- };
- timer = new Timer(onTimeout, null, interval, interval);
+ if (callback())
+ StartTimer(interval, callback);
+
+ handler.Dispose();
+ handler = null;
+ }, (long)interval.TotalMilliseconds);
}
double ConvertTextAppearanceToSize(int themeDefault, int deviceDefault, double defaultValue)
@@ -472,36 +465,6 @@ namespace Xamarin.Forms
return false;
}
- public class _Timer : ITimer
- {
- readonly Timer _timer;
-
- public _Timer(Timer timer)
- {
- _timer = timer;
- }
-
- public void Change(int dueTime, int period)
- {
- _timer.Change(dueTime, period);
- }
-
- public void Change(long dueTime, long period)
- {
- _timer.Change(dueTime, period);
- }
-
- public void Change(TimeSpan dueTime, TimeSpan period)
- {
- _timer.Change(dueTime, period);
- }
-
- public void Change(uint dueTime, uint period)
- {
- _timer.Change(dueTime, period);
- }
- }
-
public class _IsolatedStorageFile : IIsolatedStorageFile
{
readonly IsolatedStorageFile _isolatedStorageFile;