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


Java Callback类代码示例

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


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

示例1: getSectionInformation

import org.chromium.base.Callback; //导入依赖的package包/类
@Override
public void getSectionInformation(@PaymentRequestUI.DataType final int optionType,
        final Callback<SectionInformation> callback) {
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) {
                callback.onResult(mShippingAddressesSection);
            } else if (optionType == PaymentRequestUI.TYPE_SHIPPING_OPTIONS) {
                callback.onResult(mUiShippingOptions);
            } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) {
                callback.onResult(mContactSection);
            } else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) {
                assert mPaymentMethodsSection != null;
                callback.onResult(mPaymentMethodsSection);
            }
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:20,代码来源:PaymentRequestImpl.java

示例2: onSectionEditOption

import org.chromium.base.Callback; //导入依赖的package包/类
@Override
@PaymentRequestUI.SelectionResult
public int onSectionEditOption(@PaymentRequestUI.DataType int optionType, PaymentOption option,
        Callback<PaymentInformation> callback) {
    if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) {
        assert option instanceof AutofillAddress;
        editAddress((AutofillAddress) option);
        mPaymentInformationCallback = callback;
        return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION;
    }

    if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) {
        assert option instanceof AutofillContact;
        editContact((AutofillContact) option);
        return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH;
    }

    if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) {
        assert option instanceof AutofillPaymentInstrument;
        editCard((AutofillPaymentInstrument) option);
        return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH;
    }

    assert false;
    return PaymentRequestUI.SELECTION_RESULT_NONE;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:27,代码来源:PaymentRequestImpl.java

示例3: onSectionAddOption

import org.chromium.base.Callback; //导入依赖的package包/类
@Override
@PaymentRequestUI.SelectionResult
public int onSectionAddOption(
        @PaymentRequestUI.DataType int optionType, Callback<PaymentInformation> callback) {
    if (optionType == PaymentRequestUI.TYPE_SHIPPING_ADDRESSES) {
        editAddress(null);
        mPaymentInformationCallback = callback;
        // Log the add of shipping address.
        mJourneyLogger.incrementSelectionAdds(
                PaymentRequestJourneyLogger.SECTION_SHIPPING_ADDRESS);
        return PaymentRequestUI.SELECTION_RESULT_ASYNCHRONOUS_VALIDATION;
    } else if (optionType == PaymentRequestUI.TYPE_CONTACT_DETAILS) {
        editContact(null);
        // Log the add of contact info.
        mJourneyLogger.incrementSelectionAdds(PaymentRequestJourneyLogger.SECTION_CONTACT_INFO);
        return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH;
    } else if (optionType == PaymentRequestUI.TYPE_PAYMENT_METHODS) {
        editCard(null);
        // Log the add of credit card.
        mJourneyLogger.incrementSelectionAdds(PaymentRequestJourneyLogger.SECTION_CREDIT_CARDS);
        return PaymentRequestUI.SELECTION_RESULT_EDITOR_LAUNCH;
    }

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

示例4: editAddress

import org.chromium.base.Callback; //导入依赖的package包/类
private void editAddress(final AutofillAddress toEdit) {
    if (toEdit != null) {
        // Log the edit of a shipping address.
        mJourneyLogger.incrementSelectionEdits(
                PaymentRequestJourneyLogger.SECTION_SHIPPING_ADDRESS);
    }
    mAddressEditor.edit(toEdit, new Callback<AutofillAddress>() {
        @Override
        public void onResult(AutofillAddress completeAddress) {
            if (mUI == null) return;

            if (completeAddress == null) {
                mShippingAddressesSection.setSelectedItemIndex(SectionInformation.NO_SELECTION);
                providePaymentInformation();
            } else {
                if (toEdit == null) mShippingAddressesSection.addAndSelectItem(completeAddress);
                mCardEditor.updateBillingAddressIfComplete(completeAddress);
                mClient.onShippingAddressChange(completeAddress.toPaymentAddress());
            }
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:23,代码来源:PaymentRequestImpl.java

示例5: editContact

import org.chromium.base.Callback; //导入依赖的package包/类
private void editContact(final AutofillContact toEdit) {
    if (toEdit != null) {
        // Log the edit of a contact info.
        mJourneyLogger.incrementSelectionEdits(
                PaymentRequestJourneyLogger.SECTION_CONTACT_INFO);
    }
    mContactEditor.edit(toEdit, new Callback<AutofillContact>() {
        @Override
        public void onResult(AutofillContact completeContact) {
            if (mUI == null) return;

            if (completeContact == null) {
                mContactSection.setSelectedItemIndex(SectionInformation.NO_SELECTION);
            } else if (toEdit == null) {
                mContactSection.addAndSelectItem(completeContact);
            }

            mUI.updateSection(PaymentRequestUI.TYPE_CONTACT_DETAILS, mContactSection);
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:PaymentRequestImpl.java

示例6: editCard

import org.chromium.base.Callback; //导入依赖的package包/类
private void editCard(final AutofillPaymentInstrument toEdit) {
    if (toEdit != null) {
        // Log the edit of a credit card.
        mJourneyLogger.incrementSelectionEdits(
                PaymentRequestJourneyLogger.SECTION_CREDIT_CARDS);
    }
    mCardEditor.edit(toEdit, new Callback<AutofillPaymentInstrument>() {
        @Override
        public void onResult(AutofillPaymentInstrument completeCard) {
            if (mUI == null) return;

            if (completeCard == null) {
                mPaymentMethodsSection.setSelectedItemIndex(SectionInformation.NO_SELECTION);
            } else if (toEdit == null) {
                mPaymentMethodsSection.addAndSelectItem(completeCard);
            }

            mUI.updateSection(PaymentRequestUI.TYPE_PAYMENT_METHODS, mPaymentMethodsSection);
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:PaymentRequestImpl.java

示例7: 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

示例8: 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

示例9: 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.
 */
public static void isUserManaged(String email, final Callback<Boolean> callback) {
    if (nativeShouldLoadPolicyForUser(email)) {
        nativeIsUserManaged(email, callback);
    } else {
        // Although we know the result immediately, the caller may not be able to handle the
        // callback being executed during this method call. So we post the callback on the
        // looper.
        ThreadUtils.postOnUiThread(new Runnable() {
            @Override
            public void run() {
                callback.onResult(false);
            }
        });
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:21,代码来源:SigninManager.java

示例10: showConfirmSigninPagePreviousAccountCheck

import org.chromium.base.Callback; //导入依赖的package包/类
private void showConfirmSigninPagePreviousAccountCheck() {
    String accountName = getSelectedAccountName();
    ConfirmSyncDataStateMachine.run(PrefServiceBridge.getInstance().getSyncLastAccountName(),
            accountName, ImportSyncType.PREVIOUS_DATA_FOUND,
            mDelegate.getFragmentManager(),
            getContext(), new ConfirmImportSyncDataDialog.Listener() {
                @Override
                public void onConfirm(boolean wipeData) {
                    SigninManager.wipeSyncUserDataIfRequired(wipeData)
                            .then(new Callback<Void>() {
                                @Override
                                public void onResult(Void v) {
                                    showConfirmSigninPage();
                                }
                            });
                }

                @Override
                public void onCancel() {
                    setButtonsEnabled(true);
                }
            });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:AccountSigninView.java

示例11: onMostVisitedURLsAvailable

import org.chromium.base.Callback; //导入依赖的package包/类
@Override
public void onMostVisitedURLsAvailable(final String[] titles, final String[] urls,
        final String[] whitelistIconPaths, final int[] sources) {
    Set<String> urlSet = new HashSet<>(Arrays.asList(urls));

    // If no Most Visited items have been built yet, this is the initial load. Build the Most
    // Visited items immediately so the layout is stable during initial rendering. They can be
    // replaced later if there are offline urls, but that will not affect the layout widths and
    // heights. A stable layout enables reliable scroll position initialization.
    if (!mHasReceivedMostVisitedSites) {
        buildMostVisitedItems(titles, urls, whitelistIconPaths, null, sources);
    }

    // TODO(https://crbug.com/607573): We should show offline-available content in a nonblocking
    // way so that responsiveness of the NTP does not depend on ready availability of offline
    // pages.
    mManager.getUrlsAvailableOffline(urlSet, new Callback<Set<String>>() {
        @Override
        public void onResult(Set<String> offlineUrls) {
            buildMostVisitedItems(titles, urls, whitelistIconPaths, offlineUrls, sources);
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:NewTabPageView.java

示例12: createGsaClientAndConnect

import org.chromium.base.Callback; //导入依赖的package包/类
private void createGsaClientAndConnect(Context context) {
    Callback<Bundle> onMessageReceived = new Callback<Bundle>() {
        @Override
        public void onResult(Bundle result) {
            boolean supportsBroadcast =
                    result.getBoolean(KEY_SSB_BROADCASTS_ACCOUNT_CHANGE_TO_CHROME);
            if (supportsBroadcast) notifyGsaBroadcastsAccountChanges();
            // If GSA doesn't support the broadcast, we connect several times to the service per
            // Chrome session (since there is a disconnect() call in
            // ChromeActivity#onStopWithNative()). Only record the histogram once per startup to
            // avoid skewing the results.
            if (!mAlreadyReportedHistogram) {
                RecordHistogram.recordBooleanHistogram(
                        "Search.GsaBroadcastsAccountChanges", supportsBroadcast);
                mAlreadyReportedHistogram = true;
            }
        }
    };
    mClient = new GSAServiceClient(context, onMessageReceived);
    mClient.connect();
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:22,代码来源:GSAAccountChangeListener.java

示例13: runAsync

import org.chromium.base.Callback; //导入依赖的package包/类
@Override
public void runAsync(final TaskQueue queue) {
    WebsitePreferenceBridge.fetchLocalStorageInfo(new Callback<HashMap>() {
        @Override
        public void onResult(HashMap result) {
            for (Object o : result.entrySet()) {
                @SuppressWarnings("unchecked")
                Map.Entry<String, LocalStorageInfo> entry =
                        (Map.Entry<String, LocalStorageInfo>) o;
                WebsiteAddress address = WebsiteAddress.create(entry.getKey());
                if (address == null) continue;
                findOrCreateSite(address, null).setLocalStorageInfo(entry.getValue());
            }
            queue.next();
        }
    });
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:18,代码来源:WebsitePermissionsFetcher.java

示例14: shareImageDirectly

import org.chromium.base.Callback; //导入依赖的package包/类
/**
 * Share image triggered with the current context menu directly with a specific app.
 * @param name The {@link ComponentName} of the app to share the image directly with.
 */
public void shareImageDirectly(@Nullable final ComponentName name) {
    if (mNativeContextMenuHelper == 0) return;
    Callback<byte[]> callback = new Callback<byte[]>() {
        @Override
        public void onResult(byte[] result) {
            WebContents webContents = nativeGetJavaWebContents(mNativeContextMenuHelper);
            WindowAndroid windowAndroid = webContents.getTopLevelNativeWindow();

            Activity activity = windowAndroid.getActivity().get();
            if (activity == null) return;

            ShareHelper.shareImage(activity, result, name);
        }
    };
    nativeRetrieveImage(mNativeContextMenuHelper, callback, MAX_SHARE_DIMEN_PX);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:21,代码来源:ContextMenuHelper.java

示例15: start

import org.chromium.base.Callback; //导入依赖的package包/类
/**
 * Triggers to the native VariationsService that the application has entered the foreground.
 */
public void start(Context context) {
    // If |mRestrictModeFetchStarted| is true and |mRestrictMode| is null, then async
    // initializationn is in progress and nativeStartVariationsSession() will be called
    // when it completes.
    if (mRestrictModeFetchStarted && mRestrictMode == null) {
        return;
    }

    mRestrictModeFetchStarted = true;
    getRestrictModeValue(context, new Callback<String>() {
        @Override
        public void onResult(String restrictMode) {
            nativeStartVariationsSession(mRestrictMode);
        }
    });
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:20,代码来源:VariationsSession.java


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