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


Java Callback.onResult方法代码示例

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


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

示例1: selectPageForOnlineUrlCallback

import org.chromium.base.Callback; //导入方法依赖的package包/类
/**
 * Takes the offline page item from selectPageForOnlineURL. If it exists, invokes
 * |prepareForSharing| with it.  Otherwise, saves a page for the online URL and invokes
 * |prepareForSharing| with the result when it's ready.
 * @param webContents Contents of the page to save.
 * @param offlinePageBridge A static copy of the offlinePageBridge.
 * @param prepareForSharing Callback of a single OfflinePageItem that is used to call
 *                          prepareForSharing
 * @return a callback of OfflinePageItem
 */
private static Callback<OfflinePageItem> selectPageForOnlineUrlCallback(
        final WebContents webContents, final OfflinePageBridge offlinePageBridge,
        final Callback<OfflinePageItem> prepareForSharing) {
    return new Callback<OfflinePageItem>() {
        @Override
        public void onResult(OfflinePageItem item) {
            if (item == null) {
                // If the page has no offline copy, save the page offline.
                ClientId clientId = ClientId.createGuidClientIdForNamespace(
                        OfflinePageBridge.SHARE_NAMESPACE);
                offlinePageBridge.savePage(webContents, clientId,
                        savePageCallback(prepareForSharing, offlinePageBridge));
                return;
            }
            // If the online page has offline copy associated with it, use the file directly.
            prepareForSharing.onResult(item);
        }
    };
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:30,代码来源:OfflinePageUtils.java

示例2: savePageCallback

import org.chromium.base.Callback; //导入方法依赖的package包/类
/**
 * Saves the web page loaded into web contents. If page saved successfully, get the offline
 * page item with the save page result and use it to invoke |prepareForSharing|. Otherwise,
 * invokes |prepareForSharing| with null.
 * @param prepareForSharing Callback of a single OfflinePageItem that is used to call
 *                          prepareForSharing
 * @param offlinePageBridge A static copy of the offlinePageBridge.
 * @return a call back of a list of OfflinePageItem
 */
private static OfflinePageBridge.SavePageCallback savePageCallback(
        final Callback<OfflinePageItem> prepareForSharing,
        final OfflinePageBridge offlinePageBridge) {
    return new OfflinePageBridge.SavePageCallback() {
        @Override
        public void onSavePageDone(int savePageResult, String url, long offlineId) {
            if (savePageResult != SavePageResult.SUCCESS) {
                Log.e(TAG, "Unable to save the page.");
                prepareForSharing.onResult(null);
                return;
            }

            offlinePageBridge.getPageByOfflineId(offlineId, prepareForSharing);
        }
    };
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:26,代码来源:OfflinePageUtils.java

示例3: dismissItem

import org.chromium.base.Callback; //导入方法依赖的package包/类
@Override
public void dismissItem(int position, Callback<String> itemRemovedCallback) {
    checkIndex(position);
    SuggestionsSource suggestionsSource = mUiDelegate.getSuggestionsSource();
    if (suggestionsSource == null) {
        // It is possible for this method to be called after the NewTabPage has had
        // destroy() called. This can happen when
        // NewTabPageRecyclerView.dismissWithAnimation() is called and the animation ends
        // after the user has navigated away. In this case we cannot inform the native side
        // that the snippet has been dismissed (http://crbug.com/649299).
        return;
    }

    SnippetArticle suggestion = remove(position);
    suggestionsSource.dismissSuggestion(suggestion);
    itemRemovedCallback.onResult(suggestion.mTitle);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:18,代码来源:SuggestionsSection.java

示例4: processBackgroundRequests

import org.chromium.base.Callback; //导入方法依赖的package包/类
/**
 * Triggers processing of background offlining requests.
 */
// TODO(petewil): Change back to private when UMA works in the test, and test
// startBackgroundRequests instead of this method.
@VisibleForTesting
public void processBackgroundRequests(
        Bundle bundle, DeviceConditions deviceConditions,
        final ChromeBackgroundServiceWaiter waiter) {
    // TODO(petewil): Nothing is holding the Wake Lock.  We need some solution to
    // keep hold of it.  Options discussed so far are having a fresh set of functions
    // to grab and release a countdown latch, or holding onto the wake lock ourselves,
    // or grabbing the wake lock and then starting chrome and running startProcessing
    // on the UI thread.

    // TODO(petewil): Decode the TriggerConditions from the bundle.

    Callback<Boolean> callback = new Callback<Boolean>() {
        /**
         * Callback function which indicates completion of background work.
         * @param result - true if work was actually done (used for UMA).
         */
        @Override
        public void onResult(Boolean result) {
            // Release the wake lock.
            Log.d(TAG, "onProcessingDone");
            waiter.onWaitDone();
        }
    };

    // Pass the activation on to the bridge to the C++ RequestCoordinator.
    if (!mBridge.startProcessing(deviceConditions, callback)) {
        // Processing not started currently. Let callback know.
        callback.onResult(false);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:37,代码来源:BackgroundOfflinerTask.java

示例5: getThumbnail

import org.chromium.base.Callback; //导入方法依赖的package包/类
/**
 * Gets the thumbnail of the current image that triggered the context menu.
 * @param callback Called once the the thumbnail is received.
 */
private void getThumbnail(final Callback<Bitmap> callback) {
    if (mNativeContextMenuHelper == 0) return;
    int maxSizePx = mActivity.getResources().getDimensionPixelSize(
            R.dimen.context_menu_header_image_max_size);
    Callback<byte[]> rawDataCallback = new Callback<byte[]>() {
        @Override
        public void onResult(byte[] result) {
            // TODO(tedchoc): Decode in separate process before launch.
            Bitmap bitmap = BitmapFactory.decodeByteArray(result, 0, result.length);
            callback.onResult(bitmap);
        }
    };
    nativeRetrieveImage(mNativeContextMenuHelper, rawDataCallback, maxSizePx);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:19,代码来源:ContextMenuHelper.java

示例6: deletePagesByOfflineId

import org.chromium.base.Callback; //导入方法依赖的package包/类
/**
 * Deletes offline pages based on the list of offline IDs. Calls the callback
 * when operation is complete. Note that offline IDs are not intended to be saved across
 * restarts of Chrome; they should be obtained by querying the model for the appropriate client
 * ID.
 *
 * @param offlineIds A list of offline IDs of pages that will be deleted.
 * @param callback A callback that will be called once operation is completed, called with the
 *     DeletePageResult of the operation..
 */
public void deletePagesByOfflineId(List<Long> offlineIdList, Callback<Integer> callback) {
    if (offlineIdList == null) {
        callback.onResult(Integer.valueOf(DeletePageResult.SUCCESS));
        return;
    }

    long[] offlineIds = new long[offlineIdList.size()];
    for (int i = 0; i < offlineIdList.size(); i++) {
        offlineIds[i] = offlineIdList.get(i).longValue();
    }
    nativeDeletePagesByOfflineId(mNativeOfflinePageBridge, offlineIds, callback);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:23,代码来源:OfflinePageBridge.java

示例7: isUserManaged

import org.chromium.base.Callback; //导入方法依赖的package包/类
/**
 * Performs an asynchronous check to see if the user is a managed user.
 * @param callback A callback to be called with true if the user is a managed user and false
 *         otherwise. May be called synchronously from this function.
 */
public static void isUserManaged(String email, final Callback<Boolean> callback) {
    if (nativeShouldLoadPolicyForUser(email)) {
        nativeIsUserManaged(email, callback);
    } else {
        callback.onResult(false);
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:13,代码来源:SigninManager.java

示例8: dismiss

import org.chromium.base.Callback; //导入方法依赖的package包/类
/** Hides the sign in promo and sets a preference to make sure it is not shown again. */
@Override
public void dismiss(Callback<String> itemRemovedCallback) {
    mDismissed = true;
    setVisible(false);

    ChromePreferenceManager.getInstance().setNewTabPageSigninPromoDismissed(true);
    mObserver.unregister();
    itemRemovedCallback.onResult(ContextUtils.getApplicationContext().getString(getHeader()));
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:11,代码来源:SignInPromo.java

示例9: showCancelableIntent

import org.chromium.base.Callback; //导入方法依赖的package包/类
@Override
public int showCancelableIntent(Callback<Integer> intentTrigger, IntentCallback callback,
        Integer errorId) {
    Activity activity = getActivity().get();
    if (activity == null) return START_INTENT_FAILURE;

    int requestCode = generateNextRequestCode();

    intentTrigger.onResult(requestCode);

    storeCallbackData(requestCode, callback, errorId);
    return requestCode;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:14,代码来源:ActivityWindowAndroid.java

示例10: onProvisioned

import org.chromium.base.Callback; //导入方法依赖的package包/类
/**
 * Called when device provisioning is finished.
 */
void onProvisioned(Callback<Boolean> cb) {
    if (isNativeMediaDrmStorageValid()) {
        nativeOnProvisioned(mNativeMediaDrmStorageBridge, cb);
    } else {
        cb.onResult(true);
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:11,代码来源:MediaDrmStorageBridge.java

示例11: loadInfo

import org.chromium.base.Callback; //导入方法依赖的package包/类
/**
 * Load |emeId|'s storage into memory.
 */
void loadInfo(byte[] emeId, Callback<PersistentInfo> cb) {
    if (isNativeMediaDrmStorageValid()) {
        nativeOnLoadInfo(mNativeMediaDrmStorageBridge, emeId, cb);
    } else {
        cb.onResult(null);
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:11,代码来源:MediaDrmStorageBridge.java

示例12: saveInfo

import org.chromium.base.Callback; //导入方法依赖的package包/类
/**
 * Save persistent information. Override the existing value.
 */
void saveInfo(PersistentInfo info, Callback<Boolean> cb) {
    if (isNativeMediaDrmStorageValid()) {
        nativeOnSaveInfo(mNativeMediaDrmStorageBridge, info, cb);
    } else {
        cb.onResult(false);
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:11,代码来源:MediaDrmStorageBridge.java

示例13: clearInfo

import org.chromium.base.Callback; //导入方法依赖的package包/类
/**
 * Remove persistent information related |emeId|.
 */
void clearInfo(byte[] emeId, Callback<Boolean> cb) {
    if (isNativeMediaDrmStorageValid()) {
        nativeOnClearInfo(mNativeMediaDrmStorageBridge, emeId, cb);
    } else {
        cb.onResult(true);
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:11,代码来源:MediaDrmStorageBridge.java

示例14: fetchSuggestionImage

import org.chromium.base.Callback; //导入方法依赖的package包/类
@Override
public void fetchSuggestionImage(SnippetArticle suggestion, Callback<Bitmap> callback) {
    if (mThumbnails.containsKey(suggestion.mIdWithinCategory)) {
        callback.onResult(mThumbnails.get(suggestion.mIdWithinCategory));
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:7,代码来源:FakeSuggestionsSource.java

示例15: onContextMenuClosed

import org.chromium.base.Callback; //导入方法依赖的package包/类
@Override
public void onContextMenuClosed(Menu menu) {
    for (Callback<Menu> callback : mContextMenuCloseObservers) {
        callback.onResult(menu);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:7,代码来源:ChromeActivity.java


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