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


Java ThreadUtils.assertOnUiThread方法代码示例

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


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

示例1: signalNativeLibraryLoadedIfReady

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
private void signalNativeLibraryLoadedIfReady() {
    ThreadUtils.assertOnUiThread();

    // Called on UI thread when any of the booleans below have changed.
    if (mHasDoneFirstDraw && mLibraryLoaded && !mWaitingForVariationsFetch) {
        // Allow the UI thread to continue its initialization - so that this call back
        // doesn't block priority work on the UI thread until it's idle.
        mHandler.post(new Runnable() {
            @Override
            public void run() {
                if (mActivityDelegate.isActivityDestroyed()) return;
                mActivityDelegate.onCreateWithNative();
            }
        });
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:17,代码来源:NativeInitializationController.java

示例2: onApplicationStateChange

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@Override
public void onApplicationStateChange(int newState) {
    Log.d(TAG, "onApplicationStateChange");
    ThreadUtils.assertOnUiThread();

    boolean newVisibility = ApplicationStatus.hasVisibleActivities();
    if (mIsApplicationVisible == newVisibility) return;

    Log.d(TAG, "Application visibilty changed to %s. Updating state of %d client(s).",
            newVisibility, mClientHelpers.size());

    mIsApplicationVisible = newVisibility;

    synchronized (mClientHelpers) {
        for (GoogleApiClientHelper clientHelper : mClientHelpers) {
            if (mIsApplicationVisible) clientHelper.restoreConnectedState();
            else clientHelper.scheduleDisconnection();
        }
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:21,代码来源:LifecycleHook.java

示例3: getForProfile

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * Returns Java DomDistillerService for given Profile.
 */
public static DomDistillerService getForProfile(Profile profile) {
    ThreadUtils.assertOnUiThread();
    DomDistillerService service = sServiceMap.get(profile);
    if (service == null) {
        service = nativeGetForProfile(profile);
        sServiceMap.put(profile, service);
    }
    return service;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:DomDistillerServiceFactory.java

示例4: getInstance

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
public static PersonalDataManager getInstance() {
    ThreadUtils.assertOnUiThread();
    if (sManager == null) {
        sManager = new PersonalDataManager();
    }
    return sManager;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:8,代码来源:PersonalDataManager.java

示例5: isRecognitionIntentPresent

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * Determines whether or not the {@link RecognizerIntent#ACTION_WEB_SEARCH} {@link Intent}
 * is handled by any {@link android.app.Activity}s in the system.  The result will be cached for
 * future calls.  Passing {@code false} to {@code useCachedValue} will force it to re-query any
 * {@link android.app.Activity}s that can process the {@link Intent}.
 * @param context        The {@link Context} to use to check to see if the {@link Intent} will
 *                       be handled.
 * @param useCachedValue Whether or not to use the cached value from a previous result.
 * @return {@code true} if recognition is supported.  {@code false} otherwise.
 */
public static boolean isRecognitionIntentPresent(Context context, boolean useCachedValue) {
    ThreadUtils.assertOnUiThread();
    if (sHasRecognitionIntentHandler == null || !useCachedValue) {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> activities = pm.queryIntentActivities(
                new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
        sHasRecognitionIntentHandler = activities.size() > 0;
    }

    return sHasRecognitionIntentHandler;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:FeatureUtilities.java

示例6: takeSpareWebContents

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * Returns a spare WebContents or null, depending on the availability of one.
 *
 * The parameters are the same as for {@link WebContentsFactory#createWebContents()}.
 *
 * @return a WebContents, or null.
 */
public WebContents takeSpareWebContents(boolean incognito, boolean initiallyHidden) {
    ThreadUtils.assertOnUiThread();
    if (incognito || initiallyHidden) return null;
    WebContents result = mSpareWebContents;
    mSpareWebContents = null;
    return result;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:15,代码来源:WarmupManager.java

示例7: instance

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * The singleton instance access method for native objects. Must be called on the UI thread
 * only.
 */
public static RemoteMediaPlayerController instance() {
    ThreadUtils.assertOnUiThread();

    if (sInstance == null) sInstance = new RemoteMediaPlayerController();
    if (sInstance.mChromeVideoActivity.get() == null) sInstance.linkToBrowserActivity();

    return sInstance;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:RemoteMediaPlayerController.java

示例8: takePrerenderedUrl

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * Transfers a prerendered WebContents if one exists.
 *
 * This resets the internal WebContents; a subsequent call to this method
 * returns null. Must be called from the UI thread.
 * If a prerender exists for a different URL with the same sessionId or with
 * a different referrer, then this is treated as a mispredict from the
 * client application, and cancels the previous prerender. This is done to
 * avoid keeping resources laying around for too long, but is subject to a
 * race condition, as the following scenario is possible:
 * The application calls:
 * 1. mayLaunchUrl(url1) <- IPC
 * 2. loadUrl(url2) <- Intent
 * 3. mayLaunchUrl(url3) <- IPC
 * If the IPC for url3 arrives before the intent for url2, then this methods
 * cancels the prerender for url3, which is unexpected. On the other
 * hand, not cancelling the previous prerender leads to wasted resources, as
 * a WebContents is lingering. This can be solved by requiring applications
 * to call mayLaunchUrl(null) to cancel a current prerender before 2, that
 * is for a mispredict.
 *
 * Note that this methods accepts URLs that don't exactly match the initially
 * prerendered URL. More precisely, the #fragment is ignored. In this case,
 * the client needs to navigate to the correct URL after the WebContents
 * swap. This can be tested using {@link UrlUtilities#urlsFragmentsDiffer()}.
 *
 * @param session The Binder object identifying a session.
 * @param url The URL the WebContents is for.
 * @param referrer The referrer to use for |url|.
 * @return The prerendered WebContents, or null.
 */
WebContents takePrerenderedUrl(CustomTabsSessionToken session, String url, String referrer) {
    ThreadUtils.assertOnUiThread();
    if (mSpeculation == null || session == null || !session.equals(mSpeculation.session)) {
        return null;
    }

    if (mSpeculation.prefetchOnly) {
        Profile profile = Profile.getLastUsedProfile();
        new ResourcePrefetchPredictor(profile).stopPrefetching(mSpeculation.url);
        mSpeculation = null;
        return null;
    }

    WebContents webContents = mSpeculation.webContents;
    String prerenderedUrl = mSpeculation.url;
    String prerenderReferrer = mSpeculation.referrer;
    if (referrer == null) referrer = "";
    boolean ignoreFragments = mClientManager.getIgnoreFragmentsForSession(session);
    boolean urlsMatch = TextUtils.equals(prerenderedUrl, url)
            || (ignoreFragments
                    && UrlUtilities.urlsMatchIgnoringFragments(prerenderedUrl, url));
    WebContents result = null;
    if (urlsMatch && TextUtils.equals(prerenderReferrer, referrer)) {
        result = webContents;
        mSpeculation = null;
    } else {
        cancelPrerender(session);
    }
    if (!mClientManager.usesDefaultSessionParameters(session) && webContents != null) {
        RecordHistogram.recordBooleanHistogram(
                "CustomTabs.NonDefaultSessionPrerenderMatched", result != null);
    }

    return result;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:67,代码来源:CustomTabsConnection.java

示例9: postInflationStartup

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
private void postInflationStartup() {
    ThreadUtils.assertOnUiThread();
    if (mPostInflationStartupComplete) return;

    // Check to see if we need to extract any new resources from the APK. This could
    // be on first run when we need to extract all the .pak files we need, or after
    // the user has switched locale, in which case we want new locale resources.
    ResourceExtractor.get().startExtractingResources();

    mPostInflationStartupComplete = true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:12,代码来源:ChromeBrowserInitializer.java

示例10: unregisterDataObserver

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * Unregisters the provided observer.
 */
public void unregisterDataObserver(PersonalDataManagerObserver observer) {
    ThreadUtils.assertOnUiThread();
    assert (mDataObservers.size() > 0);
    assert (mDataObservers.contains(observer));
    mDataObservers.remove(observer);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:10,代码来源:PersonalDataManager.java

示例11: onNetworkConnect

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@Override
public void onNetworkConnect(long netId, int connectionType) {
    ThreadUtils.assertOnUiThread();
    mChanges.add(new ChangeInfo(ChangeType.CONNECT, netId));
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:6,代码来源:NetworkChangeNotifierTest.java

示例12: fireRefreshTokensLoaded

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * Triggers a notification to all observers of the native and Java instance of the
 * OAuth2TokenService that all refresh tokens now have been loaded.
 */
@VisibleForTesting
public void fireRefreshTokensLoaded() {
    ThreadUtils.assertOnUiThread();
    nativeFireRefreshTokensLoadedFromJava(mNativeOAuth2TokenServiceDelegateAndroid);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:10,代码来源:OAuth2TokenService.java

示例13: isDone

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * @return whether all connectivity type results have been collected.
 */
public boolean isDone() {
    ThreadUtils.assertOnUiThread();
    return mResult.size() == Type.values().length;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:8,代码来源:ConnectivityTask.java

示例14: getProfileUseCountForTesting

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@VisibleForTesting
int getProfileUseCountForTesting(String guid) {
    ThreadUtils.assertOnUiThread();
    return nativeGetProfileUseCountForTesting(mPersonalDataManagerAndroid, guid);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:6,代码来源:PersonalDataManager.java

示例15: clearViewHierarchy

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * Clears the inflated view hierarchy.
 */
public void clearViewHierarchy() {
    ThreadUtils.assertOnUiThread();
    mMainView = null;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:8,代码来源:WarmupManager.java


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