Add configured background color of fallback contact picture to cache key
This commit is contained in:
parent
c8da50f945
commit
f610be227b
2 changed files with 5 additions and 4 deletions
|
@ -11,7 +11,7 @@ import com.fsck.k9.mail.Address
|
|||
*/
|
||||
class ContactLetterBitmapCreator(
|
||||
private val letterExtractor: ContactLetterExtractor,
|
||||
private val config: ContactLetterBitmapConfig
|
||||
val config: ContactLetterBitmapConfig
|
||||
) {
|
||||
fun drawBitmap(bitmap: Bitmap, pictureSizeInPx: Int, address: Address): Bitmap {
|
||||
val canvas = Canvas(bitmap)
|
||||
|
|
|
@ -26,7 +26,6 @@ import com.bumptech.glide.request.target.Target
|
|||
import com.fsck.k9.helper.Contacts
|
||||
import com.fsck.k9.mail.Address
|
||||
import com.fsck.k9.view.RecipientSelectView.Recipient
|
||||
import java.util.Locale
|
||||
|
||||
|
||||
class ContactPictureLoader(
|
||||
|
@ -35,6 +34,9 @@ class ContactPictureLoader(
|
|||
) {
|
||||
private val contactsHelper: Contacts = Contacts.getInstance(context)
|
||||
private val pictureSizeInPx: Int = PICTURE_SIZE.toDip(context)
|
||||
private val backgroundCacheId: String = with(contactLetterBitmapCreator.config) {
|
||||
if (hasDefaultBackgroundColor) defaultBackgroundColor.toString() else "*"
|
||||
}
|
||||
|
||||
|
||||
fun loadContactPicture(address: Address, imageView: ImageView) {
|
||||
|
@ -151,8 +153,7 @@ class ContactPictureLoader(
|
|||
}
|
||||
|
||||
private inner class FallbackGlideParams(val address: Address) {
|
||||
val id: String
|
||||
get() = String.format(Locale.ROOT, "%s-%s", address.address, address.personal)
|
||||
val id: String = "${address.address}-${address.personal}-$backgroundCacheId"
|
||||
}
|
||||
|
||||
private inner class FallbackGlideModelLoader : ModelLoader<FallbackGlideParams, FallbackGlideParams> {
|
||||
|
|
Loading…
Reference in a new issue