Class OneShotPreDrawListener

java.lang.Object
icyllis.modernui.view.OneShotPreDrawListener
All Implemented Interfaces:
View.OnAttachStateChangeListener, ViewTreeObserver.OnPreDrawListener

public final class OneShotPreDrawListener extends Object implements ViewTreeObserver.OnPreDrawListener, View.OnAttachStateChangeListener
An OnPreDrawListener that will remove itself after one OnPreDraw call. Typical usage is:

     OneShotPreDrawListener.add(view, () -> view.doSomething())
 

The onPreDraw always returns true.

The listener will also remove itself from the ViewTreeObserver when the view is detached from the view hierarchy. In that case, the Runnable will never be executed.