Search in sources :

Example 1 with FaviconHelper

use of org.chromium.chrome.browser.favicon.FaviconHelper 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 FaviconHelper

use of org.chromium.chrome.browser.favicon.FaviconHelper in project AndroidChromium by JackyAndroid.

the class WebsitePreference method onBindView.

@Override
protected void onBindView(View view) {
    super.onBindView(view);
    TextView usageText = (TextView) view.findViewById(R.id.usage_text);
    usageText.setVisibility(View.GONE);
    if (mCategory.showStorageSites()) {
        long totalUsage = mSite.getTotalUsage();
        if (totalUsage > 0) {
            usageText.setText(Formatter.formatShortFileSize(getContext(), totalUsage));
            usageText.setTextSize(TEXT_SIZE_SP);
            usageText.setVisibility(View.VISIBLE);
        }
    }
    if (!mFaviconFetched) {
        // Start the favicon fetching. Will respond in onFaviconAvailable.
        mFaviconHelper = new FaviconHelper();
        if (!mFaviconHelper.getLocalFaviconImageForURL(Profile.getLastUsedProfile(), faviconUrl(), mFaviconSizePx, this)) {
            onFaviconAvailable(null, null);
        }
        mFaviconFetched = true;
    }
    float density = getContext().getResources().getDisplayMetrics().density;
    int iconPadding = Math.round(FAVICON_PADDING_DP * density);
    View iconView = view.findViewById(android.R.id.icon);
    iconView.setPadding(iconPadding, iconPadding, iconPadding, iconPadding);
}
Also used : FaviconHelper(org.chromium.chrome.browser.favicon.FaviconHelper) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

FaviconHelper (org.chromium.chrome.browser.favicon.FaviconHelper)2 Bitmap (android.graphics.Bitmap)1 View (android.view.View)1 TextView (android.widget.TextView)1 HashSet (java.util.HashSet)1 FaviconImageCallback (org.chromium.chrome.browser.favicon.FaviconHelper.FaviconImageCallback)1 NavigationEntry (org.chromium.content_public.browser.NavigationEntry)1