Bug 931843 - Part 0: Tidy up constants in TopSitesGridItemView. r=kats, a=bajaj
authorRichard Newman <rnewman@mozilla.com>
Mon, 04 Nov 2013 11:48:57 -0800
changeset 167372 132cf341abb6ad1b80c1ceb4ffafb5124d2bc0c0
parent 167371 72614b4ccdfa092de4fdd5ebbf6a4b35095e1e03
child 167373 51b568709bb3aa287704fe8446331cbbafc15dd3
push id428
push userbbajaj@mozilla.com
push dateTue, 28 Jan 2014 00:16:25 +0000
treeherdermozilla-release@cd72a7ff3a75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats, bajaj
bugs931843
milestone27.0a2
Bug 931843 - Part 0: Tidy up constants in TopSitesGridItemView. r=kats, a=bajaj
mobile/android/base/home/TopSitesGridItemView.java
--- a/mobile/android/base/home/TopSitesGridItemView.java
+++ b/mobile/android/base/home/TopSitesGridItemView.java
@@ -25,16 +25,20 @@ import android.widget.TextView;
  * This is denoted by the empty state.
  */
 public class TopSitesGridItemView extends RelativeLayout {
     private static final String LOGTAG = "GeckoTopSitesGridItemView";
 
     // Empty state, to denote there is no valid url.
     private static final int[] STATE_EMPTY = { android.R.attr.state_empty };
 
+    private static final ScaleType SCALE_TYPE_FAVICON   = ScaleType.CENTER;
+    private static final ScaleType SCALE_TYPE_RESOURCE  = ScaleType.CENTER;
+    private static final ScaleType SCALE_TYPE_THUMBNAIL = ScaleType.CENTER_CROP;
+    
     // Child views.
     private final TextView mTitleView;
     private final ImageView mThumbnailView;
 
     // Data backing this view.
     private String mTitle;
     private String mUrl;
     private String mFaviconURL;
@@ -184,17 +188,17 @@ public class TopSitesGridItemView extend
     }
 
     /**
      * Display the thumbnail from a resource.
      *
      * @param resId Resource ID of the drawable to show.
      */
     public void displayThumbnail(int resId) {
-        mThumbnailView.setScaleType(ScaleType.CENTER);
+        mThumbnailView.setScaleType(SCALE_TYPE_RESOURCE);
         mThumbnailView.setImageResource(resId);
         mThumbnailView.setBackgroundColor(0x0);
     }
 
     /**
      * Display the thumbnail from a bitmap.
      *
      * @param thumbnail The bitmap to show as thumbnail.
@@ -203,17 +207,17 @@ public class TopSitesGridItemView extend
         if (thumbnail == null) {
             // Show a favicon based view instead.
             displayThumbnail(R.drawable.favicon);
             return;
         }
         mThumbnail = thumbnail;
         Favicons.cancelFaviconLoad(mLoadId);
 
-        mThumbnailView.setScaleType(ScaleType.CENTER_CROP);
+        mThumbnailView.setScaleType(SCALE_TYPE_THUMBNAIL);
         mThumbnailView.setImageBitmap(thumbnail);
         mThumbnailView.setBackgroundDrawable(null);
     }
 
     public void displayFavicon(Bitmap favicon, String faviconURL, int expectedLoadId) {
         if (mLoadId != Favicons.NOT_LOADING &&
             mLoadId != expectedLoadId) {
             // View recycled.
@@ -240,17 +244,17 @@ public class TopSitesGridItemView extend
             displayThumbnail(R.drawable.favicon);
             return;
         }
 
         if (faviconURL != null) {
             mFaviconURL = faviconURL;
         }
 
-        mThumbnailView.setScaleType(ScaleType.CENTER);
+        mThumbnailView.setScaleType(SCALE_TYPE_FAVICON);
         mThumbnailView.setImageBitmap(favicon);
 
         if (mFaviconURL != null) {
             mThumbnailView.setBackgroundColor(Favicons.getFaviconColor(mFaviconURL));
         }
     }
 
     /**