public class Handler {
ctor public Handler();
- ctor public Handler(android.os.Handler.Callback);
- ctor public Handler(android.os.Looper);
- ctor public Handler(android.os.Looper, android.os.Handler.Callback);
+ ctor public Handler(@Nullable android.os.Handler.Callback);
+ ctor public Handler(@NonNull android.os.Looper);
+ ctor public Handler(@NonNull android.os.Looper, @Nullable android.os.Handler.Callback);
method @NonNull public static android.os.Handler createAsync(@NonNull android.os.Looper);
method @NonNull public static android.os.Handler createAsync(@NonNull android.os.Looper, @NonNull android.os.Handler.Callback);
- method public void dispatchMessage(android.os.Message);
- method public final void dump(android.util.Printer, String);
- method public final android.os.Looper getLooper();
- method public String getMessageName(android.os.Message);
- method public void handleMessage(android.os.Message);
- method public final boolean hasCallbacks(Runnable);
+ method public void dispatchMessage(@NonNull android.os.Message);
+ method public final void dump(@NonNull android.util.Printer, @NonNull String);
+ method @NonNull public final android.os.Looper getLooper();
+ method @NonNull public String getMessageName(@NonNull android.os.Message);
+ method public void handleMessage(@NonNull android.os.Message);
+ method public final boolean hasCallbacks(@NonNull Runnable);
method public final boolean hasMessages(int);
- method public final boolean hasMessages(int, Object);
- method public final android.os.Message obtainMessage();
- method public final android.os.Message obtainMessage(int);
- method public final android.os.Message obtainMessage(int, Object);
- method public final android.os.Message obtainMessage(int, int, int);
- method public final android.os.Message obtainMessage(int, int, int, Object);
- method public final boolean post(Runnable);
- method public final boolean postAtFrontOfQueue(Runnable);
- method public final boolean postAtTime(Runnable, long);
- method public final boolean postAtTime(Runnable, Object, long);
- method public final boolean postDelayed(Runnable, long);
- method public final boolean postDelayed(Runnable, Object, long);
- method public final void removeCallbacks(Runnable);
- method public final void removeCallbacks(Runnable, Object);
- method public final void removeCallbacksAndMessages(Object);
+ method public final boolean hasMessages(int, @Nullable Object);
+ method @NonNull public final android.os.Message obtainMessage();
+ method @NonNull public final android.os.Message obtainMessage(int);
+ method @NonNull public final android.os.Message obtainMessage(int, @Nullable Object);
+ method @NonNull public final android.os.Message obtainMessage(int, int, int);
+ method @NonNull public final android.os.Message obtainMessage(int, int, int, @Nullable Object);
+ method public final boolean post(@NonNull Runnable);
+ method public final boolean postAtFrontOfQueue(@NonNull Runnable);
+ method public final boolean postAtTime(@NonNull Runnable, long);
+ method public final boolean postAtTime(@NonNull Runnable, @Nullable Object, long);
+ method public final boolean postDelayed(@NonNull Runnable, long);
+ method public final boolean postDelayed(@NonNull Runnable, @Nullable Object, long);
+ method public final void removeCallbacks(@NonNull Runnable);
+ method public final void removeCallbacks(@NonNull Runnable, @Nullable Object);
+ method public final void removeCallbacksAndMessages(@Nullable Object);
method public final void removeMessages(int);
- method public final void removeMessages(int, Object);
+ method public final void removeMessages(int, @Nullable Object);
method public final boolean sendEmptyMessage(int);
method public final boolean sendEmptyMessageAtTime(int, long);
method public final boolean sendEmptyMessageDelayed(int, long);
- method public final boolean sendMessage(android.os.Message);
- method public final boolean sendMessageAtFrontOfQueue(android.os.Message);
- method public boolean sendMessageAtTime(android.os.Message, long);
- method public final boolean sendMessageDelayed(android.os.Message, long);
+ method public final boolean sendMessage(@NonNull android.os.Message);
+ method public final boolean sendMessageAtFrontOfQueue(@NonNull android.os.Message);
+ method public boolean sendMessageAtTime(@NonNull android.os.Message, long);
+ method public final boolean sendMessageDelayed(@NonNull android.os.Message, long);
}
public static interface Handler.Callback {
- method public boolean handleMessage(android.os.Message);
+ method public boolean handleMessage(@NonNull android.os.Message);
}
public class HandlerThread extends java.lang.Thread {
* @param msg A {@link android.os.Message Message} object
* @return True if no further handling is desired
*/
- public boolean handleMessage(Message msg);
+ boolean handleMessage(@NonNull Message msg);
}
/**
* Subclasses must implement this to receive messages.
*/
- public void handleMessage(Message msg) {
+ public void handleMessage(@NonNull Message msg) {
}
/**
* Handle system messages here.
*/
- public void dispatchMessage(Message msg) {
+ public void dispatchMessage(@NonNull Message msg) {
if (msg.callback != null) {
handleCallback(msg);
} else {
*
* @param callback The callback interface in which to handle messages, or null.
*/
- public Handler(Callback callback) {
+ public Handler(@Nullable Callback callback) {
this(callback, false);
}
*
* @param looper The looper, must not be null.
*/
- public Handler(Looper looper) {
+ public Handler(@NonNull Looper looper) {
this(looper, null, false);
}
* @param looper The looper, must not be null.
* @param callback The callback interface in which to handle messages, or null.
*/
- public Handler(Looper looper, Callback callback) {
+ public Handler(@NonNull Looper looper, @Nullable Callback callback) {
this(looper, callback, false);
}
*
* @hide
*/
- public Handler(Callback callback, boolean async) {
+ public Handler(@Nullable Callback callback, boolean async) {
if (FIND_POTENTIAL_LEAKS) {
final Class<? extends Handler> klass = getClass();
if ((klass.isAnonymousClass() || klass.isMemberClass() || klass.isLocalClass()) &&
*
* @hide
*/
- public Handler(Looper looper, Callback callback, boolean async) {
+ public Handler(@NonNull Looper looper, @Nullable Callback callback, boolean async) {
mLooper = looper;
mQueue = looper.mQueue;
mCallback = callback;
}
/** {@hide} */
- public String getTraceName(Message message) {
+ @NonNull
+ public String getTraceName(@NonNull Message message) {
final StringBuilder sb = new StringBuilder();
sb.append(getClass().getName()).append(": ");
if (message.callback != null) {
*
* @param message The message whose name is being queried
*/
- public String getMessageName(Message message) {
+ @NonNull
+ public String getMessageName(@NonNull Message message) {
if (message.callback != null) {
return message.callback.getClass().getName();
}
* creating and allocating new instances. The retrieved message has its handler set to this instance (Message.target == this).
* If you don't want that facility, just call Message.obtain() instead.
*/
+ @NonNull
public final Message obtainMessage()
{
return Message.obtain(this);
* @param what Value to assign to the returned Message.what field.
* @return A Message from the global message pool.
*/
+ @NonNull
public final Message obtainMessage(int what)
{
return Message.obtain(this, what);
* @param obj Value to assign to the returned Message.obj field.
* @return A Message from the global message pool.
*/
- public final Message obtainMessage(int what, Object obj)
- {
+ @NonNull
+ public final Message obtainMessage(int what, @Nullable Object obj) {
return Message.obtain(this, what, obj);
}
* @param arg2 Value to assign to the returned Message.arg2 field.
* @return A Message from the global message pool.
*/
+ @NonNull
public final Message obtainMessage(int what, int arg1, int arg2)
{
return Message.obtain(this, what, arg1, arg2);
* @param obj Value to assign to the returned Message.obj field.
* @return A Message from the global message pool.
*/
- public final Message obtainMessage(int what, int arg1, int arg2, Object obj)
- {
+ @NonNull
+ public final Message obtainMessage(int what, int arg1, int arg2, @Nullable Object obj) {
return Message.obtain(this, what, arg1, arg2, obj);
}
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
- public final boolean post(Runnable r)
- {
+ public final boolean post(@NonNull Runnable r) {
return sendMessageDelayed(getPostMessage(r), 0);
}
* the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
- public final boolean postAtTime(Runnable r, long uptimeMillis)
- {
+ public final boolean postAtTime(@NonNull Runnable r, long uptimeMillis) {
return sendMessageAtTime(getPostMessage(r), uptimeMillis);
}
*
* @see android.os.SystemClock#uptimeMillis
*/
- public final boolean postAtTime(Runnable r, Object token, long uptimeMillis)
- {
+ public final boolean postAtTime(
+ @NonNull Runnable r, @Nullable Object token, long uptimeMillis) {
return sendMessageAtTime(getPostMessage(r, token), uptimeMillis);
}
* if the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
- public final boolean postDelayed(Runnable r, long delayMillis)
- {
+ public final boolean postDelayed(@NonNull Runnable r, long delayMillis) {
return sendMessageDelayed(getPostMessage(r), delayMillis);
}
* if the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
- public final boolean postDelayed(Runnable r, Object token, long delayMillis)
- {
+ public final boolean postDelayed(
+ @NonNull Runnable r, @Nullable Object token, long delayMillis) {
return sendMessageDelayed(getPostMessage(r, token), delayMillis);
}
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
- public final boolean postAtFrontOfQueue(Runnable r)
- {
+ public final boolean postAtFrontOfQueue(@NonNull Runnable r) {
return sendMessageAtFrontOfQueue(getPostMessage(r));
}
* If we ever do make it part of the API, we might want to rename it to something
* less funny like runUnsafe().
*/
- public final boolean runWithScissors(final Runnable r, long timeout) {
+ public final boolean runWithScissors(@NonNull Runnable r, long timeout) {
if (r == null) {
throw new IllegalArgumentException("runnable must not be null");
}
/**
* Remove any pending posts of Runnable r that are in the message queue.
*/
- public final void removeCallbacks(Runnable r)
- {
+ public final void removeCallbacks(@NonNull Runnable r) {
mQueue.removeMessages(this, r, null);
}
* <var>token</var> that are in the message queue. If <var>token</var> is null,
* all callbacks will be removed.
*/
- public final void removeCallbacks(Runnable r, Object token)
- {
+ public final void removeCallbacks(@NonNull Runnable r, @Nullable Object token) {
mQueue.removeMessages(this, r, token);
}
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
- public final boolean sendMessage(Message msg)
- {
+ public final boolean sendMessage(@NonNull Message msg) {
return sendMessageDelayed(msg, 0);
}
* the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
- public final boolean sendMessageDelayed(Message msg, long delayMillis)
- {
+ public final boolean sendMessageDelayed(@NonNull Message msg, long delayMillis) {
if (delayMillis < 0) {
delayMillis = 0;
}
* the looper is quit before the delivery time of the message
* occurs then the message will be dropped.
*/
- public boolean sendMessageAtTime(Message msg, long uptimeMillis) {
+ public boolean sendMessageAtTime(@NonNull Message msg, long uptimeMillis) {
MessageQueue queue = mQueue;
if (queue == null) {
RuntimeException e = new RuntimeException(
* message queue. Returns false on failure, usually because the
* looper processing the message queue is exiting.
*/
- public final boolean sendMessageAtFrontOfQueue(Message msg) {
+ public final boolean sendMessageAtFrontOfQueue(@NonNull Message msg) {
MessageQueue queue = mQueue;
if (queue == null) {
RuntimeException e = new RuntimeException(
* looper processing the message queue is exiting.
* @hide
*/
- public final boolean executeOrSendMessage(Message msg) {
+ public final boolean executeOrSendMessage(@NonNull Message msg) {
if (mLooper == Looper.myLooper()) {
dispatchMessage(msg);
return true;
return sendMessage(msg);
}
- private boolean enqueueMessage(MessageQueue queue, Message msg, long uptimeMillis) {
+ private boolean enqueueMessage(@NonNull MessageQueue queue, @NonNull Message msg,
+ long uptimeMillis) {
msg.target = this;
msg.workSourceUid = ThreadLocalWorkSource.getUid();
* 'object' that are in the message queue. If <var>object</var> is null,
* all messages will be removed.
*/
- public final void removeMessages(int what, Object object) {
+ public final void removeMessages(int what, @Nullable Object object) {
mQueue.removeMessages(this, what, object);
}
* <var>obj</var> is <var>token</var>. If <var>token</var> is null,
* all callbacks and messages will be removed.
*/
- public final void removeCallbacksAndMessages(Object token) {
+ public final void removeCallbacksAndMessages(@Nullable Object token) {
mQueue.removeCallbacksAndMessages(this, token);
}
* Check if there are any pending posts of messages with code 'what' and
* whose obj is 'object' in the message queue.
*/
- public final boolean hasMessages(int what, Object object) {
+ public final boolean hasMessages(int what, @Nullable Object object) {
return mQueue.hasMessages(this, what, object);
}
* Check if there are any pending posts of messages with callback r in
* the message queue.
*/
- public final boolean hasCallbacks(Runnable r) {
+ public final boolean hasCallbacks(@NonNull Runnable r) {
return mQueue.hasMessages(this, r, null);
}
// if we can get rid of this method, the handler need not remember its loop
// we could instead export a getMessageQueue() method...
+ @NonNull
public final Looper getLooper() {
return mLooper;
}
- public final void dump(Printer pw, String prefix) {
+ public final void dump(@NonNull Printer pw, @NonNull String prefix) {
pw.println(prefix + this + " @ " + SystemClock.uptimeMillis());
if (mLooper == null) {
pw.println(prefix + "looper uninitialized");
/**
* @hide
*/
- public final void dumpMine(Printer pw, String prefix) {
+ public final void dumpMine(@NonNull Printer pw, @NonNull String prefix) {
pw.println(prefix + this + " @ " + SystemClock.uptimeMillis());
if (mLooper == null) {
pw.println(prefix + "looper uninitialized");