FileDocCategorySizeDatePackage
HandlerCaller.javaAPI DocAndroid 1.5 API5747Wed May 06 22:41:56 BST 2009com.android.internal.os

HandlerCaller

public class HandlerCaller extends Object

Fields Summary
private static final String
TAG
private static final boolean
DEBUG
public final android.content.Context
mContext
final android.os.Looper
mMainLooper
final android.os.Handler
mH
final Callback
mCallback
static final int
ARGS_POOL_MAX_SIZE
int
mArgsPoolSize
SomeArgs
mArgsPool
Constructors Summary
public HandlerCaller(android.content.Context context, Callback callback)

        mContext = context;
        mMainLooper = context.getMainLooper();
        mH = new MyHandler(mMainLooper);
        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 com.android.internal.os.HandlerCaller$SomeArgsobtainArgs()

        synchronized (mH) {
            SomeArgs args = mArgsPool;
            if (args != null) {
                mArgsPool = args.next;
                args.next = null;
                mArgsPoolSize--;
                return args;
            }
        }
        return new SomeArgs();
    
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 = obtainArgs();
        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 = obtainArgs();
        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 = obtainArgs();
        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 = obtainArgs();
        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.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 = obtainArgs();
        args.arg1 = arg2;
        args.arg2 = arg3;
        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 = obtainArgs();
        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 = obtainArgs();
        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 = obtainArgs();
        args.arg1 = arg1;
        args.arg2 = arg2;
        args.arg3 = arg3;
        args.arg4 = arg4;
        return mH.obtainMessage(what, 0, 0, args);
    
public voidrecycleArgs(com.android.internal.os.HandlerCaller$SomeArgs args)

        synchronized (mH) {
            if (mArgsPoolSize < ARGS_POOL_MAX_SIZE) {
                args.next = mArgsPool;
                mArgsPool = args;
                mArgsPoolSize++;
            }
        }
    
public voidsendMessage(android.os.Message msg)

        mH.sendMessage(msg);