limiting the room bitmap loader image size, the notification icon size is relatively small and there's no cap on the image size
This commit is contained in:
parent
65239e4034
commit
eeb9785651
|
@ -21,6 +21,7 @@ import android.graphics.Bitmap
|
|||
import androidx.annotation.WorkerThread
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.DecodeFormat
|
||||
import com.bumptech.glide.signature.ObjectKey
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
@ -28,6 +29,9 @@ import javax.inject.Singleton
|
|||
@Singleton
|
||||
class BitmapLoader @Inject constructor(private val context: Context) {
|
||||
|
||||
private val iconWidth = context.resources.getDimensionPixelSize(android.R.dimen.notification_large_icon_width)
|
||||
private val iconHeight = context.resources.getDimensionPixelSize(android.R.dimen.notification_large_icon_height)
|
||||
|
||||
/**
|
||||
* Get icon of a room.
|
||||
* If already in cache, use it, else load it and call BitmapLoaderListener.onBitmapsLoaded() when ready
|
||||
|
@ -47,8 +51,10 @@ class BitmapLoader @Inject constructor(private val context: Context) {
|
|||
Glide.with(context)
|
||||
.asBitmap()
|
||||
.load(path)
|
||||
.fitCenter()
|
||||
.format(DecodeFormat.PREFER_ARGB_8888)
|
||||
.submit()
|
||||
.signature(ObjectKey("room-icon-notification"))
|
||||
.submit(iconWidth, iconHeight)
|
||||
.get()
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "decodeFile failed")
|
||||
|
|
Loading…
Reference in New Issue