本文整理汇总了Java中org.chromium.base.ThreadUtils.postOnUiThread方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadUtils.postOnUiThread方法的具体用法?Java ThreadUtils.postOnUiThread怎么用?Java ThreadUtils.postOnUiThread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.chromium.base.ThreadUtils
的用法示例。
在下文中一共展示了ThreadUtils.postOnUiThread方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCapabilitiesChanged
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@Override
public void onCapabilitiesChanged(
Network network, NetworkCapabilities networkCapabilities) {
if (ignoreConnectedNetwork(network, networkCapabilities)) {
return;
}
// A capabilities change may indicate the ConnectionType has changed,
// so forward the new ConnectionType along to observer.
final long netId = networkToNetId(network);
final int connectionType =
getCurrentConnectionType(mConnectivityManagerDelegate.getNetworkState(network));
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
mObserver.onNetworkConnect(netId, connectionType);
}
});
}
示例2: maybePostResult
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@VisibleForTesting
void maybePostResult() {
ThreadUtils.assertOnUiThread();
if (mCallback == null) return;
if (mResultPosted) return;
// Always wait for screenshot.
if (!mScreenshotTaskFinished) return;
if (!mConnectivityTaskFinished && !hasTimedOut()) return;
mResultPosted = true;
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
mCallback.onResult(FeedbackCollector.this);
}
});
}
示例3: create
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
* Prepares screenshot (possibly asynchronously) and invokes the callback when the screenshot
* is available, or collection has failed. The asynchronous path is only taken when the activity
* that is passed in is a {@link ChromeActivity}.
* The callback is always invoked asynchronously.
*/
public static void create(Activity activity, final ScreenshotTaskCallback callback) {
if (activity instanceof ChromeActivity) {
Rect rect = new Rect();
activity.getWindow().getDecorView().getRootView().getWindowVisibleDisplayFrame(rect);
createCompositorScreenshot(((ChromeActivity) activity).getWindowAndroid(), rect,
callback);
return;
}
final Bitmap bitmap = prepareScreenshot(activity, null);
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
callback.onGotBitmap(bitmap);
}
});
}
示例4: registerNativeInitStartupCallback
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
* Register a StartupCallback to initialize the native portion of the JNI bridge.
*/
private void registerNativeInitStartupCallback() {
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
BrowserStartupController.get(mContext, LibraryProcessType.PROCESS_BROWSER)
.addStartupCompletedObserver(new StartupCallback() {
@Override
public void onSuccess(boolean alreadyStarted) {
mNativePhysicalWebDataSourceAndroid = nativeInit();
}
@Override
public void onFailure() {
// Startup failed.
}
});
}
});
}
示例5: validatePostMessageOriginInternal
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
private boolean validatePostMessageOriginInternal(final CustomTabsSessionToken session) {
if (!mWarmupHasBeenCalled.get()) return false;
if (!isCallerForegroundOrSelf()) return false;
final int uid = Binder.getCallingUid();
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
// If the API is not enabled, we don't set the post message origin, which will
// avoid PostMessageHandler initialization and disallow postMessage calls.
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.CCT_POST_MESSAGE_API)) return;
mClientManager.setPostMessageOriginForSession(
session, acquireOriginForSession(session, uid));
}
});
return true;
}
示例6: postMessage
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
* Relay a postMessage request through the current channel assigned to this session.
* @param message The message to be sent.
* @return The result of the postMessage request. Returning true means the request was accepted,
* not necessarily that the postMessage was successful.
*/
public int postMessage(final String message) {
if (mChannel == null || !mChannel[0].isReady() || mChannel[0].isClosed()) {
return CustomTabsService.RESULT_FAILURE_MESSAGING_ERROR;
}
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
// It is still possible that the page has navigated while this task is in the queue.
// If that happens fail gracefully.
if (mChannel == null || mChannel[0].isClosed()) return;
mChannel[0].postMessage(message, null);
}
});
return CustomTabsService.RESULT_SUCCESS;
}
示例7: notifyChange
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@SuppressLint("NewApi")
private void notifyChange(final Uri uri) {
// If the calling user is different than current one, we need to post a
// task to notify change, otherwise, a system level hidden permission
// INTERACT_ACROSS_USERS_FULL is needed.
// The related APIs were added in API 17, it should be safe to fallback to
// normal way for notifying change, because caller can't be other users in
// devices whose API level is less than API 17.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
UserHandle callingUserHandle = Binder.getCallingUserHandle();
if (callingUserHandle != null
&& !callingUserHandle.equals(android.os.Process.myUserHandle())) {
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
getContext().getContentResolver().notifyChange(uri, null);
}
});
return;
}
}
getContext().getContentResolver().notifyChange(uri, null);
}
示例8: postCallbackOnMainThread
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
* Move activity from the native thread to the main UI thread.
* Called from native code on its own thread. Posts a callback from
* the UI thread back to native code.
*
* @param opaque Opaque argument.
*/
@CalledByNative
public static void postCallbackOnMainThread(final long opaque) {
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
nativeRunCallbackOnUiThread(opaque);
}
});
}
示例9: updateEnabled
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
* If precaching is enabled, then allow the PrecacheController to be launched and signal Chrome
* when conditions are right to start precaching. If precaching is disabled, prevent the
* PrecacheController from ever starting.
*
* @param context any context within the application
*/
@VisibleForTesting
void updateEnabled(final Context context) {
Log.v(TAG, "updateEnabled starting");
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
mCalled = true;
final ProfileSyncService sync = ProfileSyncService.get();
if (mListener == null && sync != null) {
mListener = new ProfileSyncService.SyncStateChangedListener() {
public void syncStateChanged() {
if (sync.isBackendInitialized()) {
mSyncInitialized = true;
updateEnabledSync(context);
}
}
};
sync.addSyncStateChangedListener(mListener);
}
if (mListener != null) {
// Call the listener once, in case the sync backend is already initialized.
mListener.syncStateChanged();
}
Log.v(TAG, "updateEnabled complete");
}
});
}
示例10: onLosing
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@Override
public void onLosing(Network network, int maxMsToLive) {
if (ignoreConnectedNetwork(network, null)) {
return;
}
final long netId = networkToNetId(network);
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
mObserver.onNetworkSoonToDisconnect(netId);
}
});
}
示例11: setUp
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
LibraryLoader.get(LibraryProcessType.PROCESS_BROWSER)
.ensureInitialized(getInstrumentation().getTargetContext());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Find Network.Network(int netId) using reflection.
mNetworkConstructor = Network.class.getConstructor(Integer.TYPE);
}
ThreadUtils.postOnUiThread(new Runnable() {
public void run() {
createTestNotifier(WatchForChanges.ONLY_WHEN_APP_IN_FOREGROUND);
}
});
}
示例12: setOnInitializeAsyncFinished
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
* Sets a callback that will be executed when the initialization is done.
*
* @param callback This is called when the initialization is done.
*/
public static void setOnInitializeAsyncFinished(final Runnable callback) {
if (sIsInitialized) {
ThreadUtils.postOnUiThread(callback);
} else {
sInitializeAsyncCallbacks.add(callback);
}
}
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:13,代码来源:PartnerBrowserCustomizations.java
示例13: postResult
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
private static void postResult(final ConnectivityCheckerCallback callback, final int result) {
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
callback.onResult(result);
}
});
}
示例14: postCallbackResult
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
private void postCallbackResult() {
if (mCallback == null) return;
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
mCallback.onResult(get());
}
});
}
示例15: onSuccessNotificationShown
import org.chromium.base.ThreadUtils; //导入方法依赖的package包/类
/**
* Called when a successful notification is shown.
* @param info Pending notification information to be handled.
* @param notificationId ID of the notification.
*/
@VisibleForTesting
void onSuccessNotificationShown(
final PendingNotificationInfo notificationInfo, final int notificationId) {
ThreadUtils.postOnUiThread(new Runnable() {
@Override
public void run() {
DownloadManagerService.getDownloadManagerService(
mApplicationContext).onSuccessNotificationShown(
notificationInfo.downloadInfo, notificationInfo.canResolve,
notificationId, notificationInfo.systemDownloadId);
}
});
}