Back to project page lifx-wear-test.
The source code is released under:
Apache License
If you think the Android project lifx-wear-test listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
// // LFXTimerUtils.java // LIFX// w w w . ja v a 2 s . c o m // // Created by Jarrod Boyes on 24/03/14. // Copyright (c) 2014 LIFX Labs. All rights reserved. // package lifx.java.android.util; import java.util.Timer; import java.util.TimerTask; import android.os.Handler; import android.os.Looper; public class LFXTimerUtils { private static class MainThreadRunnableTimerTask extends TimerTask { private Runnable task; public MainThreadRunnableTimerTask( Runnable task) { this.task = task; } @Override public void run() { Handler handler = new Handler( Looper.getMainLooper()); handler.post( task); } } public static Timer getTimerTaskWithPeriod( Runnable task, long period, boolean immediate) { Timer timer = new Timer(); long delay = 0L; if( !immediate) { delay = period; } timer.scheduleAtFixedRate( new MainThreadRunnableTimerTask( task), delay, period); return timer; } public static void scheduleDelayedTask( Runnable task, long delay) { Handler handler = new Handler( Looper.getMainLooper()); handler.postDelayed( task, delay); } }