2011-11-18 10:28:17 -08:00
|
|
|
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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/. */
|
2011-11-18 10:28:17 -08:00
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
2012-07-27 17:53:54 -07:00
|
|
|
import org.mozilla.gecko.db.BrowserDB;
|
2012-08-01 18:58:23 -07:00
|
|
|
import org.mozilla.gecko.util.GeckoJarReader;
|
2013-03-15 03:52:53 -07:00
|
|
|
import org.mozilla.gecko.util.ThreadUtils;
|
|
|
|
import org.mozilla.gecko.util.UiAsyncTask;
|
2012-07-27 17:53:54 -07:00
|
|
|
|
|
|
|
import org.apache.http.HttpEntity;
|
2013-04-08 06:39:49 -07:00
|
|
|
import org.apache.http.HttpResponse;
|
2012-07-27 17:53:54 -07:00
|
|
|
import org.apache.http.client.methods.HttpGet;
|
|
|
|
import org.apache.http.entity.BufferedHttpEntity;
|
|
|
|
|
2011-11-18 10:28:17 -08:00
|
|
|
import android.content.ContentResolver;
|
|
|
|
import android.content.Context;
|
2012-10-31 05:34:32 -07:00
|
|
|
import android.graphics.Bitmap;
|
2012-11-05 03:42:25 -08:00
|
|
|
import android.graphics.BitmapFactory;
|
2012-06-10 16:44:50 -07:00
|
|
|
import android.net.http.AndroidHttpClient;
|
2013-02-19 13:14:37 -08:00
|
|
|
import android.os.Handler;
|
2012-11-14 04:10:01 -08:00
|
|
|
import android.support.v4.util.LruCache;
|
2011-11-18 10:28:17 -08:00
|
|
|
import android.util.Log;
|
|
|
|
|
2012-03-22 11:11:49 -07:00
|
|
|
import java.io.InputStream;
|
2011-11-18 10:28:17 -08:00
|
|
|
import java.net.MalformedURLException;
|
2012-06-10 16:44:50 -07:00
|
|
|
import java.net.URI;
|
|
|
|
import java.net.URISyntaxException;
|
2012-07-27 17:53:54 -07:00
|
|
|
import java.net.URL;
|
2012-06-10 16:44:50 -07:00
|
|
|
import java.util.Collections;
|
2011-11-18 10:28:17 -08:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2012-07-17 17:54:54 -07:00
|
|
|
public class Favicons {
|
2011-11-18 10:28:17 -08:00
|
|
|
private static final String LOGTAG = "GeckoFavicons";
|
|
|
|
|
|
|
|
public static final long NOT_LOADING = 0;
|
2013-04-08 06:39:49 -07:00
|
|
|
public static final long FAILED_EXPIRY_NEVER = -1;
|
2011-11-18 10:28:17 -08:00
|
|
|
|
2013-01-28 14:52:05 -08:00
|
|
|
private static int sFaviconSmallSize = -1;
|
|
|
|
private static int sFaviconLargeSize = -1;
|
|
|
|
|
2011-11-18 10:28:17 -08:00
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
private Map<Long,LoadFaviconTask> mLoadTasks;
|
|
|
|
private long mNextFaviconLoadId;
|
2012-11-05 03:42:25 -08:00
|
|
|
private LruCache<String, Bitmap> mFaviconsCache;
|
2013-04-08 06:39:49 -07:00
|
|
|
private LruCache<String, Long> mFailedCache;
|
2012-06-10 16:44:50 -07:00
|
|
|
private static final String USER_AGENT = GeckoApp.mAppContext.getDefaultUAString();
|
|
|
|
private AndroidHttpClient mHttpClient;
|
2011-11-18 10:28:17 -08:00
|
|
|
|
|
|
|
public interface OnFaviconLoadedListener {
|
2012-11-05 03:42:25 -08:00
|
|
|
public void onFaviconLoaded(String url, Bitmap favicon);
|
2011-11-18 10:28:17 -08:00
|
|
|
}
|
|
|
|
|
2012-12-03 00:59:17 -08:00
|
|
|
public Favicons() {
|
2011-11-18 10:28:17 -08:00
|
|
|
Log.d(LOGTAG, "Creating Favicons instance");
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
mLoadTasks = Collections.synchronizedMap(new HashMap<Long,LoadFaviconTask>());
|
2011-11-18 10:28:17 -08:00
|
|
|
mNextFaviconLoadId = 0;
|
2012-10-31 05:34:32 -07:00
|
|
|
|
|
|
|
// Create a favicon memory cache that have up to 1mb of size
|
2012-11-05 03:42:25 -08:00
|
|
|
mFaviconsCache = new LruCache<String, Bitmap>(1024 * 1024) {
|
2012-10-31 05:34:32 -07:00
|
|
|
@Override
|
2012-11-05 03:42:25 -08:00
|
|
|
protected int sizeOf(String url, Bitmap image) {
|
|
|
|
return image.getRowBytes() * image.getHeight();
|
2012-10-31 05:34:32 -07:00
|
|
|
}
|
|
|
|
};
|
2013-04-08 06:39:49 -07:00
|
|
|
|
|
|
|
// Create a failed favicon memory cache that has up to 64 entries
|
|
|
|
mFailedCache = new LruCache<String, Long>(64);
|
2011-11-18 10:28:17 -08:00
|
|
|
}
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
private synchronized AndroidHttpClient getHttpClient() {
|
|
|
|
if (mHttpClient != null)
|
|
|
|
return mHttpClient;
|
|
|
|
|
|
|
|
mHttpClient = AndroidHttpClient.newInstance(USER_AGENT);
|
|
|
|
return mHttpClient;
|
|
|
|
}
|
|
|
|
|
2012-11-05 03:42:25 -08:00
|
|
|
private void dispatchResult(final String pageUrl, final Bitmap image,
|
2012-10-31 05:34:32 -07:00
|
|
|
final OnFaviconLoadedListener listener) {
|
|
|
|
if (pageUrl != null && image != null)
|
|
|
|
putFaviconInMemCache(pageUrl, image);
|
|
|
|
|
|
|
|
// We want to always run the listener on UI thread
|
2013-03-15 03:52:53 -07:00
|
|
|
ThreadUtils.postToUiThread(new Runnable() {
|
2013-02-26 21:48:00 -08:00
|
|
|
@Override
|
2012-10-31 05:34:32 -07:00
|
|
|
public void run() {
|
|
|
|
if (listener != null)
|
|
|
|
listener.onFaviconLoaded(pageUrl, image);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-07-26 15:08:50 -07:00
|
|
|
public String getFaviconUrlForPageUrl(String pageUrl) {
|
2012-11-13 10:56:58 -08:00
|
|
|
return BrowserDB.getFaviconUrlForHistoryUrl(mContext.getContentResolver(), pageUrl);
|
2012-07-26 15:08:50 -07:00
|
|
|
}
|
|
|
|
|
2012-10-09 11:26:33 -07:00
|
|
|
public long loadFavicon(String pageUrl, String faviconUrl, boolean persist,
|
2011-11-18 10:28:17 -08:00
|
|
|
OnFaviconLoadedListener listener) {
|
|
|
|
|
|
|
|
// Handle the case where page url is empty
|
|
|
|
if (pageUrl == null || pageUrl.length() == 0) {
|
2012-10-31 05:34:32 -07:00
|
|
|
dispatchResult(null, null, listener);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-04-08 06:39:49 -07:00
|
|
|
// Check if favicon has failed
|
|
|
|
if (isFailedFavicon(pageUrl)) {
|
|
|
|
dispatchResult(pageUrl, null, listener);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-10-31 05:34:32 -07:00
|
|
|
// Check if favicon is mem cached
|
2012-11-05 03:42:25 -08:00
|
|
|
Bitmap image = getFaviconFromMemCache(pageUrl);
|
2012-10-31 05:34:32 -07:00
|
|
|
if (image != null) {
|
|
|
|
dispatchResult(pageUrl, image, listener);
|
|
|
|
return -1;
|
2011-11-18 10:28:17 -08:00
|
|
|
}
|
|
|
|
|
2013-03-15 03:52:53 -07:00
|
|
|
LoadFaviconTask task = new LoadFaviconTask(ThreadUtils.getBackgroundHandler(), pageUrl, faviconUrl, persist, listener);
|
2011-11-18 10:28:17 -08:00
|
|
|
|
|
|
|
long taskId = task.getId();
|
|
|
|
mLoadTasks.put(taskId, task);
|
|
|
|
|
|
|
|
task.execute();
|
|
|
|
|
|
|
|
return taskId;
|
|
|
|
}
|
|
|
|
|
2012-11-05 03:42:25 -08:00
|
|
|
public Bitmap getFaviconFromMemCache(String pageUrl) {
|
2012-10-31 05:34:32 -07:00
|
|
|
return mFaviconsCache.get(pageUrl);
|
|
|
|
}
|
|
|
|
|
2012-11-05 03:42:25 -08:00
|
|
|
public void putFaviconInMemCache(String pageUrl, Bitmap image) {
|
2012-10-31 05:34:32 -07:00
|
|
|
mFaviconsCache.put(pageUrl, image);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void clearMemCache() {
|
|
|
|
mFaviconsCache.evictAll();
|
|
|
|
}
|
|
|
|
|
2013-04-08 06:39:49 -07:00
|
|
|
public boolean isFailedFavicon(String pageUrl) {
|
|
|
|
Long fetchTime = mFailedCache.get(pageUrl);
|
|
|
|
if (fetchTime == null)
|
|
|
|
return false;
|
|
|
|
// We don't have any other rules yet.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void putFaviconInFailedCache(String pageUrl, long fetchTime) {
|
|
|
|
mFailedCache.put(pageUrl, fetchTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void clearFailedCache() {
|
|
|
|
mFailedCache.evictAll();
|
|
|
|
}
|
|
|
|
|
2011-11-18 10:28:17 -08:00
|
|
|
public boolean cancelFaviconLoad(long taskId) {
|
|
|
|
Log.d(LOGTAG, "Requesting cancelation of favicon load (" + taskId + ")");
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
boolean cancelled = false;
|
|
|
|
synchronized (mLoadTasks) {
|
|
|
|
if (!mLoadTasks.containsKey(taskId))
|
|
|
|
return false;
|
2011-11-18 10:28:17 -08:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
Log.d(LOGTAG, "Cancelling favicon load (" + taskId + ")");
|
2011-11-18 10:28:17 -08:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
LoadFaviconTask task = mLoadTasks.get(taskId);
|
|
|
|
cancelled = task.cancel(false);
|
|
|
|
}
|
|
|
|
return cancelled;
|
2011-11-18 10:28:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public void close() {
|
|
|
|
Log.d(LOGTAG, "Closing Favicons database");
|
|
|
|
|
|
|
|
// Cancel any pending tasks
|
2012-06-10 16:44:50 -07:00
|
|
|
synchronized (mLoadTasks) {
|
|
|
|
Set<Long> taskIds = mLoadTasks.keySet();
|
|
|
|
Iterator<Long> iter = taskIds.iterator();
|
|
|
|
while (iter.hasNext()) {
|
|
|
|
long taskId = iter.next();
|
|
|
|
cancelFaviconLoad(taskId);
|
|
|
|
}
|
2011-11-18 10:28:17 -08:00
|
|
|
}
|
2012-06-10 16:44:50 -07:00
|
|
|
if (mHttpClient != null)
|
|
|
|
mHttpClient.close();
|
2011-11-18 10:28:17 -08:00
|
|
|
}
|
|
|
|
|
2012-12-03 00:59:17 -08:00
|
|
|
private static class FaviconsInstanceHolder {
|
|
|
|
private static final Favicons INSTANCE = new Favicons();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Favicons getInstance() {
|
|
|
|
return Favicons.FaviconsInstanceHolder.INSTANCE;
|
|
|
|
}
|
|
|
|
|
2013-01-28 14:52:05 -08:00
|
|
|
public boolean isLargeFavicon(Bitmap image) {
|
|
|
|
return image.getWidth() > sFaviconSmallSize || image.getHeight() > sFaviconSmallSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Bitmap scaleImage(Bitmap image) {
|
|
|
|
// If the icon is larger than 16px, scale it to sFaviconLargeSize.
|
|
|
|
// Otherwise, scale it to sFaviconSmallSize.
|
|
|
|
if (isLargeFavicon(image)) {
|
|
|
|
image = Bitmap.createScaledBitmap(image, sFaviconLargeSize, sFaviconLargeSize, false);
|
|
|
|
} else {
|
|
|
|
image = Bitmap.createScaledBitmap(image, sFaviconSmallSize, sFaviconSmallSize, false);
|
|
|
|
}
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
2012-12-03 00:59:17 -08:00
|
|
|
public void attachToContext(Context context) {
|
|
|
|
mContext = context;
|
2013-01-28 14:52:05 -08:00
|
|
|
if (sFaviconSmallSize < 0) {
|
|
|
|
sFaviconSmallSize = Math.round(mContext.getResources().getDimension(R.dimen.awesomebar_row_favicon_size_small));
|
|
|
|
}
|
|
|
|
if (sFaviconLargeSize < 0) {
|
|
|
|
sFaviconLargeSize = Math.round(mContext.getResources().getDimension(R.dimen.awesomebar_row_favicon_size_large));
|
|
|
|
}
|
2012-12-03 00:59:17 -08:00
|
|
|
}
|
|
|
|
|
2013-02-21 12:01:09 -08:00
|
|
|
private class LoadFaviconTask extends UiAsyncTask<Void, Void, Bitmap> {
|
2011-11-18 10:28:17 -08:00
|
|
|
private long mId;
|
|
|
|
private String mPageUrl;
|
|
|
|
private String mFaviconUrl;
|
|
|
|
private OnFaviconLoadedListener mListener;
|
2012-10-09 11:26:33 -07:00
|
|
|
private boolean mPersist;
|
2011-11-18 10:28:17 -08:00
|
|
|
|
2013-02-25 15:15:49 -08:00
|
|
|
public LoadFaviconTask(Handler backgroundThreadHandler,
|
2013-02-19 13:14:37 -08:00
|
|
|
String pageUrl, String faviconUrl, boolean persist,
|
|
|
|
OnFaviconLoadedListener listener) {
|
2013-02-25 15:15:49 -08:00
|
|
|
super(backgroundThreadHandler);
|
2013-02-19 13:14:37 -08:00
|
|
|
|
2012-01-24 08:52:26 -08:00
|
|
|
synchronized(this) {
|
|
|
|
mId = ++mNextFaviconLoadId;
|
|
|
|
}
|
|
|
|
|
2011-11-18 10:28:17 -08:00
|
|
|
mPageUrl = pageUrl;
|
|
|
|
mFaviconUrl = faviconUrl;
|
|
|
|
mListener = listener;
|
2012-10-09 11:26:33 -07:00
|
|
|
mPersist = persist;
|
2011-11-18 10:28:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Runs in background thread
|
2012-11-05 03:42:25 -08:00
|
|
|
private Bitmap loadFaviconFromDb() {
|
2011-11-18 10:28:17 -08:00
|
|
|
ContentResolver resolver = mContext.getContentResolver();
|
2012-11-05 03:42:25 -08:00
|
|
|
return BrowserDB.getFaviconForUrl(resolver, mPageUrl);
|
2011-11-18 10:28:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Runs in background thread
|
2012-12-21 21:27:41 -08:00
|
|
|
private void saveFaviconToDb(final Bitmap favicon) {
|
2012-10-09 11:26:33 -07:00
|
|
|
if (!mPersist) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-19 13:14:37 -08:00
|
|
|
ContentResolver resolver = mContext.getContentResolver();
|
|
|
|
BrowserDB.updateFaviconForUrl(resolver, mPageUrl, favicon, mFaviconUrl);
|
2011-11-18 10:28:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Runs in background thread
|
2012-11-05 03:42:25 -08:00
|
|
|
private Bitmap downloadFavicon(URL faviconUrl) {
|
2012-03-23 17:07:10 -07:00
|
|
|
if (mFaviconUrl.startsWith("jar:jar:")) {
|
2013-03-05 04:08:43 -08:00
|
|
|
return GeckoJarReader.getBitmap(mContext.getResources(), mFaviconUrl);
|
2012-03-23 17:07:10 -07:00
|
|
|
}
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
URI uri;
|
|
|
|
try {
|
|
|
|
uri = faviconUrl.toURI();
|
|
|
|
} catch (URISyntaxException e) {
|
2012-09-08 18:40:58 -07:00
|
|
|
Log.d(LOGTAG, "Could not get URI for favicon");
|
2012-06-10 16:44:50 -07:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// only get favicons for HTTP/HTTPS
|
|
|
|
String scheme = uri.getScheme();
|
|
|
|
if (!"http".equals(scheme) && !"https".equals(scheme))
|
|
|
|
return null;
|
|
|
|
|
2012-03-28 11:14:19 -07:00
|
|
|
// skia decoder sometimes returns null; workaround is to use BufferedHttpEntity
|
|
|
|
// http://groups.google.com/group/android-developers/browse_thread/thread/171b8bf35dbbed96/c3ec5f45436ceec8?lnk=raot
|
2012-11-05 03:42:25 -08:00
|
|
|
Bitmap image = null;
|
2011-11-18 10:28:17 -08:00
|
|
|
try {
|
2012-03-28 11:14:19 -07:00
|
|
|
HttpGet request = new HttpGet(faviconUrl.toURI());
|
2013-04-08 06:39:49 -07:00
|
|
|
HttpResponse response = getHttpClient().execute(request);
|
|
|
|
if (response == null)
|
|
|
|
return null;
|
|
|
|
if (response.getStatusLine() != null) {
|
|
|
|
// Was the response a failure?
|
|
|
|
int status = response.getStatusLine().getStatusCode();
|
|
|
|
if (status >= 400) {
|
|
|
|
putFaviconInFailedCache(mPageUrl, FAILED_EXPIRY_NEVER);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HttpEntity entity = response.getEntity();
|
|
|
|
if (entity == null)
|
|
|
|
return null;
|
|
|
|
if (entity.getContentType() != null) {
|
|
|
|
// Is the content type valid? Might be a captive portal.
|
|
|
|
String contentType = entity.getContentType().getValue();
|
|
|
|
if (contentType.indexOf("image") == -1)
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-03-28 11:14:19 -07:00
|
|
|
BufferedHttpEntity bufferedEntity = new BufferedHttpEntity(entity);
|
2012-06-10 16:44:50 -07:00
|
|
|
InputStream contentStream = bufferedEntity.getContent();
|
2012-11-05 03:42:25 -08:00
|
|
|
image = BitmapFactory.decodeStream(contentStream);
|
2011-11-18 10:28:17 -08:00
|
|
|
} catch (Exception e) {
|
2012-03-23 17:07:10 -07:00
|
|
|
Log.e(LOGTAG, "Error reading favicon", e);
|
2011-11-18 10:28:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-11-05 03:42:25 -08:00
|
|
|
protected Bitmap doInBackground(Void... unused) {
|
|
|
|
Bitmap image = null;
|
2011-11-18 10:28:17 -08:00
|
|
|
|
|
|
|
if (isCancelled())
|
|
|
|
return null;
|
|
|
|
|
|
|
|
URL faviconUrl = null;
|
|
|
|
|
|
|
|
// Handle the case of malformed favicon URL
|
|
|
|
try {
|
|
|
|
// If favicon is empty, fallback to default favicon URI
|
|
|
|
if (mFaviconUrl == null || mFaviconUrl.length() == 0) {
|
2011-12-08 05:56:45 -08:00
|
|
|
// Handle the case of malformed URL
|
|
|
|
URL pageUrl = null;
|
2012-03-23 17:38:49 -07:00
|
|
|
pageUrl = new URL(mPageUrl);
|
2011-12-08 05:56:45 -08:00
|
|
|
|
2011-11-18 10:28:17 -08:00
|
|
|
faviconUrl = new URL(pageUrl.getProtocol(), pageUrl.getAuthority(), "/favicon.ico");
|
|
|
|
mFaviconUrl = faviconUrl.toString();
|
|
|
|
} else {
|
|
|
|
faviconUrl = new URL(mFaviconUrl);
|
|
|
|
}
|
|
|
|
} catch (MalformedURLException e) {
|
2012-09-08 18:40:58 -07:00
|
|
|
Log.d(LOGTAG, "The provided favicon URL is not valid");
|
2011-11-18 10:28:17 -08:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isCancelled())
|
|
|
|
return null;
|
|
|
|
|
2012-11-13 10:56:58 -08:00
|
|
|
String storedFaviconUrl = getFaviconUrlForPageUrl(mPageUrl);
|
2011-11-18 10:28:17 -08:00
|
|
|
if (storedFaviconUrl != null && storedFaviconUrl.equals(mFaviconUrl)) {
|
|
|
|
image = loadFaviconFromDb();
|
2013-02-04 11:08:10 -08:00
|
|
|
if (image != null && image.getWidth() > 0 && image.getHeight() > 0)
|
2013-01-28 14:52:05 -08:00
|
|
|
return scaleImage(image);
|
2012-04-02 17:36:13 -07:00
|
|
|
}
|
2011-11-18 10:28:17 -08:00
|
|
|
|
2012-04-02 17:36:13 -07:00
|
|
|
if (isCancelled())
|
|
|
|
return null;
|
2011-11-18 10:28:17 -08:00
|
|
|
|
2012-04-02 17:36:13 -07:00
|
|
|
image = downloadFavicon(faviconUrl);
|
2011-11-18 10:28:17 -08:00
|
|
|
|
2012-12-03 00:59:17 -08:00
|
|
|
if (image != null && image.getWidth() > 0 && image.getHeight() > 0) {
|
2012-03-23 17:07:10 -07:00
|
|
|
saveFaviconToDb(image);
|
2013-01-28 14:52:05 -08:00
|
|
|
image = scaleImage(image);
|
2012-12-03 00:59:17 -08:00
|
|
|
} else {
|
|
|
|
image = null;
|
2012-03-23 17:07:10 -07:00
|
|
|
}
|
|
|
|
|
2011-11-18 10:28:17 -08:00
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-11-05 03:42:25 -08:00
|
|
|
protected void onPostExecute(final Bitmap image) {
|
2011-11-18 10:28:17 -08:00
|
|
|
mLoadTasks.remove(mId);
|
2012-10-31 05:34:32 -07:00
|
|
|
dispatchResult(mPageUrl, image, mListener);
|
2011-11-18 10:28:17 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onCancelled() {
|
|
|
|
mLoadTasks.remove(mId);
|
|
|
|
|
|
|
|
// Note that we don't call the listener callback if the
|
|
|
|
// favicon load is cancelled.
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getId() {
|
|
|
|
return mId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|