mirror of
https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
synced 2025-06-05 21:49:22 +02:00
fix #76, make sure a notification is shown if app is paused
This commit is contained in:
@@ -51,6 +51,7 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private var threadId = 0
|
private var threadId = 0
|
||||||
private var currentSIMCardIndex = 0
|
private var currentSIMCardIndex = 0
|
||||||
|
private var isActivityVisible = false
|
||||||
private var threadItems = ArrayList<ThreadItem>()
|
private var threadItems = ArrayList<ThreadItem>()
|
||||||
private var bus: EventBus? = null
|
private var bus: EventBus? = null
|
||||||
private var participants = ArrayList<SimpleContact>()
|
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() {
|
private fun setupThread() {
|
||||||
val privateCursor = getMyContactsCursor().loadInBackground()
|
val privateCursor = getMyContactsCursor().loadInBackground()
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
@@ -643,7 +654,10 @@ class ThreadActivity : SimpleActivity() {
|
|||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.ASYNC)
|
@Subscribe(threadMode = ThreadMode.ASYNC)
|
||||||
fun refreshMessages(event: Events.RefreshMessages) {
|
fun refreshMessages(event: Events.RefreshMessages) {
|
||||||
notificationManager.cancel(threadId)
|
if (isActivityVisible) {
|
||||||
|
notificationManager.cancel(threadId)
|
||||||
|
}
|
||||||
|
|
||||||
messages = getMessages(threadId)
|
messages = getMessages(threadId)
|
||||||
setupAdapter()
|
setupAdapter()
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user