/** * Schedules a task for one-time execution. The task will be executed on * the UI thread. * * @param callback * The task to execute. * * @param delay * The length of time to wait before executing the task (in milliseconds). */ public static ScheduledCallback scheduleCallback(Runnable callback, long delay) { ScheduledCallback scheduledCallback = new ScheduledCallback(callback); // TODO This is a workaround for a potential OS X bug; revisit try { try { timer.schedule(scheduledCallback, delay); } catch (IllegalStateException exception) { createTimer(); timer.schedule(scheduledCallback, delay); } } catch (Throwable throwable) { System.err.println("Unable to schedule callback: " + throwable); } return scheduledCallback; }
/** * Schedules a task for one-time execution. The task will be executed on * the UI thread. * * @param callback * The task to execute. * * @param delay * The length of time to wait before executing the task. */ public static ScheduledCallback scheduleCallback(Runnable callback, long delay) { ScheduledCallback scheduledCallback = new ScheduledCallback(callback); // TODO This is a workaround for a potential OS X bug; revisit try { try { timer.schedule(scheduledCallback, delay); } catch (IllegalStateException exception) { createTimer(); timer.schedule(scheduledCallback, delay); } } catch (Throwable throwable) { System.err.println("Unable to schedule callback: " + throwable); } return scheduledCallback; }
/** * Schedules a task for repeated execution. The task will be executed on the * UI thread. * * @param callback * The task to execute. * * @param delay * The length of time to wait before the first execution of the task (milliseconds). * * @param period * The interval at which the task will be repeated (also in milliseconds). */ public static ScheduledCallback scheduleRecurringCallback(Runnable callback, long delay, long period) { ScheduledCallback scheduledCallback = new ScheduledCallback(callback); // TODO This is a workaround for a potential OS X bug; revisit try { try { timer.schedule(scheduledCallback, delay, period); } catch (IllegalStateException exception) { createTimer(); timer.schedule(scheduledCallback, delay, period); } } catch (Throwable throwable) { System.err.println("Unable to schedule callback: " + throwable); } return scheduledCallback; }
/** * Schedules a task for repeated execution. The task will be executed on the * UI thread. * * @param callback * The task to execute. * * @param delay * The length of time to wait before the first execution of the task * * @param period * The interval at which the task will be repeated. */ public static ScheduledCallback scheduleRecurringCallback(Runnable callback, long delay, long period) { ScheduledCallback scheduledCallback = new ScheduledCallback(callback); // TODO This is a workaround for a potential OS X bug; revisit try { try { timer.schedule(scheduledCallback, delay, period); } catch (IllegalStateException exception) { createTimer(); timer.schedule(scheduledCallback, delay, period); } } catch (Throwable throwable) { System.err.println("Unable to schedule callback: " + throwable); } return scheduledCallback; }