本文整理汇总了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);
}
}
};
}
示例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");
}
}
示例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();
}
});
}
}
示例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);
}
示例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);
}
示例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");
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
};
}
示例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);
}
};
}
示例12: MyHander
import android.content.Context; //导入方法依赖的package包/类
public MyHander(Context context) {
super(context.getMainLooper());
}
示例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));
}
示例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();
}
示例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);
}