當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。