From 443fb41d18386b12308517c83a240a18328dd64f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 8 Jul 2019 11:21:26 +0200 Subject: [PATCH] Cleanup --- .../riotx/features/notifications/BitmapLoader.kt | 14 ++------------ .../riotx/features/notifications/IconLoader.kt | 14 ++------------ 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/notifications/BitmapLoader.kt b/vector/src/main/java/im/vector/riotx/features/notifications/BitmapLoader.kt index 51a025e5..c3a74bd9 100644 --- a/vector/src/main/java/im/vector/riotx/features/notifications/BitmapLoader.kt +++ b/vector/src/main/java/im/vector/riotx/features/notifications/BitmapLoader.kt @@ -29,13 +29,10 @@ import javax.inject.Singleton class BitmapLoader @Inject constructor(val context: Context) { /** - * Avatar Url -> Icon + * Avatar Url -> Bitmap */ private val cache = HashMap() - // Black list of URLs (broken URL, etc.) - private val blacklist = HashSet() - /** * Get icon of a room. * If already in cache, use it, else load it and call BitmapLoaderListener.onBitmapsLoaded() when ready @@ -53,7 +50,7 @@ class BitmapLoader @Inject constructor(val context: Context) { @WorkerThread private fun loadRoomBitmap(path: String): Bitmap? { - val bitmap = path.let { + return path.let { try { Glide.with(context) .asBitmap() @@ -66,12 +63,5 @@ class BitmapLoader @Inject constructor(val context: Context) { null } } - - if (bitmap == null) { - // Add to the blacklist - blacklist.add(path) - } - - return bitmap } } diff --git a/vector/src/main/java/im/vector/riotx/features/notifications/IconLoader.kt b/vector/src/main/java/im/vector/riotx/features/notifications/IconLoader.kt index 205f2b0e..0c4477f4 100644 --- a/vector/src/main/java/im/vector/riotx/features/notifications/IconLoader.kt +++ b/vector/src/main/java/im/vector/riotx/features/notifications/IconLoader.kt @@ -31,13 +31,10 @@ import javax.inject.Singleton class IconLoader @Inject constructor(val context: Context) { /** - * Avatar Url -> Icon + * Avatar Url -> IconCompat */ private val cache = HashMap() - // Black list of URLs (broken URL, etc.) - private val blacklist = HashSet() - /** * Get icon of a user. * If already in cache, use it, else load it and call IconLoaderListener.onIconsLoaded() when ready @@ -56,7 +53,7 @@ class IconLoader @Inject constructor(val context: Context) { @WorkerThread private fun loadUserIcon(path: String): IconCompat? { - val iconCompat = path.let { + return path.let { try { Glide.with(context) .asBitmap() @@ -72,12 +69,5 @@ class IconLoader @Inject constructor(val context: Context) { IconCompat.createWithBitmap(bitmap) } } - - if (iconCompat == null) { - // Add to the blacklist - blacklist.add(path) - } - - return iconCompat } }