Scan all image links

pull/190/head
M66B 5 years ago
parent ea5f9d7e28
commit 6daad8ed45

@ -477,16 +477,42 @@ public class ContactInfo {
Document doc = JsoupEx.parse(response); Document doc = JsoupEx.parse(response);
Element link = doc.head().select("link[href~=.*\\.(ico|png|gif|svg)]").first(); List<Future<Bitmap>> futures = new ArrayList<>();
String favicon = (link == null ? null : link.attr("href"));
if (TextUtils.isEmpty(favicon)) { for (Element link : doc.head().select("link[href~=.*\\.(ico|png|gif|svg)]")) {
Element meta = doc.head().select("meta[itemprop=image]").first(); String favicon = link.attr("href");
favicon = (meta == null ? null : meta.attr("content")); if (TextUtils.isEmpty(favicon))
continue;
final URL url = new URL(base, favicon);
futures.add(executorFavicon.submit(new Callable<Bitmap>() {
@Override
public Bitmap call() throws Exception {
return getFavicon(url, scaleToPixels);
}
}));
}
for (Element meta : doc.head().select("meta[itemprop=image]")) {
String favicon = meta.attr("content");
if (TextUtils.isEmpty(favicon))
continue;
final URL url = new URL(base, favicon);
futures.add(executorFavicon.submit(new Callable<Bitmap>() {
@Override
public Bitmap call() throws Exception {
return getFavicon(url, scaleToPixels);
}
}));
} }
if (!TextUtils.isEmpty(favicon)) for (Future<Bitmap> future : futures)
return getFavicon(new URL(base, favicon), scaleToPixels); try {
return future.get();
} catch (Throwable ex) {
Log.e(ex);
}
return null; return null;
} }

Loading…
Cancel
Save