From b3c403ad76e180e9ced5db116902b3d854da331e Mon Sep 17 00:00:00 2001 From: Sriram Ramasubramanian Date: Thu, 19 Sep 2013 11:29:34 -0400 Subject: [PATCH] Bug 917848: Use a static class for LoadFaviconTask inside TwoLinePageRow. [r=lucasr] --- mobile/android/base/home/TwoLinePageRow.java | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/mobile/android/base/home/TwoLinePageRow.java b/mobile/android/base/home/TwoLinePageRow.java index c70ae2b693f3..ed3d3914fde0 100644 --- a/mobile/android/base/home/TwoLinePageRow.java +++ b/mobile/android/base/home/TwoLinePageRow.java @@ -200,7 +200,7 @@ public class TwoLinePageRow extends LinearLayout // Show blank image until the new favicon finishes loading mFavicon.clearImage(); - mLoadFaviconTask = new LoadFaviconTask(url); + mLoadFaviconTask = new LoadFaviconTask(TwoLinePageRow.this, url); // Try to use a thread pool instead of serial execution of tasks // to add more throughput to the favicon loading routines. @@ -242,10 +242,20 @@ public class TwoLinePageRow extends LinearLayout } } - private class LoadFaviconTask extends AsyncTask { + void onFaviconLoaded(Bitmap favicon, String url) { + if (TextUtils.equals(mPageUrl, url)) { + setFaviconWithUrl(favicon, url); + } + + mLoadFaviconTask = null; + } + + private static class LoadFaviconTask extends AsyncTask { + private final TwoLinePageRow mRow; private final String mUrl; - public LoadFaviconTask(String url) { + public LoadFaviconTask(TwoLinePageRow row, String url) { + mRow = row; mUrl = url; } @@ -253,7 +263,7 @@ public class TwoLinePageRow extends LinearLayout public Bitmap doInBackground(Void... params) { Bitmap favicon = Favicons.getFaviconFromMemCache(mUrl); if (favicon == null) { - final ContentResolver cr = getContext().getContentResolver(); + final ContentResolver cr = mRow.getContext().getContentResolver(); final Bitmap faviconFromDb = BrowserDB.getFaviconForUrl(cr, mUrl); if (faviconFromDb != null) { @@ -267,11 +277,7 @@ public class TwoLinePageRow extends LinearLayout @Override public void onPostExecute(Bitmap favicon) { - if (TextUtils.equals(mPageUrl, mUrl)) { - setFaviconWithUrl(favicon, mUrl); - } - - mLoadFaviconTask = null; + mRow.onFaviconLoaded(favicon, mUrl); } } }