You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Greg Brown <gk...@mac.com> on 2009/03/20 18:15:36 UTC

setInterval()/setTimeout()

As discussed, the setTimeout() and setInterval() methods in ApplicationContext have been replaced by the following new methods:

public static ScheduledCallback scheduleCallback(Runnable callback, long delay);

public static ScheduledCallback scheduleRecurringCallback(Runnable callback, long period);
public static ScheduledCallback scheduleRecurringCallback(Runnable callback, long delay, long period);

ScheduledCallback extends java.util.TimerTask. It wraps the actual callback and executes it on the UI thread. Returning it from these methods allows the caller to cancel the task.

The addition of the third method offers more flexibility than we previously had, since the old setInterval() method used a fixed delay of 0. This simplified the implementation of auto-scrolling in TerraScrollBarSkin and TerraSpinnerSkin.

Noel and Chris, thanks for the great suggestion to change this API.

Greg