当前位置: 首页>>代码示例>>Java>>正文


Java Context.getMainLooper方法代码示例

本文整理汇总了Java中android.content.Context.getMainLooper方法的典型用法代码示例。如果您正苦于以下问题:Java Context.getMainLooper方法的具体用法?Java Context.getMainLooper怎么用?Java Context.getMainLooper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.Context的用法示例。


在下文中一共展示了Context.getMainLooper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PluginLocalBroadcastManager

import android.content.Context; //导入方法依赖的package包/类
private PluginLocalBroadcastManager(Context context) {
    mAppContext = context;
    mHandler = new Handler(context.getMainLooper()) {

        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_EXEC_PENDING_BROADCASTS:
                    executePendingBroadcasts();
                    break;
                default:
                    super.handleMessage(msg);
            }
        }
    };
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:17,代码来源:PluginLocalBroadcastManager.java

示例2: MiniDrone

import android.content.Context; //导入方法依赖的package包/类
public MiniDrone(Context context, @NonNull ARDiscoveryDeviceService deviceService) {

        mContext = context;
        mListeners = new ArrayList<>();

        // needed because some callbacks will be called on the main thread
        mHandler = new Handler(context.getMainLooper());

        mState = ARCONTROLLER_DEVICE_STATE_ENUM.ARCONTROLLER_DEVICE_STATE_STOPPED;

        // if the product type of the deviceService match with the types supported
        mProductType = ARDiscoveryService.getProductFromProductID(deviceService.getProductID());
        ARDISCOVERY_PRODUCT_FAMILY_ENUM family = ARDiscoveryService.getProductFamily(mProductType);
        if (ARDISCOVERY_PRODUCT_FAMILY_ENUM.ARDISCOVERY_PRODUCT_FAMILY_MINIDRONE.equals(family)) {

            ARDiscoveryDevice discoveryDevice = createDiscoveryDevice(context, deviceService, mProductType);
            if (discoveryDevice != null) {
                mDeviceController = createDeviceController(discoveryDevice);
            }

        } else {
            Log.e(TAG, "DeviceService type is not supported by MiniDrone");
        }
    }
 
开发者ID:pkargupta,项目名称:gyrodrone,代码行数:25,代码来源:MiniDrone.java

示例3: showToast

import android.content.Context; //导入方法依赖的package包/类
private static void showToast(@NonNull final String message, final Context context, final int duration) {
    if (null == message) {
        throw new NullPointerException("message");
    }
    if (null == mAppName) {
        throw new NullPointerException("mAppName");
    }
    if (Looper.myLooper() == context.getMainLooper()) {
        Toast.makeText(context, mAppName + ": " + message, duration).show();
    } else {
        new Handler(context.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(context, mAppName + ": " + message, duration).show();
            }
        });
    }
}
 
开发者ID:littleRich,项目名称:AutoInteraction-Library,代码行数:19,代码来源:Log.java

示例4: init

import android.content.Context; //导入方法依赖的package包/类
private void init(Context context) {
    this.context = context;
    this.uiHandler = new Handler(context.getMainLooper());

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.nim_emoji_layout, this);
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:8,代码来源:EmoticonPickerView.java

示例5: PKDialog

import android.content.Context; //导入方法依赖的package包/类
public PKDialog(Context context, String str, String str2, IUiListener iUiListener, QQToken
        qQToken) {
    super(context, 16973840);
    this.mWeakContext = new WeakReference(context);
    this.mUrl = str2;
    this.mListener = new OnTimeListener(context, str, str2, qQToken.getAppId(), iUiListener);
    this.mHandler = new THandler(this.mListener, context.getMainLooper());
    this.listener = iUiListener;
    this.mWebviewHeight = Math.round(185.0f * context.getResources().getDisplayMetrics()
            .density);
    f.e(TAG, "density=" + context.getResources().getDisplayMetrics().density + "; " +
            "webviewHeight=" + this.mWebviewHeight);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:PKDialog.java

示例6: ensureNotOnMainThread

import android.content.Context; //导入方法依赖的package包/类
private static void ensureNotOnMainThread(Context context) {
    Looper looper = Looper.myLooper();
    if (looper != null && looper == context.getMainLooper()) {
        throw new IllegalStateException("calling this from your main thread can lead to " +
                "deadlock");
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:ServiceTalker.java

示例7: init

import android.content.Context; //导入方法依赖的package包/类
public void init(Context context) {
    if (inited) {
        return;
    }

    // init thread pool
    executor = new NimTaskExecutor("NIM_HTTP_TASK_EXECUTOR", new NimTaskExecutor.Config(1, 3, 10 * 1000, true));
    uiHandler = new Handler(context.getMainLooper());
    inited = true;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:11,代码来源:NimHttpClient.java

示例8: PKDialog

import android.content.Context; //导入方法依赖的package包/类
public PKDialog(Context context, String str, String str2, IUiListener iUiListener, QQToken qQToken) {
    super(context, 16973840);
    this.mWeakContext = new WeakReference(context);
    this.mUrl = str2;
    this.mListener = new OnTimeListener(context, str, str2, qQToken.getAppId(), iUiListener);
    this.mHandler = new THandler(this.mListener, context.getMainLooper());
    this.listener = iUiListener;
    this.mWebviewHeight = Math.round(185.0f * context.getResources().getDisplayMetrics().density);
    f.e(TAG, "density=" + context.getResources().getDisplayMetrics().density + "; webviewHeight=" + this.mWebviewHeight);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:11,代码来源:PKDialog.java

示例9: TDialog

import android.content.Context; //导入方法依赖的package包/类
public TDialog(Context context, String str, String str2, IUiListener iUiListener, QQToken qQToken) {
    super(context, 16973840);
    this.c = new WeakReference(context);
    this.e = str2;
    this.f = new OnTimeListener(context, str, str2, qQToken.getAppId(), iUiListener);
    this.j = new THandler(this.f, context.getMainLooper());
    this.g = iUiListener;
    this.l = qQToken;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:10,代码来源:TDialog.java

示例10: LocalBroadcastManager

import android.content.Context; //导入方法依赖的package包/类
private LocalBroadcastManager(Context context) {
    this.mAppContext = context;
    this.mHandler = new Handler(context.getMainLooper()) {
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case 1:
                    LocalBroadcastManager.this.executePendingBroadcasts();
                    return;
                default:
                    super.handleMessage(msg);
                    return;
            }
        }
    };
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:16,代码来源:LocalBroadcastManager.java

示例11: CountDownUtils

import android.content.Context; //导入方法依赖的package包/类
public CountDownUtils(final Context context, final TextView v) {
    this.context = context;
    this.v = v;
    countdownHandler = new Handler(context.getMainLooper()) {
        public void handleMessage(android.os.Message msg) {
            String s = String.format(context.getString(R.string.code_txt), String.valueOf(iTime));
            v.setText(s);
            countdownHandler.postDelayed(countdownRunnable, 1000);
        }
    };
}
 
开发者ID:huashengzzz,项目名称:SmartChart,代码行数:12,代码来源:CountDownUtils.java

示例12: MyHander

import android.content.Context; //导入方法依赖的package包/类
public MyHander(Context context) {
	super(context.getMainLooper());
}
 
开发者ID:FacePlusPlus,项目名称:MegviiLicMgr-Android-SDK,代码行数:4,代码来源:RequestManager.java

示例13: updateLVL

import android.content.Context; //导入方法依赖的package包/类
/**
 * Updates the LVL information from the server.
 *
 * @param context
 */
public void updateLVL(final Context context) {
    Context c = context.getApplicationContext();
    Handler h = new Handler(c.getMainLooper());
    h.post(new LVLRunnable(c, mPendingIntent));
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:11,代码来源:DownloaderService.java

示例14: BaseDialog

import android.content.Context; //导入方法依赖的package包/类
public BaseDialog(Context context) {
    super(context, R.style.dialog_custom);
    mContext = context;
    handler = new Handler(context.getMainLooper());
    initView();
}
 
开发者ID:chengzichen,项目名称:KrGallery,代码行数:7,代码来源:BaseDialog.java

示例15: BlocklyController

import android.content.Context; //导入方法依赖的package包/类
/**
 * Creates a new Controller with Workspace and WorkspaceHelper. Most controllers will require
 * a {@link BlockViewFactory}, but headless (i.e. viewless) controllers are allowed, where it
 * could be null.
 *
 * @param context Android context, such as an Activity.
 * @param blockModelFactory Factory used to create new Blocks.
 * @param workspaceHelper Helper functions for workspace views and device resolution.
 * @param blockViewFactory Factory used to construct block views for this app.
 */
private BlocklyController(Context context, BlockFactory blockModelFactory,
                          WorkspaceHelper workspaceHelper, BlockClipDataHelper clipHelper,
                          @Nullable BlockViewFactory blockViewFactory) {

    if (context == null) {
        throw new IllegalArgumentException("Context may not be null.");
    }
    if (blockModelFactory == null) {
        throw new IllegalArgumentException("BlockFactory may not be null.");
    }
    if (workspaceHelper == null) {
        throw new IllegalArgumentException("WorkspaceHelper may not be null.");
    }
    if (clipHelper == null) {
        throw new IllegalArgumentException("BlockClipDataHelper may not be null.");
    }
    mContext = context;
    mMainLooper = context.getMainLooper();
    mModelFactory = blockModelFactory;
    mModelFactory.setController(this);
    mHelper = workspaceHelper;
    mViewFactory = blockViewFactory;

    // mHelper, mModelFactory, and mViewFactory must be initialized before mClipHelper.
    mClipHelper = clipHelper;

    mWorkspace = new Workspace(mContext, this, mModelFactory);
    mConnectionManager = mWorkspace.getConnectionManager();

    if (mViewFactory != null) {
        // TODO(#81): Check if variables are enabled/disabled
        mViewFactory.setVariableNameManager(mWorkspace.getVariableNameManager());
        mViewFactory.setVariableRequestCallback(new VariableRequestCallback() {
            @Override
            public void onVariableRequest(int request, String variable) {
                if (request == VariableRequestCallback.REQUEST_RENAME) {
                    requestRenameVariable(variable, variable);
                } else if (request == VariableRequestCallback.REQUEST_DELETE) {
                    requestDeleteVariable(variable);
                }
            }
        });
    }

    mDragger = new Dragger(this);
    mTouchHandler = mDragger.buildSloppyBlockTouchHandler(mWorkspaceDragHandler);

    mFlyoutController = new FlyoutController(this);
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:60,代码来源:BlocklyController.java


注:本文中的android.content.Context.getMainLooper方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。