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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/MostVisitedLayout.java

Issue 2651673010: 🍝🏠 Refactor MostVisited UI management, extract it for reuse in Home. (Closed)
Patch Set: Rebase. Created 3 years, 10 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/ntp/MostVisitedLayout.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/MostVisitedLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/MostVisitedLayout.java
index 9ec2ef691040d6a6d8d122ecb69bbc55f36c01c1..47c99aa95f4363766c8b92d5ba483e642927c156 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/MostVisitedLayout.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/MostVisitedLayout.java
@@ -6,6 +6,8 @@ package org.chromium.chrome.browser.ntp;
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.drawable.Drawable;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
@@ -66,6 +68,22 @@ public class MostVisitedLayout extends FrameLayout {
forceLayout();
}
+ /**
+ * Sets a new icon on the child view with a matching URL.
+ * @param url The site URL of the child tile view.
+ * @param icon The icon to set.
+ */
+ public void updateIconView(String url, Drawable icon) {
+ int childCount = getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ MostVisitedItemView tileView = (MostVisitedItemView) getChildAt(i);
+ if (TextUtils.equals(url, tileView.getUrl())) {
+ tileView.setIcon(icon);
+ break;
+ }
+ }
+ }
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int totalWidth = resolveSize(mMaxWidth, widthMeasureSpec);

Powered by Google App Engine
This is Rietveld 408576698