improve the performance of recents fetching

This commit is contained in:
tibbi
2020-05-23 17:54:41 +02:00
parent b4b376cbfc
commit 4983cd98a7

View File

@ -16,7 +16,6 @@ class RecentsHelper(private val context: Context) {
fun getRecentCalls(callback: (ArrayList<RecentCall>) -> Unit) { fun getRecentCalls(callback: (ArrayList<RecentCall>) -> Unit) {
ensureBackgroundThread { ensureBackgroundThread {
var recentCalls = ArrayList<RecentCall>() var recentCalls = ArrayList<RecentCall>()
val blockedNumbers = context.getBlockedNumbers()
if (!context.hasPermission(PERMISSION_READ_CALL_LOG)) { if (!context.hasPermission(PERMISSION_READ_CALL_LOG)) {
callback(recentCalls) callback(recentCalls)
return@ensureBackgroundThread return@ensureBackgroundThread
@ -65,7 +64,8 @@ class RecentsHelper(private val context: Context) {
previousRecentCallFrom = "$number$name" previousRecentCallFrom = "$number$name"
} }
recentCalls = recentCalls.filter { !context.isNumberBlocked(it.phoneNumber) }.toMutableList() as ArrayList<RecentCall> val blockedNumbers = context.getBlockedNumbers()
recentCalls = recentCalls.filter { !context.isNumberBlocked(it.phoneNumber, blockedNumbers) }.toMutableList() as ArrayList<RecentCall>
callback(recentCalls) callback(recentCalls)
} }
} }