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

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

Issue 2436883002: Make PaymentOption store a Drawable instead of id (Closed)
Patch Set: Fix presubmit warning 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 side-by-side diff with in-line comments
Download patch
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 315ceb17d4cae1950b67aeb4261ab8647f72d10c..3f2e5608bdbf15ee2160c6f309c433ef69a7b7fd 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
@@ -8,6 +8,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Typeface;
+import android.graphics.drawable.Drawable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.TextUtils.TruncateAt;
@@ -135,7 +136,7 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
private TextView mSummaryLeftTextView;
private TextView mSummaryRightTextView;
- private int mLogoResourceId;
+ private Drawable mLogo;
private boolean mIsSummaryAllowed = true;
/**
@@ -173,12 +174,12 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
/**
* Sets what logo should be displayed.
*
- * @param resourceId ID of the logo to display.
+ * @param resource The logo to display.
*/
- protected void setLogoResource(int resourceId) {
+ protected void setLogoDrawable(Drawable logo) {
assert isLogoNecessary();
- mLogoResourceId = resourceId;
- mLogoView.setImageResource(resourceId);
+ mLogo = logo;
+ mLogoView.setImageDrawable(mLogo);
}
@Override
@@ -411,7 +412,7 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
// Update whether the logo is displayed.
if (mLogoView != null) {
- boolean show = mLogoResourceId != 0 && mDisplayMode != DISPLAY_MODE_FOCUSED;
+ boolean show = mLogo != null && mDisplayMode != DISPLAY_MODE_FOCUSED;
mLogoView.setVisibility(show ? VISIBLE : GONE);
}
@@ -718,7 +719,7 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
public OptionRow(GridLayout parent, int rowIndex, int rowType, PaymentOption item,
boolean isSelected) {
- boolean iconExists = item != null && item.getDrawableIconId() != 0;
+ boolean iconExists = item != null && item.getDrawableIcon() != null;
boolean isEnabled = item != null && item.isValid();
mRowType = rowType;
mOption = item;
@@ -871,7 +872,7 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
ImageView icon = new ImageView(parent.getContext());
icon.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
icon.setBackgroundResource(R.drawable.payments_ui_logo_bg);
- icon.setImageResource(mOption.getDrawableIconId());
+ icon.setImageDrawable(mOption.getDrawableIcon());
icon.setMaxWidth(mIconMaxWidth);
// The icon floats to the right of everything.
@@ -1053,11 +1054,11 @@ public abstract class PaymentRequestSection extends LinearLayout implements View
private void updateSelectedItem(PaymentOption selectedItem) {
if (selectedItem == null) {
- setLogoResource(0);
+ setLogoDrawable(null);
setIsSummaryAllowed(false);
setSummaryText(null, null);
} else {
- setLogoResource(selectedItem.getDrawableIconId());
+ setLogoDrawable(selectedItem.getDrawableIcon());
setSummaryText(convertOptionToString(selectedItem, false), null);
}

Powered by Google App Engine
This is Rietveld 408576698