OSDN Git Service

Deprecate fill_parent and introduce match_parent.
[android-x86/packages-apps-Browser.git] / src / com / android / browser / DownloadTouchIcon.java
index 07d2d3a..22ed73c 100644 (file)
@@ -22,11 +22,12 @@ import android.content.ContentValues;
 import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
-import android.net.http.AndroidHttpClient;
 import android.os.AsyncTask;
 import android.provider.Browser;
 import android.webkit.WebView;
 
+import com.android.common.AndroidHttpClient;
+
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.methods.HttpGet;
@@ -36,17 +37,16 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
-class DownloadTouchIcon extends AsyncTask<String, Void, Bitmap> {
+class DownloadTouchIcon extends AsyncTask<String, Void, Void> {
     private final ContentResolver mContentResolver;
     private final Cursor mCursor;
     private final String mOriginalUrl;
     private final String mUrl;
     private final String mUserAgent;
-    /* package */ BrowserActivity mActivity;
+    /* package */ Tab mTab;
 
-    public DownloadTouchIcon(BrowserActivity activity, ContentResolver cr,
-            Cursor c, WebView view) {
-        mActivity = activity;
+    public DownloadTouchIcon(Tab tab, ContentResolver cr, Cursor c, WebView view) {
+        mTab = tab;
         mContentResolver = cr;
         mCursor = c;
         // Store these in case they change.
@@ -56,7 +56,7 @@ class DownloadTouchIcon extends AsyncTask<String, Void, Bitmap> {
     }
 
     public DownloadTouchIcon(ContentResolver cr, Cursor c, String url) {
-        mActivity = null;
+        mTab = null;
         mContentResolver = cr;
         mCursor = c;
         mOriginalUrl = null;
@@ -65,7 +65,7 @@ class DownloadTouchIcon extends AsyncTask<String, Void, Bitmap> {
     }
 
     @Override
-    public Bitmap doInBackground(String... values) {
+    public Void doInBackground(String... values) {
         String url = values[0];
 
         AndroidHttpClient client = AndroidHttpClient.newInstance(
@@ -85,7 +85,7 @@ class DownloadTouchIcon extends AsyncTask<String, Void, Bitmap> {
                     if (content != null) {
                         Bitmap icon = BitmapFactory.decodeStream(
                                 content, null, null);
-                        return icon;
+                        storeIcon(icon);
                     }
                 }
             }
@@ -106,12 +106,11 @@ class DownloadTouchIcon extends AsyncTask<String, Void, Bitmap> {
         }
     }
 
-    @Override
-    public void onPostExecute(Bitmap icon) {
+    private void storeIcon(Bitmap icon) {
         // Do this first in case the download failed.
-        if (mActivity != null) {
+        if (mTab != null) {
             // Remove the touch icon loader from the BrowserActivity.
-            mActivity.mTouchIconLoader = null;
+            mTab.mTouchIconLoader = null;
         }
 
         if (icon == null || mCursor == null || isCancelled()) {