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


Java ThreadUtils.runOnUiThread方法代码示例

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


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

示例1: onHandleIntent

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * Called when a Notification has been interacted with by the user. If we can verify that
 * the Intent has a notification Id, start Chrome (if needed) on the UI thread.
 *
 * @param intent The intent containing the specific information.
 */
@Override
public void onHandleIntent(final Intent intent) {
    if (!intent.hasExtra(NotificationConstants.EXTRA_NOTIFICATION_ID)
            || !intent.hasExtra(NotificationConstants.EXTRA_NOTIFICATION_INFO_ORIGIN)
            || !intent.hasExtra(NotificationConstants.EXTRA_NOTIFICATION_INFO_TAG)) {
        return;
    }

    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            dispatchIntentOnUIThread(intent);
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:NotificationService.java

示例2: canUseGooglePlayServicesResultCode

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * Same as {@link #canUseGooglePlayServices(Context, UserRecoverableErrorHandler)}.
 * @param context The current context.
 * @param errorHandler How to handle user-recoverable errors; must be non-null.
 * @return the result code specifying Google Play Services availability.
 */
public int canUseGooglePlayServicesResultCode(
        final Context context, final UserRecoverableErrorHandler errorHandler) {
    final int resultCode = checkGooglePlayServicesAvailable(context);
    recordConnectionResult(resultCode);
    if (resultCode != ConnectionResult.SUCCESS) {
        // resultCode is some kind of error.
        Log.v(TAG, "Unable to use Google Play Services: %s", describeError(resultCode));

        if (isUserRecoverableError(resultCode)) {
            Runnable errorHandlerTask = new Runnable() {
                @Override
                public void run() {
                    errorHandler.handleError(context, resultCode);
                }
            };
            ThreadUtils.runOnUiThread(errorHandlerTask);
        }
    }
    return resultCode;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:27,代码来源:ExternalAuthUtils.java

示例3: loadBookmarks

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@BinderThread
private BookmarkFolder loadBookmarks(final BookmarkId folderId) {
    final LinkedBlockingQueue<BookmarkFolder> resultQueue = new LinkedBlockingQueue<>(1);
    //A reference of BookmarkLoader is needed in binder thread to
    //prevent it from being garbage collected.
    final BookmarkLoader bookmarkLoader = new BookmarkLoader();
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            bookmarkLoader.initialize(mContext, folderId, new BookmarkLoaderCallback() {
                @Override
                public void onBookmarksLoaded(BookmarkFolder folder) {
                    resultQueue.add(folder);
                }
            });
        }
    });
    try {
        return resultQueue.take();
    } catch (InterruptedException e) {
        return null;
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:BookmarkWidgetService.java

示例4: getCount

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@BinderThread
@Override
public int getCount() {
    //On some Sony devices, getCount() could be called before onDatasetChanged()
    //returns. If it happens, refresh widget until the bookmarks are all loaded.
    if (mCurrentFolder == null || !mPreferences.getString(PREF_CURRENT_FOLDER, "")
            .equals(mCurrentFolder.folder.id.toString())) {
        ThreadUtils.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                refreshWidget();
            }
        });
    }
    if (mCurrentFolder == null) {
        return 0;
    }
    return mCurrentFolder.children.size() + (mCurrentFolder.parent != null ? 1 : 0);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:BookmarkWidgetService.java

示例5: pushMessageReceived

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
private void pushMessageReceived(final String from, final Bundle data) {
    final String bundleSubtype = "subtype";
    if (!data.containsKey(bundleSubtype)) {
        Log.w(TAG, "Received push message with no subtype");
        return;
    }
    final String appId = data.getString(bundleSubtype);
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        @SuppressFBWarnings("DM_EXIT")
        public void run() {
            try {
                ChromeBrowserInitializer.getInstance(getApplicationContext())
                    .handleSynchronousStartup();
                GCMDriver.onMessageReceived(appId, from, data);
            } catch (ProcessInitException e) {
                Log.e(TAG, "ProcessInitException while starting the browser process");
                // Since the library failed to initialize nothing in the application
                // can work, so kill the whole application not just the activity.
                System.exit(-1);
            }
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:25,代码来源:ChromeGcmListenerService.java

示例6: TtsPlatformImpl

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
protected TtsPlatformImpl(long nativeTtsPlatformImplAndroid, Context context) {
    mInitialized = false;
    mNativeTtsPlatformImplAndroid = nativeTtsPlatformImplAndroid;
    mTextToSpeech = new TextToSpeech(context, new TextToSpeech.OnInitListener() {
            @Override
            public void onInit(int status) {
                if (status == TextToSpeech.SUCCESS) {
                    ThreadUtils.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            initialize();
                        }
                    });
                }
            }
        });
    addOnUtteranceProgressListener();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:19,代码来源:TtsPlatformImpl.java

示例7: record

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
public static void record(final String action) {
    if (ThreadUtils.runningOnUiThread()) {
        nativeRecordUserAction(action);
        return;
    }

    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            nativeRecordUserAction(action);
        }
    });
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:14,代码来源:RecordUserAction.java

示例8: onHandleIntent

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    final DocumentModeAssassin assassin = DocumentModeAssassin.getInstance();
    if (!assassin.isMigrationNecessary()) return;

    final CountDownLatch finishSignal = new CountDownLatch(1);
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (assassin.isMigrationNecessary()) {
                // Kick off migration if it hasn't already started.
                DocumentModeAssassinObserver observer = new DocumentModeAssassinObserver() {
                    @Override
                    public void onStageChange(int newStage) {
                        if (newStage != DocumentModeAssassin.STAGE_DONE) return;
                        assassin.removeObserver(this);
                        finishSignal.countDown();
                    }
                };
                assassin.addObserver(observer);
                assassin.migrateFromDocumentToTabbedMode();
            } else {
                // Migration finished in the background.
                finishSignal.countDown();
            }
        }
    });

    try {
        boolean success = finishSignal.await(TIMEOUT_MS, TimeUnit.MILLISECONDS);
        Log.d(TAG, "Migration completed.  Status: " + success);
    } catch (InterruptedException e) {
        Log.e(TAG, "Failed to migrate user on time.");
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:36,代码来源:UpgradeIntentService.java

示例9: onDestroy

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@BinderThread
@Override
public void onDestroy() {
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (mBookmarkModel != null) mBookmarkModel.destroy();
        }
    });
    deleteWidgetState(mContext, mWidgetId);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:12,代码来源:BookmarkWidgetService.java

示例10: onInvalidBeam

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * Trigger an error about NFC if we don't want to send anything. Also
 * records a UMA stat. On ICS we only show the error if they attempt to
 * beam, since the recipient will receive the market link. On JB we'll
 * always show the error, since the beam animation won't trigger, which
 * could be confusing to the user.
 *
 * @param errorStringId The resid of the string to display as error.
 */
private void onInvalidBeam(final int errorStringId) {
    RecordUserAction.record("MobileBeamInvalidAppState");
    Runnable errorRunnable = new Runnable() {
        @Override
        public void run() {
            Toast.makeText(mActivity, errorStringId, Toast.LENGTH_SHORT).show();
        }
    };
    if (NFC_BUGS_ACTIVE) {
        mErrorRunnableIfBeamSent = errorRunnable;
    } else {
        ThreadUtils.runOnUiThread(errorRunnable);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:BeamCallback.java

示例11: cleanUpSession

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
 * Handle any clean up left after a session is destroyed.
 * @param session The session that has been destroyed.
 */
@VisibleForTesting
void cleanUpSession(final CustomTabsSessionToken session) {
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            mClientManager.cleanupSession(session);
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:14,代码来源:CustomTabsConnection.java

示例12: recordClientPackageName

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
private void recordClientPackageName() {
    String clientName = CustomTabsConnection.getInstance(getApplication())
            .getClientPackageNameForSession(mSession);
    if (TextUtils.isEmpty(clientName)) clientName = mIntentDataProvider.getClientPackageName();
    final String packageName = clientName;
    if (TextUtils.isEmpty(packageName) || packageName.contains(getPackageName())) return;
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            RapporServiceBridge.sampleString(
                    "CustomTabs.ServiceClient.PackageName", packageName);
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:15,代码来源:CustomTabActivity.java

示例13: startBrowserIfNeededAndValidateAccounts

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@SuppressFBWarnings("DM_EXIT")
private static void startBrowserIfNeededAndValidateAccounts(final Context context) {
    BrowserParts parts = new EmptyBrowserParts() {
        @Override
        public void finishNativeInitialization() {
            ThreadUtils.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    SigninHelper.get(context).validateAccountSettings(true);
                }
            });
        }

        @Override
        public void onStartupFailure() {
            // Startup failed. So notify SigninHelper of changed accounts via
            // shared prefs.
            SigninHelper.markAccountsChangedPref(context);
        }
    };
    try {
        ChromeBrowserInitializer.getInstance(context).handlePreNativeStartup(parts);
        ChromeBrowserInitializer.getInstance(context).handlePostNativeStartup(true, parts);
    } catch (ProcessInitException e) {
        Log.e(TAG, "Unable to load native library.", e);
        ChromeApplication.reportStartupErrorAndExit(e);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:29,代码来源:AccountsChangedReceiver.java

示例14: androidSyncSettingsChanged

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@Override
public void androidSyncSettingsChanged() {
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (mIsDestroyed) return;
            updateForeignSessions();
            postUpdate();
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:12,代码来源:RecentTabsManager.java

示例15: finalize

import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@Override
protected void finalize() throws Throwable {
    try {
        // Per Object#finalize(), finalizers are run on a single VM-wide finalizer thread, and
        // the native objects need to be destroyed on the UI thread.
        ThreadUtils.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                ensureNativeChromeDestroyedOnUIThread();
            }
        });
    } finally {
        super.finalize();
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:16,代码来源:ChromeBrowserProvider.java


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