Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestUI.java

Issue 1904553003: Java implementation of PaymentRequest mojo service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 6d939b74e610e67d4a019611cac1148fc463ec7f..1e6908e642b7d96d5894da20cb200ca9e2316bac 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
@@ -25,7 +25,7 @@ import org.chromium.base.Callback;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.widget.AlwaysDismissedDialog;
-import java.util.ArrayList;
+import java.util.List;
/**
* The PaymentRequest UI.
@@ -43,7 +43,7 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
/**
* Asynchronously returns the full bill. The last line item is the total.
*/
- void getLineItems(Callback<ArrayList<LineItem>> callback);
+ void getLineItems(Callback<List<LineItem>> callback);
/**
* Asynchronously returns the full list of available shipping addresses.
@@ -134,7 +134,7 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
private View mSelectedSectionLabel;
private ViewGroup mSelectedSection;
- private ArrayList<LineItem> mLineItems;
+ private List<LineItem> mLineItems;
private SectionInformation mPaymentMethodsSection;
private SectionInformation mShippingAddressesSection;
private SectionInformation mShippingOptionsSection;
@@ -250,6 +250,8 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
mPaymentMethodsSection = result.getPaymentMethods();
updateSection(mPaymentMethods, mPaymentMethodsSection, null);
+
+ updatePayButtonEnabled();
}
});
}
@@ -313,7 +315,7 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
*
* @param lineItems The full bill. The last line item is the total.
*/
- public void updateLineItems(ArrayList<LineItem> lineItems) {
+ public void updateLineItems(List<LineItem> lineItems) {
mLineItems = lineItems;
mOrderSummary.removeAllViews();
@@ -329,9 +331,8 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
if (mSelectedSection != mOrderSummary) return;
- for (LineItem item : lineItems) {
- if (item == total) return;
- mOrderSummary.addView(buildLineItem(item));
+ for (int i = 0; i < lineItems.size() - 1; i++) {
+ mOrderSummary.addView(buildLineItem(lineItems.get(i)));
}
}
@@ -482,8 +483,7 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
? null : mShippingAddressesSection.getSelectedItem(),
mShippingOptionsSection == null
? null : mShippingOptionsSection.getSelectedItem(),
- mPaymentMethodsSection == null
- ? null : mPaymentMethodsSection.getSelectedItem());
+ mPaymentMethodsSection.getSelectedItem());
} else if (v == mEditButton) {
if (mSelectedSection == null) {
expand(mOrderSummaryLabel, mOrderSummary);
@@ -502,6 +502,22 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
mClient.onPaymentMethodChanged(tag.getSection().getSelectedItem());
}
}
+
+ updatePayButtonEnabled();
+ }
+
+ private void updatePayButtonEnabled() {
+ if (mRequestShipping) {
+ mPayButton.setEnabled(mShippingAddressesSection != null
+ && mShippingAddressesSection.getSelectedItem() != null
+ && mShippingOptionsSection != null
+ && mShippingOptionsSection.getSelectedItem() != null
+ && mPaymentMethodsSection != null
+ && mPaymentMethodsSection.getSelectedItem() != null);
+ } else {
+ mPayButton.setEnabled(mPaymentMethodsSection != null
+ && mPaymentMethodsSection.getSelectedItem() != null);
+ }
}
private void expand(View sectionLabel, ViewGroup section) {
@@ -562,9 +578,9 @@ public class PaymentRequestUI implements DialogInterface.OnDismissListener, View
}
if (mSelectedSection == mOrderSummary) {
- mClient.getLineItems(new Callback<ArrayList<LineItem>>() {
+ mClient.getLineItems(new Callback<List<LineItem>>() {
@Override
- public void onResult(ArrayList<LineItem> result) {
+ public void onResult(List<LineItem> result) {
updateLineItems(result);
}
});

Powered by Google App Engine
This is Rietveld 408576698