本文整理汇总了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);
}
});
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}
}
});
}
示例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();
}
示例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);
}
});
}
示例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.");
}
}
示例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);
}
示例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);
}
}
示例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);
}
});
}
示例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);
}
});
}
示例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);
}
}
示例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();
}
});
}
示例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();
}
}