Index: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java |
index 7e15a3aa3a0c7679777eff70241a2317ab5be038..35a7e6e7b86d6cfc0884eb11d261a5290646ff88 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java |
@@ -116,9 +116,17 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View |
Callback<PaymentInformation> checkedCallback); |
/** |
- * Called when the user clicks on the "Add" button for a section. |
+ * Called when the user clicks on the "Add" button for a section. This method returns true |
+ * if this section should be disabled and show a spinner while the added option is being |
gone
2016/06/28 17:30:29
"progress spinny". Now that you have actual spinn
please use gerrit instead
2016/06/29 00:28:45
Done.
|
+ * checked. If this method returns true, the checkedCallback will be invoked with the |
+ * results of the check and updated information. |
+ * |
+ * @param optionType Data being updated. |
+ * @param checkedCallback The callback after an asynchronous check has completed. |
+ * @return True if the option needs to be asynchronously checked. |
*/ |
- void onSectionAddOption(@DataType int optionType); |
+ boolean onSectionAddOption( |
+ @DataType int optionType, Callback<PaymentInformation> checkedCallback); |
/** |
* Called when the user clicks on the “Pay” button. At this point, the UI is disabled and is |
@@ -204,6 +212,7 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View |
private final ViewGroup mFullContainer; |
private final ViewGroup mRequestView; |
private final PaymentRequestUiErrorView mErrorView; |
+ private final Callback<PaymentInformation> mUpdateSectionsCallback; |
gone
2016/06/28 17:30:29
mUpdateSectionCallback?
please use gerrit instead
2016/06/29 00:28:45
It updates all sections, so plural sounds right to
gone
2016/06/29 17:12:45
Ah, misread what it did. [eject]
|
private ScrollView mPaymentContainer; |
private LinearLayout mPaymentContainerLayout; |
@@ -267,6 +276,30 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View |
R.layout.payment_request_error, null); |
mErrorView.initialize(title, origin); |
+ // This callback will be fired if mIsClientCheckingSelection is true. |
+ mUpdateSectionsCallback = new Callback<PaymentInformation>() { |
+ @Override |
+ public void onResult(PaymentInformation result) { |
+ mIsClientCheckingSelection = false; |
+ updateOrderSummarySection(result.getShoppingCart()); |
+ if (mRequestShipping) { |
+ updateSection(TYPE_SHIPPING_ADDRESSES, result.getShippingAddresses()); |
+ updateSection(TYPE_SHIPPING_OPTIONS, result.getShippingOptions()); |
+ } |
+ if (mRequestContactDetails) { |
+ updateSection(TYPE_CONTACT_DETAILS, result.getContactDetails()); |
+ } |
+ updateSection(TYPE_PAYMENT_METHODS, result.getPaymentMethods()); |
+ if (mShippingAddressSectionInformation.getSelectedItem() == null) { |
+ mShippingAddressSection.setDisplayMode( |
+ PaymentRequestSection.DISPLAY_MODE_FOCUSED); |
+ } else { |
+ expand(null); |
+ } |
+ updatePayButtonEnabled(); |
+ } |
+ }; |
+ |
mRequestView = |
(ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.payment_request, null); |
prepareRequestView(activity, title, origin); |
@@ -526,29 +559,7 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View |
&& mShippingAddressSectionInformation.getSelectedItem() != option) { |
mShippingAddressSectionInformation.setSelectedItem(option); |
mIsClientCheckingSelection = mClient.onSectionOptionSelected( |
- TYPE_SHIPPING_ADDRESSES, option, new Callback<PaymentInformation>() { |
- // The callback will be fired only if mIsClientCheckingSelection is true. |
- @Override |
- public void onResult(PaymentInformation result) { |
- mIsClientCheckingSelection = false; |
- updateOrderSummarySection(result.getShoppingCart()); |
- if (mRequestShipping) { |
- updateSection(TYPE_SHIPPING_ADDRESSES, |
- result.getShippingAddresses()); |
- updateSection(TYPE_SHIPPING_OPTIONS, result.getShippingOptions()); |
- } |
- if (mRequestContactDetails) { |
- updateSection(TYPE_CONTACT_DETAILS, result.getContactDetails()); |
- } |
- updateSection(TYPE_PAYMENT_METHODS, result.getPaymentMethods()); |
- if (mShippingAddressSectionInformation.getSelectedItem() == null) { |
- section.setDisplayMode(PaymentRequestSection.DISPLAY_MODE_FOCUSED); |
- } else { |
- expand(null); |
- } |
- updatePayButtonEnabled(); |
- } |
- }); |
+ TYPE_SHIPPING_ADDRESSES, option, mUpdateSectionsCallback); |
} else if (section == mShippingOptionSection) { |
mShippingOptionsSectionInformation.setSelectedItem(option); |
mClient.onSectionOptionSelected(TYPE_SHIPPING_OPTIONS, option, null); |
@@ -574,12 +585,20 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View |
assert section != mShippingOptionSection; |
if (section == mShippingAddressSection) { |
- mClient.onSectionAddOption(TYPE_SHIPPING_ADDRESSES); |
+ mIsClientCheckingSelection = |
+ mClient.onSectionAddOption(TYPE_SHIPPING_ADDRESSES, mUpdateSectionsCallback); |
} else if (section == mContactDetailsSection) { |
- mClient.onSectionAddOption(TYPE_CONTACT_DETAILS); |
+ mClient.onSectionAddOption(TYPE_CONTACT_DETAILS, null); |
} else if (section == mPaymentMethodSection) { |
- mClient.onSectionAddOption(TYPE_PAYMENT_METHODS); |
+ mClient.onSectionAddOption(TYPE_PAYMENT_METHODS, null); |
+ } |
+ |
+ if (mIsClientCheckingSelection) { |
+ startSectionResizeAnimation(); |
+ section.setDisplayMode(PaymentRequestSection.DISPLAY_MODE_CHECKING); |
} |
+ |
+ updatePayButtonEnabled(); |
} |
/** @return The editor user interface. */ |
@@ -1012,6 +1031,11 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View |
} |
@VisibleForTesting |
+ public ViewGroup getShippingSummarySectionForTest() { |
+ return mShippingSummarySection; |
+ } |
+ |
+ @VisibleForTesting |
public ViewGroup getShippingAddressSectionForTest() { |
return mShippingAddressSection; |
} |