fix #76, make sure a notification is shown if app is paused

This commit is contained in:
tibbi 2020-09-22 14:22:03 +02:00
parent e3f7d80987
commit 766f1ef78c
1 changed files with 15 additions and 1 deletions

View File

@ -51,6 +51,7 @@ class ThreadActivity : SimpleActivity() {
private var threadId = 0
private var currentSIMCardIndex = 0
private var isActivityVisible = false
private var threadItems = ArrayList<ThreadItem>()
private var bus: EventBus? = null
private var participants = ArrayList<SimpleContact>()
@ -86,6 +87,16 @@ class ThreadActivity : SimpleActivity() {
}
}
override fun onResume() {
super.onResume()
isActivityVisible = true
}
override fun onPause() {
super.onPause()
isActivityVisible = false
}
private fun setupThread() {
val privateCursor = getMyContactsCursor().loadInBackground()
ensureBackgroundThread {
@ -643,7 +654,10 @@ class ThreadActivity : SimpleActivity() {
@Subscribe(threadMode = ThreadMode.ASYNC)
fun refreshMessages(event: Events.RefreshMessages) {
notificationManager.cancel(threadId)
if (isActivityVisible) {
notificationManager.cancel(threadId)
}
messages = getMessages(threadId)
setupAdapter()
}