mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-09 13:59:48 +01:00
DirectReplyReceiver: fetch avatar in background
Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
parent
4b46270362
commit
2b646845bf
@ -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_ROOM_TOKEN
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SYSTEM_NOTIFICATION_ID
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_SYSTEM_NOTIFICATION_ID
|
||||||
import io.reactivex.Observer
|
import io.reactivex.Observer
|
||||||
|
import io.reactivex.Single
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
@ -159,19 +160,25 @@ class DirectReplyReceiver : BroadcastReceiver() {
|
|||||||
.extractMessagingStyleFromNotification(previousNotification)
|
.extractMessagingStyleFromNotification(previousNotification)
|
||||||
|
|
||||||
// Add reply
|
// Add reply
|
||||||
val avatarUrl = ApiUtils.getUrlForAvatar(currentUser.baseUrl, currentUser.userId, false)
|
Single.fromCallable {
|
||||||
val me = Person.Builder()
|
val avatarUrl = ApiUtils.getUrlForAvatar(currentUser.baseUrl, currentUser.userId, false)
|
||||||
.setName(currentUser.displayName)
|
val me = Person.Builder()
|
||||||
.setIcon(NotificationUtils.loadAvatarSync(avatarUrl, context))
|
.setName(currentUser.displayName)
|
||||||
.build()
|
.setIcon(NotificationUtils.loadAvatarSync(avatarUrl, context))
|
||||||
val message = NotificationCompat.MessagingStyle.Message(reply, System.currentTimeMillis(), me)
|
.build()
|
||||||
previousStyle?.addMessage(message)
|
val message = NotificationCompat.MessagingStyle.Message(reply, System.currentTimeMillis(), me)
|
||||||
|
previousStyle?.addMessage(message)
|
||||||
|
|
||||||
// Set the updated style
|
// Set the updated style
|
||||||
previousBuilder.setStyle(previousStyle)
|
previousBuilder.setStyle(previousStyle)
|
||||||
|
|
||||||
// Update the active notification.
|
// Check if notification still exists
|
||||||
NotificationManagerCompat.from(context).notify(systemNotificationId!!, previousBuilder.build())
|
if (findActiveNotification(systemNotificationId!!) != null) {
|
||||||
|
NotificationManagerCompat.from(context).notify(systemNotificationId!!, previousBuilder.build())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.subscribe()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -330,7 +330,6 @@ object NotificationUtils {
|
|||||||
.data(avatarUrl)
|
.data(avatarUrl)
|
||||||
.transformations(CircleCropTransformation())
|
.transformations(CircleCropTransformation())
|
||||||
.placeholder(R.drawable.account_circle_96dp)
|
.placeholder(R.drawable.account_circle_96dp)
|
||||||
.placeholder(R.drawable.account_circle_96dp)
|
|
||||||
.target(
|
.target(
|
||||||
onSuccess = { result ->
|
onSuccess = { result ->
|
||||||
val bitmap = (result as BitmapDrawable).bitmap
|
val bitmap = (result as BitmapDrawable).bitmap
|
||||||
|
Loading…
Reference in New Issue
Block a user