本文整理汇总了Java中org.chromium.chrome.browser.payments.ui.EditorModel类的典型用法代码示例。如果您正苦于以下问题:Java EditorModel类的具体用法?Java EditorModel怎么用?Java EditorModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EditorModel类属于org.chromium.chrome.browser.payments.ui包,在下文中一共展示了EditorModel类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSaveCardCheckbox
import org.chromium.chrome.browser.payments.ui.EditorModel; //导入依赖的package包/类
/** Adds the "save this card" checkbox to the editor. */
private void addSaveCardCheckbox(EditorModel editor) {
if (mSaveCardCheckbox == null) {
mSaveCardCheckbox = EditorFieldModel.createCheckbox(
mContext.getString(R.string.payments_save_card_to_device_checkbox),
CHECK_SAVE_CARD_TO_DEVICE);
}
editor.addField(mSaveCardCheckbox);
}
示例2: addAddressTextFieldsToEditor
import org.chromium.chrome.browser.payments.ui.EditorModel; //导入依赖的package包/类
/**
* Adds text fields to the editor model based on the country and language code of the profile
* that's being edited.
*/
private void addAddressTextFieldsToEditor(
EditorModel container, String countryCode, String languageCode) {
mAddressUiComponents = mAutofillProfileBridge.getAddressUiComponents(countryCode,
languageCode);
for (int i = 0; i < mAddressUiComponents.size(); i++) {
AddressUiComponent component = mAddressUiComponents.get(i);
// The country field is a dropdown, so there's no need to add a text field for it.
if (component.id == AddressField.COUNTRY) continue;
EditorFieldModel field = mAddressFields.get(component.id);
// Labels depend on country, e.g., state is called province in some countries. These are
// already localized.
field.setLabel(component.label);
field.setIsFullLine(component.isFullLine);
// Libaddressinput formats do not always require the full name (RECIPIENT), but
// PaymentRequest does.
if (component.isRequired || component.id == AddressField.RECIPIENT) {
field.setRequiredErrorMessage(mContext.getString(
R.string.payments_field_required_validation_message));
} else {
field.setRequiredErrorMessage(null);
}
container.addField(field);
}
}
示例3: addBillingAddressDropdown
import org.chromium.chrome.browser.payments.ui.EditorModel; //导入依赖的package包/类
/**
* Adds the billing address dropdown to the editor with the following items.
*
* | "select" |
* | complete address 1 |
* | complete address 2 |
* ...
* | complete address n |
* | "add address" |
*/
private void addBillingAddressDropdown(EditorModel editor, final CreditCard card) {
final List<DropdownKeyValue> billingAddresses = new ArrayList<>();
for (int i = 0; i < mProfilesForBillingAddress.size(); ++i) {
billingAddresses.add(new DropdownKeyValue(mProfilesForBillingAddress.get(i).getGUID(),
mProfilesForBillingAddress.get(i).getLabel()));
}
billingAddresses.add(new DropdownKeyValue(BILLING_ADDRESS_ADD_NEW,
mContext.getString(R.string.autofill_create_profile)));
// Don't cache the billing address dropdown, because the user may have added or removed
// profiles. Also pass the "Select" dropdown item as a hint to the dropdown constructor.
mBillingAddressField = EditorFieldModel.createDropdown(
mContext.getString(R.string.autofill_credit_card_editor_billing_address),
billingAddresses, mContext.getString(R.string.select));
// The billing address is required.
mBillingAddressField.setRequiredErrorMessage(
mContext.getString(R.string.payments_field_required_validation_message));
mBillingAddressField.setDropdownCallback(new Callback<Pair<String, Runnable>>() {
@Override
public void onResult(final Pair<String, Runnable> eventData) {
if (!BILLING_ADDRESS_ADD_NEW.equals(eventData.first)) {
if (mObserverForTest != null) {
mObserverForTest.onPaymentRequestServiceBillingAddressChangeProcessed();
}
return;
}
mAddressEditor.edit(null, new Callback<AutofillAddress>() {
@Override
public void onResult(AutofillAddress billingAddress) {
if (billingAddress == null) {
// User has cancelled the address editor.
mBillingAddressField.setValue(null);
} else {
// User has added a new complete address. Add it to the top of the
// dropdown.
mProfilesForBillingAddress.add(billingAddress.getProfile());
billingAddresses.add(
0, new DropdownKeyValue(billingAddress.getIdentifier(),
billingAddress.getSublabel()));
mBillingAddressField.setDropdownKeyValues(billingAddresses);
mBillingAddressField.setValue(billingAddress.getIdentifier());
}
// Let the card editor UI re-read the model and re-create UI elements.
mHandler.post(eventData.second);
}
});
}
});
if (mBillingAddressField.getDropdownKeys().contains(card.getBillingAddressId())) {
mBillingAddressField.setValue(card.getBillingAddressId());
}
editor.addField(mBillingAddressField);
}
示例4: edit
import org.chromium.chrome.browser.payments.ui.EditorModel; //导入依赖的package包/类
@Override
public void edit(@Nullable AutofillContact toEdit, final Callback<AutofillContact> callback) {
super.edit(toEdit, callback);
final AutofillContact contact = toEdit == null
? new AutofillContact(new AutofillProfile(), null, null, null, false) : toEdit;
final EditorFieldModel nameField = mRequestPayerName
? EditorFieldModel.createTextInput(EditorFieldModel.INPUT_TYPE_HINT_PERSON_NAME,
mContext.getString(R.string.payments_name_field_in_contact_details),
mPayerNames, null, null,
mContext.getString(R.string.payments_field_required_validation_message),
null, contact.getPayerName())
: null;
final EditorFieldModel phoneField = mRequestPayerPhone
? EditorFieldModel.createTextInput(EditorFieldModel.INPUT_TYPE_HINT_PHONE,
mContext.getString(R.string.autofill_profile_editor_phone_number),
mPhoneNumbers, getPhoneValidator(), null,
mContext.getString(R.string.payments_field_required_validation_message),
mContext.getString(R.string.payments_phone_invalid_validation_message),
contact.getPayerPhone())
: null;
final EditorFieldModel emailField = mRequestPayerEmail
? EditorFieldModel.createTextInput(EditorFieldModel.INPUT_TYPE_HINT_EMAIL,
mContext.getString(R.string.autofill_profile_editor_email_address),
mEmailAddresses, getEmailValidator(), null,
mContext.getString(R.string.payments_field_required_validation_message),
mContext.getString(R.string.payments_email_invalid_validation_message),
contact.getPayerEmail())
: null;
EditorModel editor = new EditorModel(
mContext.getString(toEdit == null ? R.string.payments_add_contact_details_label
: R.string.payments_edit_contact_details_label));
if (nameField != null) editor.addField(nameField);
if (phoneField != null) editor.addField(phoneField);
if (emailField != null) editor.addField(emailField);
editor.setCancelCallback(new Runnable() {
@Override
public void run() {
callback.onResult(null);
}
});
editor.setDoneCallback(new Runnable() {
@Override
public void run() {
String name = null;
String phone = null;
String email = null;
AutofillProfile profile = contact.getProfile();
if (nameField != null) {
name = nameField.getValue().toString();
profile.setFullName(name);
}
if (phoneField != null) {
phone = phoneField.getValue().toString();
profile.setPhoneNumber(phone);
}
if (emailField != null) {
email = emailField.getValue().toString();
profile.setEmailAddress(email);
}
profile.setGUID(PersonalDataManager.getInstance().setProfileToLocal(profile));
profile.setIsLocal(true);
contact.completeContact(profile.getGUID(), name, phone, email);
callback.onResult(contact);
}
});
mEditorView.show(editor);
}