relying on the glide caches (persisted and in memory) instead of our own
- this effectively halves the amount of image memory used by notifications
This commit is contained in:
parent
95b3afd148
commit
65239e4034
@ -28,11 +28,6 @@ import javax.inject.Singleton
|
|||||||
@Singleton
|
@Singleton
|
||||||
class BitmapLoader @Inject constructor(private val context: Context) {
|
class BitmapLoader @Inject constructor(private val context: Context) {
|
||||||
|
|
||||||
/**
|
|
||||||
* Avatar Url -> Bitmap
|
|
||||||
*/
|
|
||||||
private val cache = HashMap<String, Bitmap?>()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@ -42,10 +37,7 @@ class BitmapLoader @Inject constructor(private val context: Context) {
|
|||||||
if (path == null) {
|
if (path == null) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
return loadRoomBitmap(path)
|
||||||
return cache.getOrPut(path) {
|
|
||||||
loadRoomBitmap(path)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
|
@ -30,11 +30,6 @@ import javax.inject.Singleton
|
|||||||
@Singleton
|
@Singleton
|
||||||
class IconLoader @Inject constructor(private val context: Context) {
|
class IconLoader @Inject constructor(private val context: Context) {
|
||||||
|
|
||||||
/**
|
|
||||||
* Avatar Url -> IconCompat
|
|
||||||
*/
|
|
||||||
private val cache = HashMap<String, IconCompat?>()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
@ -46,9 +41,7 @@ class IconLoader @Inject constructor(private val context: Context) {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return cache.getOrPut(path) {
|
return loadUserIcon(path)
|
||||||
loadUserIcon(path)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
|
Loading…
x
Reference in New Issue
Block a user