Bug 963046 - Use Picasso to load images in PanelListRow and PanelGridItemView (r=margaret)
authorLucas Rocha <lucasr@mozilla.com>
Thu, 06 Feb 2014 21:06:39 +0000
changeset 184623 4577b30df743032f4aefb60d2c76422183451c80
parent 184622 b85c89584af9d8c3b4e90294d4af80c9a65d718c
child 184624 f9c1a27f64bbff197dd42d4c5bad3e39f07e35e3
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs963046
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 963046 - Use Picasso to load images in PanelListRow and PanelGridItemView (r=margaret)
mobile/android/base/home/PanelGridItemView.java
mobile/android/base/home/PanelListRow.java
--- a/mobile/android/base/home/PanelGridItemView.java
+++ b/mobile/android/base/home/PanelGridItemView.java
@@ -3,20 +3,22 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.home;
 
 import java.net.MalformedURLException;
 import java.net.URL;
 
-import org.mozilla.gecko.db.BrowserContract.URLColumns;
+import org.mozilla.gecko.db.BrowserContract.HomeItems;
 import org.mozilla.gecko.favicons.Favicons;
 import org.mozilla.gecko.R;
 
+import com.squareup.picasso.Picasso;
+
 import android.content.Context;
 import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.graphics.Color;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.util.Log;
@@ -42,10 +44,17 @@ public class PanelGridItemView extends F
 
     public PanelGridItemView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
 
         LayoutInflater.from(context).inflate(R.layout.panel_grid_item_view, this);
         mThumbnailView = (ImageView) findViewById(R.id.image);
     }
 
-    public void updateFromCursor(Cursor cursor) { }
+    public void updateFromCursor(Cursor cursor) {
+        int imageIndex = cursor.getColumnIndexOrThrow(HomeItems.IMAGE_URL);
+        final String imageUrl = cursor.getString(imageIndex);
+
+        Picasso.with(getContext())
+               .load(imageUrl)
+               .into(mThumbnailView);
+    }
 }
--- a/mobile/android/base/home/PanelListRow.java
+++ b/mobile/android/base/home/PanelListRow.java
@@ -10,38 +10,40 @@ import org.mozilla.gecko.favicons.Favico
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.db.BrowserContract.HomeItems;
 import org.mozilla.gecko.favicons.OnFaviconLoadedListener;
 import org.mozilla.gecko.util.ThreadUtils;
 import org.mozilla.gecko.widget.FaviconView;
 
+import com.squareup.picasso.Picasso;
+
 import android.content.Context;
 import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.View;
+import android.widget.ImageView;
 
 import java.lang.ref.WeakReference;
 
 public class PanelListRow extends TwoLineRow {
 
+    private final ImageView mIcon;
+
     public PanelListRow(Context context) {
         this(context, null);
     }
 
     public PanelListRow(Context context, AttributeSet attrs) {
         super(context, attrs);
 
-        // XXX: Never show icon for now. We have to figure out
-        // how the images will be passed through the cursor.
-        final View iconView = findViewById(R.id.icon);
-        iconView.setVisibility(View.GONE);
+        mIcon = (ImageView) findViewById(R.id.icon);
     }
 
     @Override
     public void updateFromCursor(Cursor cursor) {
         if (cursor == null) {
             return;
         }
 
@@ -50,10 +52,18 @@ public class PanelListRow extends TwoLin
 
         int titleIndex = cursor.getColumnIndexOrThrow(HomeItems.TITLE);
         final String title = cursor.getString(titleIndex);
         setPrimaryText(title);
 
         int urlIndex = cursor.getColumnIndexOrThrow(HomeItems.URL);
         final String url = cursor.getString(urlIndex);
         setSecondaryText(url);
+
+        int imageIndex = cursor.getColumnIndexOrThrow(HomeItems.IMAGE_URL);
+        final String imageUrl = cursor.getString(imageIndex);
+
+        Picasso.with(getContext())
+               .load(imageUrl)
+               .error(R.drawable.favicon)
+               .into(mIcon);
     }
 }