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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/payments/ui/PaymentOption.java

Issue 2437223002: Revert of Make PaymentOption store a Drawable instead of id (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.payments.ui; 5 package org.chromium.chrome.browser.payments.ui;
6 6
7 import android.graphics.drawable.Drawable;
8
9 import javax.annotation.Nullable; 7 import javax.annotation.Nullable;
10 8
11 /** 9 /**
12 * An option that the user can select, e.g., a shipping option, a shipping addre ss, or a payment 10 * An option that the user can select, e.g., a shipping option, a shipping addre ss, or a payment
13 * method. 11 * method.
14 */ 12 */
15 public class PaymentOption implements Completable { 13 public class PaymentOption implements Completable {
14 /** The placeholder value that indicates the absence of an icon for this opt ion. */
15 public static final int NO_ICON = 0;
16
16 protected boolean mIsComplete; 17 protected boolean mIsComplete;
17 private String mId; 18 private String mId;
18 private Drawable mIcon; 19 private int mIcon;
19 private String[] mLabels = {null, null, null}; 20 private String[] mLabels = {null, null, null};
20 private boolean mIsValid = true; 21 private boolean mIsValid = true;
21 22
22 /** See {@link #PaymentOption(String, String, String, String, int)}. */ 23 /** See {@link #PaymentOption(String, String, String, String, int)}. */
23 public PaymentOption(String id, @Nullable String label, @Nullable String sub label, 24 public PaymentOption(String id, @Nullable String label, @Nullable String sub label, int icon) {
24 @Nullable Drawable icon) {
25 this(id, label, sublabel, null, icon); 25 this(id, label, sublabel, null, icon);
26 } 26 }
27 27
28 /** 28 /**
29 * Constructs a payment option. 29 * Constructs a payment option.
30 * 30 *
31 * @param id The identifier. 31 * @param id The identifier.
32 * @param label The label. 32 * @param label The label.
33 * @param sublabel The optional sublabel. 33 * @param sublabel The optional sublabel.
34 * @param tertiarylabel The optional tertiary label. 34 * @param tertiarylabel The optional tertiary label.
35 * @param icon The drawable icon identifier or null. 35 * @param icon The drawable icon identifier or NO_ICON.
36 */ 36 */
37 public PaymentOption(String id, @Nullable String label, @Nullable String sub label, 37 public PaymentOption(String id, @Nullable String label, @Nullable String sub label,
38 @Nullable String tertiarylabel, @Nullable Drawable icon) { 38 @Nullable String tertiarylabel, int icon) {
39 updateIdentifierLabelsAndIcon(id, label, sublabel, tertiarylabel, icon); 39 updateIdentifierLabelsAndIcon(id, label, sublabel, tertiarylabel, icon);
40 } 40 }
41 41
42 @Override 42 @Override
43 public boolean isComplete() { 43 public boolean isComplete() {
44 return mIsComplete; 44 return mIsComplete;
45 } 45 }
46 46
47 /** 47 /**
48 * The non-human readable identifier for this option. For example, "standard _shipping" or the 48 * The non-human readable identifier for this option. For example, "standard _shipping" or the
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 89
90 /** 90 /**
91 * Updates the identifier, labels, and icon of this option. Called after the user has 91 * Updates the identifier, labels, and icon of this option. Called after the user has
92 * edited this option. 92 * edited this option.
93 * 93 *
94 * @param id The new id to use. Should not be null. 94 * @param id The new id to use. Should not be null.
95 * @param label The new label to use. Should not be null. 95 * @param label The new label to use. Should not be null.
96 * @param sublabel The new sublabel to use. Can be null. 96 * @param sublabel The new sublabel to use. Can be null.
97 * @param tertiarylabel The new tertiary label to use. Can be null. 97 * @param tertiarylabel The new tertiary label to use. Can be null.
98 * @param icon The drawable icon identifier or null. 98 * @param icon The drawable icon identifier or NO_ICON.
99 */ 99 */
100 protected void updateIdentifierLabelsAndIcon( 100 protected void updateIdentifierLabelsAndIcon(
101 String id, String label, @Nullable String sublabel, @Nullable String tertiarylabel, 101 String id, String label, @Nullable String sublabel, @Nullable String tertiarylabel,
102 @Nullable Drawable icon) { 102 int icon) {
103 updateIdentifierAndLabels(id, label, sublabel, tertiarylabel); 103 updateIdentifierAndLabels(id, label, sublabel, tertiarylabel);
104 mIcon = icon; 104 mIcon = icon;
105 } 105 }
106 106
107 /** * The drawable icon for this payment option. */ 107 /**
108 public Drawable getDrawableIcon() { 108 * The identifier for the drawable icon for this payment option. For example , R.drawable.pr_visa
109 * or NO_ICON.
110 */
111 public int getDrawableIconId() {
109 return mIcon; 112 return mIcon;
110 } 113 }
111 114
112 /** 115 /**
113 * Marks this option as invalid. For example, this can be a shipping address that's not served 116 * Marks this option as invalid. For example, this can be a shipping address that's not served
114 * by the merchant. 117 * by the merchant.
115 */ 118 */
116 public void setInvalid() { 119 public void setInvalid() {
117 mIsValid = false; 120 mIsValid = false;
118 } 121 }
119 122
120 /** @return True if this option is valid. */ 123 /** @return True if this option is valid. */
121 public boolean isValid() { 124 public boolean isValid() {
122 return mIsValid; 125 return mIsValid;
123 } 126 }
124 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698