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) {
|
class BitmapLoader @Inject constructor(val context: Context) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Avatar Url -> Icon
|
* Avatar Url -> Bitmap
|
||||||
*/
|
*/
|
||||||
private val cache = HashMap<String, Bitmap?>()
|
private val cache = HashMap<String, Bitmap?>()
|
||||||
|
|
||||||
// Black list of URLs (broken URL, etc.)
|
|
||||||
private val blacklist = HashSet<String>()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get icon of a room.
|
* Get icon of a room.
|
||||||
* If already in cache, use it, else load it and call BitmapLoaderListener.onBitmapsLoaded() when ready
|
* 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
|
@WorkerThread
|
||||||
private fun loadRoomBitmap(path: String): Bitmap? {
|
private fun loadRoomBitmap(path: String): Bitmap? {
|
||||||
val bitmap = path.let {
|
return path.let {
|
||||||
try {
|
try {
|
||||||
Glide.with(context)
|
Glide.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
@ -66,12 +63,5 @@ class BitmapLoader @Inject constructor(val context: Context) {
|
|||||||
null
|
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) {
|
class IconLoader @Inject constructor(val context: Context) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Avatar Url -> Icon
|
* Avatar Url -> IconCompat
|
||||||
*/
|
*/
|
||||||
private val cache = HashMap<String, IconCompat?>()
|
private val cache = HashMap<String, IconCompat?>()
|
||||||
|
|
||||||
// Black list of URLs (broken URL, etc.)
|
|
||||||
private val blacklist = HashSet<String>()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get icon of a user.
|
* Get icon of a user.
|
||||||
* If already in cache, use it, else load it and call IconLoaderListener.onIconsLoaded() when ready
|
* 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
|
@WorkerThread
|
||||||
private fun loadUserIcon(path: String): IconCompat? {
|
private fun loadUserIcon(path: String): IconCompat? {
|
||||||
val iconCompat = path.let {
|
return path.let {
|
||||||
try {
|
try {
|
||||||
Glide.with(context)
|
Glide.with(context)
|
||||||
.asBitmap()
|
.asBitmap()
|
||||||
@ -72,12 +69,5 @@ class IconLoader @Inject constructor(val context: Context) {
|
|||||||
IconCompat.createWithBitmap(bitmap)
|
IconCompat.createWithBitmap(bitmap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iconCompat == null) {
|
|
||||||
// Add to the blacklist
|
|
||||||
blacklist.add(path)
|
|
||||||
}
|
|
||||||
|
|
||||||
return iconCompat
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user