Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java |
| index 080d9b642662cde3b31b24a0b179dc571531dfe4..74cc62cea9197c8ec1672d67e722614cfb831b08 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentRequestSection.java |
| @@ -131,6 +131,7 @@ public abstract class PaymentRequestSection extends LinearLayout { |
| private PaymentRequestSection(Context context, String sectionName, SectionDelegate delegate) { |
| super(context); |
| mDelegate = delegate; |
| + setId(R.id.payments_section); |
| setOnClickListener(delegate); |
| setOrientation(HORIZONTAL); |
| setGravity(Gravity.CENTER_VERTICAL); |
| @@ -553,6 +554,11 @@ public abstract class PaymentRequestSection extends LinearLayout { |
| mLabel.setText(stringId); |
| } |
| + /** Set the button identifier for the option. */ |
| + public void setId(int stringId) { |
|
gone
2016/06/21 06:04:39
Don't use stringId -- that implies a string resour
please use gerrit instead
2016/06/22 02:12:30
Done.
|
| + mButton.setId(stringId); |
| + } |
| + |
| private View createButton( |
| GridLayout parent, int rowIndex, boolean isSelected, boolean isEnabled) { |
| Context context = parent.getContext(); |
| @@ -692,14 +698,18 @@ public abstract class PaymentRequestSection extends LinearLayout { |
| for (int i = 0; i < mOptionRows.size(); i++) { |
|
please use gerrit instead
2016/06/20 14:35:53
The split of the single for-loop into two for-loop
gone
2016/06/21 06:04:39
This is fine, but it didn't early return before.
please use gerrit instead
2016/06/22 02:12:30
Done.
|
| OptionRow row = mOptionRows.get(i); |
| - |
| boolean wasClicked = row.mButton == v || row.mLabel == v || row.mIcon == v; |
| - if (row.mOption == null) { |
| - if (wasClicked) mDelegate.onAddPaymentOption(this); |
| - } else { |
| - row.setChecked(wasClicked); |
| + if (row.mOption == null && wasClicked) { |
| + mDelegate.onAddPaymentOption(this); |
| + return; |
| } |
| } |
| + |
| + for (int i = 0; i < mOptionRows.size(); i++) { |
| + OptionRow row = mOptionRows.get(i); |
| + boolean wasClicked = row.mButton == v || row.mLabel == v || row.mIcon == v; |
| + if (row.mOption != null) row.setChecked(wasClicked); |
| + } |
| } |
| @Override |
| @@ -838,13 +848,17 @@ public abstract class PaymentRequestSection extends LinearLayout { |
| // List out known payment options. |
| for (int i = 0; i < information.getSize(); i++) { |
| PaymentOption item = information.getItem(i); |
| - mOptionRows.add(new OptionRow(mOptionLayout, i, item, item == selectedItem)); |
| + OptionRow addRow = new OptionRow(mOptionLayout, i, item, item == selectedItem); |
| + if (i == 0) addRow.setId(R.id.payments_first_radio_button); |
|
gone
2016/06/21 06:04:39
Looks weird because it's only added for testing an
please use gerrit instead
2016/06/22 02:12:30
Done.
|
| + mOptionRows.add(addRow); |
| } |
| // If the user is allowed to add new options, show the button for it. |
| if (information.getAddStringId() != 0) { |
| - mOptionRows.add(new OptionRow(mOptionLayout, information.getSize(), null, false)); |
| - mOptionRows.get(mOptionRows.size() - 1).setLabel(information.getAddStringId()); |
| + OptionRow addRow = new OptionRow(mOptionLayout, information.getSize(), null, false); |
| + addRow.setLabel(information.getAddStringId()); |
| + addRow.setId(R.id.payments_add_option_button); |
| + mOptionRows.add(addRow); |
| } |
| } |