FileDocCategorySizeDatePackage
HandlerCaller.javaAPI DocAndroid 5.1 API7316Thu Mar 12 22:22:10 GMT 2015com.android.internal.os

HandlerCaller

public class HandlerCaller extends Object

Fields Summary
final android.os.Looper
mMainLooper
final android.os.Handler
mH
final Callback
mCallback
Constructors Summary
public HandlerCaller(android.content.Context context, android.os.Looper looper, Callback callback, boolean asyncHandler)

        mMainLooper = looper != null ? looper : context.getMainLooper();
        mH = new MyHandler(mMainLooper, asyncHandler);
        mCallback = callback;
    
Methods Summary
public voidexecuteOrSendMessage(android.os.Message msg)

        // If we are calling this from the main thread, then we can call
        // right through.  Otherwise, we need to send the message to the
        // main thread.
        if (Looper.myLooper() == mMainLooper) {
            mCallback.executeMessage(msg);
            msg.recycle();
            return;
        }
        
        mH.sendMessage(msg);
    
public android.os.HandlergetHandler()

        return mH;
    
public booleanhasMessages(int what)

        return mH.hasMessages(what);
    
public android.os.MessageobtainMessage(int what)

        return mH.obtainMessage(what);
    
public android.os.MessageobtainMessageBO(int what, boolean arg1, java.lang.Object arg2)

        return mH.obtainMessage(what, arg1 ? 1 : 0, 0, arg2);
    
public android.os.MessageobtainMessageBOO(int what, boolean arg1, java.lang.Object arg2, java.lang.Object arg3)

        SomeArgs args = SomeArgs.obtain();
        args.arg1 = arg2;
        args.arg2 = arg3;
        return mH.obtainMessage(what, arg1 ? 1 : 0, 0, args);
    
public android.os.MessageobtainMessageI(int what, int arg1)

        return mH.obtainMessage(what, arg1, 0);
    
public android.os.MessageobtainMessageII(int what, int arg1, int arg2)

        return mH.obtainMessage(what, arg1, arg2);
    
public android.os.MessageobtainMessageIIII(int what, int arg1, int arg2, int arg3, int arg4)

        SomeArgs args = SomeArgs.obtain();
        args.argi1 = arg1;
        args.argi2 = arg2;
        args.argi3 = arg3;
        args.argi4 = arg4;
        return mH.obtainMessage(what, 0, 0, args);
    
public android.os.MessageobtainMessageIIIIII(int what, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6)

        SomeArgs args = SomeArgs.obtain();
        args.argi1 = arg1;
        args.argi2 = arg2;
        args.argi3 = arg3;
        args.argi4 = arg4;
        args.argi5 = arg5;
        args.argi6 = arg6;
        return mH.obtainMessage(what, 0, 0, args);
    
public android.os.MessageobtainMessageIIIIO(int what, int arg1, int arg2, int arg3, int arg4, java.lang.Object arg5)

        SomeArgs args = SomeArgs.obtain();
        args.arg1 = arg5;
        args.argi1 = arg1;
        args.argi2 = arg2;
        args.argi3 = arg3;
        args.argi4 = arg4;
        return mH.obtainMessage(what, 0, 0, args);
    
public android.os.MessageobtainMessageIIO(int what, int arg1, int arg2, java.lang.Object arg3)

        return mH.obtainMessage(what, arg1, arg2, arg3);
    
public android.os.MessageobtainMessageIIOO(int what, int arg1, int arg2, java.lang.Object arg3, java.lang.Object arg4)

        SomeArgs args = SomeArgs.obtain();
        args.arg1 = arg3;
        args.arg2 = arg4;
        return mH.obtainMessage(what, arg1, arg2, args);
    
public android.os.MessageobtainMessageIO(int what, int arg1, java.lang.Object arg2)

        return mH.obtainMessage(what, arg1, 0, arg2);
    
public android.os.MessageobtainMessageIOO(int what, int arg1, java.lang.Object arg2, java.lang.Object arg3)

        SomeArgs args = SomeArgs.obtain();
        args.arg1 = arg2;
        args.arg2 = arg3;
        return mH.obtainMessage(what, arg1, 0, args);
    
public android.os.MessageobtainMessageIOOO(int what, int arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)

        SomeArgs args = SomeArgs.obtain();
        args.arg1 = arg2;
        args.arg2 = arg3;
        args.arg3 = arg4;
        return mH.obtainMessage(what, arg1, 0, args);
    
public android.os.MessageobtainMessageO(int what, java.lang.Object arg1)

        return mH.obtainMessage(what, 0, 0, arg1);
    
public android.os.MessageobtainMessageOO(int what, java.lang.Object arg1, java.lang.Object arg2)

        SomeArgs args = SomeArgs.obtain();
        args.arg1 = arg1;
        args.arg2 = arg2;
        return mH.obtainMessage(what, 0, 0, args);
    
public android.os.MessageobtainMessageOOO(int what, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)

        SomeArgs args = SomeArgs.obtain();
        args.arg1 = arg1;
        args.arg2 = arg2;
        args.arg3 = arg3;
        return mH.obtainMessage(what, 0, 0, args);
    
public android.os.MessageobtainMessageOOOO(int what, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)

        SomeArgs args = SomeArgs.obtain();
        args.arg1 = arg1;
        args.arg2 = arg2;
        args.arg3 = arg3;
        args.arg4 = arg4;
        return mH.obtainMessage(what, 0, 0, args);
    
public android.os.MessageobtainMessageOOOOO(int what, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4, java.lang.Object arg5)

        SomeArgs args = SomeArgs.obtain();
        args.arg1 = arg1;
        args.arg2 = arg2;
        args.arg3 = arg3;
        args.arg4 = arg4;
        args.arg5 = arg5;
        return mH.obtainMessage(what, 0, 0, args);
    
public voidremoveMessages(int what)

        mH.removeMessages(what);
    
public voidremoveMessages(int what, java.lang.Object obj)

        mH.removeMessages(what, obj);
    
public voidsendMessage(android.os.Message msg)

        mH.sendMessage(msg);
    
public SomeArgssendMessageAndWait(android.os.Message msg)

        if (Looper.myLooper() == mH.getLooper()) {
            throw new IllegalStateException("Can't wait on same thread as looper");
        }
        SomeArgs args = (SomeArgs)msg.obj;
        args.mWaitState = SomeArgs.WAIT_WAITING;
        mH.sendMessage(msg);
        synchronized (args) {
            while (args.mWaitState == SomeArgs.WAIT_WAITING) {
                try {
                    args.wait();
                } catch (InterruptedException e) {
                    return null;
                }
            }
        }
        args.mWaitState = SomeArgs.WAIT_NONE;
        return args;
    
public voidsendMessageDelayed(android.os.Message msg, long delayMillis)

        mH.sendMessageDelayed(msg, delayMillis);