private void resolve(Collection<String> urls) { final long timestamp = SystemClock.elapsedRealtime(); mPwsClient.resolve( urls, new PwsClient.ResolveScanCallback() { @Override public void onPwsResults(Collection<PwsResult> pwsResults) { long duration = SystemClock.elapsedRealtime() - timestamp; PhysicalWebUma.onForegroundPwsResolution(ListUrlsActivity.this, duration); // filter out duplicate site URLs. Collection<String> siteUrls = new HashSet<>(); for (PwsResult pwsResult : pwsResults) { String siteUrl = pwsResult.siteUrl; String iconUrl = pwsResult.iconUrl; if (siteUrl != null && !siteUrls.contains(siteUrl)) { siteUrls.add(siteUrl); mAdapter.add(pwsResult); if (iconUrl != null && !mAdapter.hasIcon(iconUrl)) { fetchIcon(iconUrl); } } } finishRefresh(); } }); }
private void fetchIcon(String iconUrl) { mPwsClient.fetchIcon( iconUrl, new PwsClient.FetchIconCallback() { @Override public void onIconReceived(String url, Bitmap bitmap) { mAdapter.setIcon(url, bitmap); } }); }