Cleanup
This commit is contained in:
parent
e90aeff417
commit
443fb41d18
|
@ -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<String, Bitmap?>()
|
||||
|
||||
// Black list of URLs (broken URL, etc.)
|
||||
private val blacklist = HashSet<String>()
|
||||
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String, IconCompat?>()
|
||||
|
||||
// Black list of URLs (broken URL, etc.)
|
||||
private val blacklist = HashSet<String>()
|
||||
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue