use of org.chromium.chrome.browser.favicon.FaviconHelper.IconAvailabilityCallback in project AndroidChromium by JackyAndroid.
the class NewTabPageView method onPopularURLsAvailable.
@Override
public void onPopularURLsAvailable(String[] urls, String[] faviconUrls, String[] largeIconUrls) {
for (int i = 0; i < urls.length; i++) {
final String url = urls[i];
boolean useLargeIcon = !largeIconUrls[i].isEmpty();
// Only fetch one of favicon or large icon based on what is required on the NTP.
// The other will be fetched on visiting the site.
String iconUrl = useLargeIcon ? largeIconUrls[i] : faviconUrls[i];
if (iconUrl.isEmpty())
continue;
IconAvailabilityCallback callback = new IconAvailabilityCallback() {
@Override
public void onIconAvailabilityChecked(boolean newlyAvailable) {
if (newlyAvailable) {
mMostVisitedDesign.onIconUpdated(url);
}
}
};
mManager.ensureIconIsAvailable(url, iconUrl, useLargeIcon, /*isTemporary=*/
false, callback);
}
}
use of org.chromium.chrome.browser.favicon.FaviconHelper.IconAvailabilityCallback in project AndroidChromium by JackyAndroid.
the class SnippetArticleViewHolder method fetchFaviconFromService.
// TODO(crbug.com/635567): Fix this properly.
@SuppressLint("DefaultLocale")
private void fetchFaviconFromService(final URI snippetUri) {
// Show the default favicon immediately.
setDefaultFaviconOnView();
if (!mUseFaviconService)
return;
int sizePx = getFaviconServiceSupportedSize();
if (sizePx == 0)
return;
// Replace the default icon by another one from the service when it is fetched.
mNewTabPageManager.ensureIconIsAvailable(// Store to the cache for the whole domain.
getSnippetDomain(snippetUri), String.format(FAVICON_SERVICE_FORMAT, snippetUri.getHost(), sizePx), /*useLargeIcon=*/
false, /*isTemporary=*/
true, new IconAvailabilityCallback() {
@Override
public void onIconAvailabilityChecked(boolean newlyAvailable) {
if (!newlyAvailable)
return;
// The download succeeded, the favicon is in the cache; fetch it.
fetchFaviconFromLocalCache(snippetUri, /*fallbackToService=*/
false);
}
});
}
Aggregations