/ *
* Send a message to the thread's message queue by a handler class,
* Each object has a Handler Looper MessageQueue objects and objects
* /
public Handler (the Callback the callback, the async Boolean) {
IF (FIND_POTENTIAL_LEAKS) {
Final Class <? The extends Handler> Klass = getClass ();
IF ((klass.isAnonymousClass () klass.isMemberClass || () || klass.isLocalClass ()) &&
(klass.getModifiers () & Modifier.STATIC) == 0) {
the Log. W (the TAG, "Handler class of The following static or leaks Should BE Might Occur:" +
klass.getCanonicalName ());
}
}
// Get the object Looper
mLooper Looper.myLooper = ();
IF (mLooper == null) {. ..}
// Get message Queuing
mQueue = mLooper.mQueue;
mCallback = callback;
mAsynchronous = async;
}
/ *
* SendMessage various methods, eventually both call a method sendMessageAtTime ()
* /
public Boolean sendMessageAtTime (the Message MSG, Long uptimeMillis) {
the MessageQueue Queue = mqueue;
IF (Queue == null) {
a RuntimeException a RuntimeException new new E = (
+ the this "sendMessageAtTime () Called with mqueue NO");
Log.w ( "Looper", e.getMessage (), E);
return to false;
}
// add messages to the queue
return enqueueMessage (queue, msg, uptimeMillis );
}
/ *
* a callback when Message is not null, performs callback method of the Message. A Runnable interface when the callback.
* 2. When the Callback Interface Handler is not null, performs the method Callback interface.
* 3. Handler in the handleMessage directly execute () method.
* /
void DispatchMessage public (the Message MSG) {
// Callback Interface message is not null, performs Callback Interface
IF (msg.callback = null!) {
handleCallback (MSG);
} {the else
IF (! mCallback = null) {
// Callback Handler interface is not null, the interface method performed
IF (mCallback.handleMessage (MSG)) {
return;
}
}
// message processing
the handleMessage (MSG);
}
}