diff --git a/app/src/main/java/com/nextcloud/talk/receivers/DirectReplyReceiver.kt b/app/src/main/java/com/nextcloud/talk/receivers/DirectReplyReceiver.kt index aa6806974..feec10aea 100644 --- a/app/src/main/java/com/nextcloud/talk/receivers/DirectReplyReceiver.kt +++ b/app/src/main/java/com/nextcloud/talk/receivers/DirectReplyReceiver.kt @@ -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,19 +160,25 @@ class DirectReplyReceiver : BroadcastReceiver() { .extractMessagingStyleFromNotification(previousNotification) // Add reply - val avatarUrl = ApiUtils.getUrlForAvatar(currentUser.baseUrl, currentUser.userId, false) - val me = Person.Builder() - .setName(currentUser.displayName) - .setIcon(NotificationUtils.loadAvatarSync(avatarUrl, context)) - .build() - val message = NotificationCompat.MessagingStyle.Message(reply, System.currentTimeMillis(), me) - previousStyle?.addMessage(message) + Single.fromCallable { + val avatarUrl = ApiUtils.getUrlForAvatar(currentUser.baseUrl, currentUser.userId, false) + val me = Person.Builder() + .setName(currentUser.displayName) + .setIcon(NotificationUtils.loadAvatarSync(avatarUrl, context)) + .build() + val message = NotificationCompat.MessagingStyle.Message(reply, System.currentTimeMillis(), me) + previousStyle?.addMessage(message) - // Set the updated style - previousBuilder.setStyle(previousStyle) + // Set the updated style + previousBuilder.setStyle(previousStyle) - // Update the active notification. - NotificationManagerCompat.from(context).notify(systemNotificationId!!, previousBuilder.build()) + // Check if notification still exists + if (findActiveNotification(systemNotificationId!!) != null) { + NotificationManagerCompat.from(context).notify(systemNotificationId!!, previousBuilder.build()) + } + } + .subscribeOn(Schedulers.io()) + .subscribe() } companion object { diff --git a/app/src/main/java/com/nextcloud/talk/utils/NotificationUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/NotificationUtils.kt index 5e2c80e95..7ada7b797 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/NotificationUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/NotificationUtils.kt @@ -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