use of org.chromium.chrome.browser.favicon.FaviconHelper.FaviconImageCallback in project AndroidChromium by JackyAndroid.
the class NavigationPopup method initialize.
private void initialize() {
ThreadUtils.assertOnUiThread();
mInitialized = true;
mFaviconHelper = new FaviconHelper();
Set<String> requestedUrls = new HashSet<String>();
for (int i = 0; i < mHistory.getEntryCount(); i++) {
NavigationEntry entry = mHistory.getEntryAtIndex(i);
if (entry.getFavicon() != null)
continue;
final String pageUrl = entry.getUrl();
if (!requestedUrls.contains(pageUrl)) {
FaviconImageCallback imageCallback = new FaviconImageCallback() {
@Override
public void onFaviconAvailable(Bitmap bitmap, String iconUrl) {
NavigationPopup.this.onFaviconAvailable(pageUrl, bitmap);
}
};
mFaviconHelper.getLocalFaviconImageForURL(mProfile, pageUrl, mFaviconSize, imageCallback);
requestedUrls.add(pageUrl);
}
}
FaviconImageCallback historyImageCallback = new FaviconImageCallback() {
@Override
public void onFaviconAvailable(Bitmap bitmap, String iconUrl) {
NavigationPopup.this.onFaviconAvailable(UrlConstants.HISTORY_URL, bitmap);
}
};
mFaviconHelper.getLocalFaviconImageForURL(mProfile, UrlConstants.HISTORY_URL, mFaviconSize, historyImageCallback);
}
use of org.chromium.chrome.browser.favicon.FaviconHelper.FaviconImageCallback in project AndroidChromium by JackyAndroid.
the class RecentTabsRowAdapter method loadLocalFavicon.
private void loadLocalFavicon(final ViewHolder viewHolder, final String url) {
Drawable image;
if (url == null) {
// URL is null for print jobs, for example.
image = mDefaultFavicon;
} else {
image = mFaviconCache.getLocalFaviconImage(url);
if (image == null) {
FaviconImageCallback imageCallback = new FaviconImageCallback() {
@Override
public void onFaviconAvailable(Bitmap bitmap, String iconUrl) {
if (this != viewHolder.imageCallback)
return;
Drawable image = faviconDrawable(bitmap);
image = (image == null) ? mDefaultFavicon : image;
mFaviconCache.putLocalFaviconImage(url, image);
ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(viewHolder.textView, image, null, null, null);
}
};
viewHolder.imageCallback = imageCallback;
mRecentTabsManager.getLocalFaviconForUrl(url, mFaviconSize, imageCallback);
image = mDefaultFavicon;
}
}
ApiCompatibilityUtils.setCompoundDrawablesRelativeWithIntrinsicBounds(viewHolder.textView, image, null, null, null);
}
Aggregations