Search in sources :

Example 1 with FaviconImageCallback

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);
}
Also used : FaviconHelper(org.chromium.chrome.browser.favicon.FaviconHelper) FaviconImageCallback(org.chromium.chrome.browser.favicon.FaviconHelper.FaviconImageCallback) Bitmap(android.graphics.Bitmap) NavigationEntry(org.chromium.content_public.browser.NavigationEntry) HashSet(java.util.HashSet)

Example 2 with FaviconImageCallback

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);
}
Also used : FaviconImageCallback(org.chromium.chrome.browser.favicon.FaviconHelper.FaviconImageCallback) Bitmap(android.graphics.Bitmap) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Aggregations

Bitmap (android.graphics.Bitmap)2 FaviconImageCallback (org.chromium.chrome.browser.favicon.FaviconHelper.FaviconImageCallback)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Drawable (android.graphics.drawable.Drawable)1 HashSet (java.util.HashSet)1 FaviconHelper (org.chromium.chrome.browser.favicon.FaviconHelper)1 NavigationEntry (org.chromium.content_public.browser.NavigationEntry)1