From 584b79778839b70444d5aa9ce40904f2e9947e29 Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 27 Apr 2020 01:11:28 +0200 Subject: [PATCH] Implemented setting pref icon size --- .../main/java/net/dankito/banking/util/BankIconFinder.kt | 6 +++++- .../main/java/net/dankito/banking/util/IBankIconFinder.kt | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/BankingUiCommon/src/main/java/net/dankito/banking/util/BankIconFinder.kt b/BankingUiCommon/src/main/java/net/dankito/banking/util/BankIconFinder.kt index 23506015..40335852 100644 --- a/BankingUiCommon/src/main/java/net/dankito/banking/util/BankIconFinder.kt +++ b/BankingUiCommon/src/main/java/net/dankito/banking/util/BankIconFinder.kt @@ -36,11 +36,15 @@ open class BankIconFinder : IBankIconFinder { protected val faviconComparator = FaviconComparator(webClient) - override fun findIconForBank(bankName: String): String? { + override fun findIconForBank(bankName: String, prefSize: Int): String? { findBankWebsite(bankName)?.let { bankUrl -> webClient.get(bankUrl).body?.let { bankHomepageResponse -> val favicons = faviconFinder.extractFavicons(Jsoup.parse(bankHomepageResponse), bankUrl) + faviconComparator.getBestIcon(favicons, prefSize, prefSize + 32, true)?.let { prefFavicon -> + return prefFavicon.url + } + return faviconComparator.getBestIcon(favicons, 16)?.url } } diff --git a/BankingUiCommon/src/main/java/net/dankito/banking/util/IBankIconFinder.kt b/BankingUiCommon/src/main/java/net/dankito/banking/util/IBankIconFinder.kt index aaa98fe8..4cae55f8 100644 --- a/BankingUiCommon/src/main/java/net/dankito/banking/util/IBankIconFinder.kt +++ b/BankingUiCommon/src/main/java/net/dankito/banking/util/IBankIconFinder.kt @@ -3,7 +3,7 @@ package net.dankito.banking.util interface IBankIconFinder { - fun findIconForBank(bankName: String): String? + fun findIconForBank(bankName: String, prefSize: Int = 72): String? fun findBankWebsite(bankName: String): String?