DirectReplyReceiver: fetch avatar in background

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2022-12-02 15:17:31 +01:00 committed by Tim Krüger
parent 4b46270362
commit 2b646845bf
No known key found for this signature in database
GPG Key ID: FECE3A7222C52A4E
2 changed files with 18 additions and 12 deletions

View File

@ -47,6 +47,7 @@ import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_INTERNAL_USER_ID
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_ROOM_TOKEN
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SYSTEM_NOTIFICATION_ID
import io.reactivex.Observer
import io.reactivex.Single
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
@ -159,6 +160,7 @@ class DirectReplyReceiver : BroadcastReceiver() {
.extractMessagingStyleFromNotification(previousNotification)
// Add reply
Single.fromCallable {
val avatarUrl = ApiUtils.getUrlForAvatar(currentUser.baseUrl, currentUser.userId, false)
val me = Person.Builder()
.setName(currentUser.displayName)
@ -170,9 +172,14 @@ class DirectReplyReceiver : BroadcastReceiver() {
// Set the updated style
previousBuilder.setStyle(previousStyle)
// Update the active notification.
// Check if notification still exists
if (findActiveNotification(systemNotificationId!!) != null) {
NotificationManagerCompat.from(context).notify(systemNotificationId!!, previousBuilder.build())
}
}
.subscribeOn(Schedulers.io())
.subscribe()
}
companion object {
const val TAG = "DirectReplyReceiver"

View File

@ -330,7 +330,6 @@ object NotificationUtils {
.data(avatarUrl)
.transformations(CircleCropTransformation())
.placeholder(R.drawable.account_circle_96dp)
.placeholder(R.drawable.account_circle_96dp)
.target(
onSuccess = { result ->
val bitmap = (result as BitmapDrawable).bitmap