Skip to content

Instantly share code, notes, and snippets.

@StephenVinouze
Created May 6, 2020 15:09
Show Gist options
  • Save StephenVinouze/63ac5307d5f0ea4c9aa47aa76c7881cc to your computer and use it in GitHub Desktop.
Save StephenVinouze/63ac5307d5f0ea4c9aa47aa76c7881cc to your computer and use it in GitHub Desktop.
Post delayed implementation in View.java
/**
* <p>Causes the Runnable to be added to the message queue, to be run
* after the specified amount of time elapses.
* The runnable will be run on the user interface thread.</p>
*
* @param action The Runnable that will be executed.
* @param delayMillis The delay (in milliseconds) until the Runnable
* will be executed.
*
* @return true if the Runnable was successfully placed in to the
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting. Note that a
* result of true does not mean the Runnable will be processed --
* if the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*
* @see #post
* @see #removeCallbacks
*/
public boolean postDelayed(Runnable action, long delayMillis) {
final AttachInfo attachInfo = mAttachInfo;
if (attachInfo != null) {
return attachInfo.mHandler.postDelayed(action, delayMillis);
}
// Postpone the runnable until we know on which thread it needs to run.
// Assume that the runnable will be successfully placed after attach.
getRunQueue().postDelayed(action, delayMillis);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment