From a29a72735ef9b947945132a5810d30a288ac94a6 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 17 Feb 2022 10:25:17 +0100 Subject: [PATCH] Refactoring --- app/src/main/java/eu/faircode/email/ContactInfo.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ContactInfo.java b/app/src/main/java/eu/faircode/email/ContactInfo.java index 7f4127cd6e..ab6d6cf581 100644 --- a/app/src/main/java/eu/faircode/email/ContactInfo.java +++ b/app/src/main/java/eu/faircode/email/ContactInfo.java @@ -647,6 +647,7 @@ public class ContactInfo { if (l != 0) return -l; + // https://en.wikipedia.org/wiki/Favicon#How_to_use boolean i1 = "icon".equalsIgnoreCase(img1.attr("rel") .replace("shortcut", "").trim()); boolean i2 = "icon".equalsIgnoreCase(img2.attr("rel") @@ -655,8 +656,8 @@ public class ContactInfo { if (i != 0) return -i; - int t1 = getOrder(img1.attr("href"), img1.attr("type")); - int t2 = getOrder(img2.attr("href"), img2.attr("type")); + int t1 = getOrder(img1); + int t2 = getOrder(img2); int t = Integer.compare(t1, t2); if (t != 0) return t; @@ -710,7 +711,10 @@ public class ContactInfo { return null; } - private static int getOrder(String href, String type) { + private static int getOrder(Element img) { + String href = img.attr("href"); + String type = img.attr("type"); + int order = -1; String h = (href == null ? "" : href.toLowerCase(Locale.ROOT)); if (h.endsWith(".ico"))