當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。