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

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

Issue 2590583002: [Payment Request] Update the Contacts section after editing address (Closed)
Patch Set: fix providePaymentInformation Created 3 years, 11 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/SectionInformation.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/SectionInformation.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/SectionInformation.java
index f26fcf51c5f96d8d5f7071cf0828c0487ebfd3a9..cda39b2a3dba5c46a6c96bfc0d23c04f888fbeaf 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/SectionInformation.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/SectionInformation.java
@@ -4,11 +4,13 @@
package org.chromium.chrome.browser.payments.ui;
+import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
import javax.annotation.Nullable;
@@ -28,7 +30,7 @@ public class SectionInformation {
public static final int INVALID_SELECTION = -2;
@PaymentRequestUI.DataType private final int mDataType;
- private ArrayList<PaymentOption> mItems;
+ protected ArrayList<PaymentOption> mItems;
private int mSelectedItem;
public String mErrorMessage;
@@ -59,15 +61,7 @@ public class SectionInformation {
public SectionInformation(@PaymentRequestUI.DataType int sectionType, int selection,
Collection<? extends PaymentOption> itemCollection) {
mDataType = sectionType;
-
- if (itemCollection == null || itemCollection.isEmpty()) {
- mSelectedItem = NO_SELECTION;
- mItems = null;
- } else {
- mSelectedItem = selection;
- mItems = new ArrayList<PaymentOption>(itemCollection.size());
- mItems.addAll(itemCollection);
- }
+ updateItemsWithCollection(selection, itemCollection);
}
/**
@@ -193,4 +187,31 @@ public class SectionInformation {
public String getErrorMessage() {
return mErrorMessage;
}
+
+ /**
+ * Returns all the items in the section. Used for testing.
+ *
+ * @return List of items in the section.
+ */
+ @VisibleForTesting
+ public List<PaymentOption> getItemsForTesting() {
+ return mItems;
+ }
+
+ /**
+ * Update the list of items being shown by this section, as well as the selection.
+ *
+ * @param selection The index of the currently selected item.
+ * @param itemCollection The items in the section.
+ */
+ protected void updateItemsWithCollection(
+ int selection, @Nullable Collection<? extends PaymentOption> itemCollection) {
+ if (itemCollection == null || itemCollection.isEmpty()) {
+ mSelectedItem = NO_SELECTION;
+ mItems = null;
+ } else {
+ mSelectedItem = selection;
+ mItems = new ArrayList<>(itemCollection);
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698