complicate the threading at receiving messages a bit more
This commit is contained in:
parent
64011e1083
commit
f66833e9bd
|
@ -3,6 +3,8 @@ package com.simplemobiletools.smsmessenger.receivers
|
||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.provider.Telephony
|
import android.provider.Telephony
|
||||||
import com.simplemobiletools.commons.extensions.isNumberBlocked
|
import com.simplemobiletools.commons.extensions.isNumberBlocked
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
|
@ -21,6 +23,7 @@ class SmsReceiver : BroadcastReceiver() {
|
||||||
val read = 0
|
val read = 0
|
||||||
val subscriptionId = intent.getIntExtra("subscription", -1)
|
val subscriptionId = intent.getIntExtra("subscription", -1)
|
||||||
|
|
||||||
|
ensureBackgroundThread {
|
||||||
messages.forEach {
|
messages.forEach {
|
||||||
address = it.originatingAddress ?: ""
|
address = it.originatingAddress ?: ""
|
||||||
subject = it.pseudoSubject
|
subject = it.pseudoSubject
|
||||||
|
@ -29,6 +32,7 @@ class SmsReceiver : BroadcastReceiver() {
|
||||||
threadId = context.getThreadId(address)
|
threadId = context.getThreadId(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Handler(Looper.getMainLooper()).post {
|
||||||
if (!context.isNumberBlocked(address)) {
|
if (!context.isNumberBlocked(address)) {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
context.insertNewSMS(address, subject, body, date, read, threadId, type, subscriptionId)
|
context.insertNewSMS(address, subject, body, date, read, threadId, type, subscriptionId)
|
||||||
|
@ -43,3 +47,5 @@ class SmsReceiver : BroadcastReceiver() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue