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


Java EditorModel.setCancelCallback方法代码示例

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


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

示例1: 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);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:80,代码来源:ContactEditor.java


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