forked from upstream-mirrors/quik
Format phone number before lookup
This commit is contained in:
@@ -28,7 +28,7 @@ class ContactImageLoader(val context: Context) : ModelLoader<String, InputStream
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun buildLoadData(model: String?, width: Int, height: Int, options: Options?): ModelLoader.LoadData<InputStream> {
|
override fun buildLoadData(model: String?, width: Int, height: Int, options: Options?): ModelLoader.LoadData<InputStream> {
|
||||||
return ModelLoader.LoadData(ContactImageKey(model), ContactImageFetcher(context, model))
|
return ModelLoader.LoadData(ContactImageKey(model.orEmpty()), ContactImageFetcher(context, model.orEmpty()))
|
||||||
}
|
}
|
||||||
|
|
||||||
class Factory(val context: Context) : ModelLoaderFactory<String, InputStream> {
|
class Factory(val context: Context) : ModelLoaderFactory<String, InputStream> {
|
||||||
@@ -36,11 +36,11 @@ class ContactImageLoader(val context: Context) : ModelLoader<String, InputStream
|
|||||||
override fun teardown() {} // nothing to do here
|
override fun teardown() {} // nothing to do here
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContactImageKey(val address: String?) : Key {
|
class ContactImageKey(val address: String) : Key {
|
||||||
override fun updateDiskCacheKey(digest: MessageDigest) = digest.update(address?.toByteArray())
|
override fun updateDiskCacheKey(digest: MessageDigest) = digest.update(address.toByteArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContactImageFetcher(val context: Context, val address: String?) : DataFetcher<InputStream> {
|
class ContactImageFetcher(val context: Context, val address: String) : DataFetcher<InputStream> {
|
||||||
|
|
||||||
private var loadPhotoDisposable: Disposable? = null
|
private var loadPhotoDisposable: Disposable? = null
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.moez.QKSMS.presentation.view
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.res.ColorStateList
|
import android.content.res.ColorStateList
|
||||||
|
import android.telephony.PhoneNumberUtils
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
@@ -46,7 +47,7 @@ class AvatarView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : Fr
|
|||||||
|
|
||||||
contact?.let { contact ->
|
contact?.let { contact ->
|
||||||
initial.text = if (contact.name.isNotEmpty()) contact.name.substring(0, 1) else "?"
|
initial.text = if (contact.name.isNotEmpty()) contact.name.substring(0, 1) else "?"
|
||||||
GlideApp.with(photo).load(contact.address).into(photo)
|
GlideApp.with(photo).load(PhoneNumberUtils.stripSeparators(contact.address)).into(photo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user