Use default dispatcher for search
This commit is contained in:
parent
6312ca93ba
commit
0851ba3891
@ -7,6 +7,8 @@ import android.content.pm.LauncherActivityInfo
|
|||||||
import android.content.pm.LauncherApps
|
import android.content.pm.LauncherApps
|
||||||
import android.content.pm.PackageInstaller
|
import android.content.pm.PackageInstaller
|
||||||
import android.content.pm.ShortcutInfo
|
import android.content.pm.ShortcutInfo
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import android.os.UserHandle
|
import android.os.UserHandle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
@ -111,7 +113,7 @@ internal class AppRepositoryImpl(
|
|||||||
suspendedPackages.value.filter { packageNames.contains(it) }
|
suspendedPackages.value.filter { packageNames.contains(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
}, Handler(Looper.getMainLooper()))
|
||||||
val apps = profiles.map { p ->
|
val apps = profiles.map { p ->
|
||||||
launcherApps.getActivityList(null, p).mapNotNull { getApplication(it, p) }
|
launcherApps.getActivityList(null, p).mapNotNull { getApplication(it, p) }
|
||||||
}.flatten()
|
}.flatten()
|
||||||
@ -158,7 +160,7 @@ internal class AppRepositoryImpl(
|
|||||||
inst.add(appInstallation)
|
inst.add(appInstallation)
|
||||||
installations.value = inst
|
installations.value = inst
|
||||||
}
|
}
|
||||||
})
|
}, Handler(Looper.getMainLooper()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -106,7 +106,7 @@ class SearchVM : ViewModel(), KoinComponent {
|
|||||||
searchJob = viewModelScope.launch {
|
searchJob = viewModelScope.launch {
|
||||||
isSearching.postValue(true)
|
isSearching.postValue(true)
|
||||||
val jobs = mutableListOf<Deferred<Any>>()
|
val jobs = mutableListOf<Deferred<Any>>()
|
||||||
jobs += async {
|
jobs += async(Dispatchers.Default) {
|
||||||
appRepository.search(query).collectLatest { apps ->
|
appRepository.search(query).collectLatest { apps ->
|
||||||
hiddenItemKeys.collectLatest { hiddenKeys ->
|
hiddenItemKeys.collectLatest { hiddenKeys ->
|
||||||
val results = apps.partition { !hiddenKeys.contains(it.key) }
|
val results = apps.partition { !hiddenKeys.contains(it.key) }
|
||||||
@ -117,7 +117,7 @@ class SearchVM : ViewModel(), KoinComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobs += async {
|
jobs += async(Dispatchers.Default) {
|
||||||
contactRepository.search(query).collectLatest { contacts ->
|
contactRepository.search(query).collectLatest { contacts ->
|
||||||
hiddenItemKeys.collectLatest { hiddenKeys ->
|
hiddenItemKeys.collectLatest { hiddenKeys ->
|
||||||
val results = contacts.partition { !hiddenKeys.contains(it.key) }
|
val results = contacts.partition { !hiddenKeys.contains(it.key) }
|
||||||
@ -128,7 +128,7 @@ class SearchVM : ViewModel(), KoinComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobs += async {
|
jobs += async(Dispatchers.Default) {
|
||||||
calendarRepository.search(query).collectLatest { events ->
|
calendarRepository.search(query).collectLatest { events ->
|
||||||
hiddenItemKeys.collectLatest { hiddenKeys ->
|
hiddenItemKeys.collectLatest { hiddenKeys ->
|
||||||
val results = events.partition { !hiddenKeys.contains(it.key) }
|
val results = events.partition { !hiddenKeys.contains(it.key) }
|
||||||
@ -139,27 +139,27 @@ class SearchVM : ViewModel(), KoinComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobs += async {
|
jobs += async(Dispatchers.Default) {
|
||||||
wikipediaRepository.search(query).collectLatest {
|
wikipediaRepository.search(query).collectLatest {
|
||||||
wikipediaResult.postValue(it)
|
wikipediaResult.postValue(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobs += async {
|
jobs += async(Dispatchers.Default) {
|
||||||
unitConverterRepository.search(query).collectLatest {
|
unitConverterRepository.search(query).collectLatest {
|
||||||
unitConverterResult.postValue(it)
|
unitConverterResult.postValue(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobs += async {
|
jobs += async(Dispatchers.Default) {
|
||||||
calculatorRepository.search(query).collectLatest {
|
calculatorRepository.search(query).collectLatest {
|
||||||
calculatorResult.postValue(it)
|
calculatorResult.postValue(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobs += async {
|
jobs += async(Dispatchers.Default) {
|
||||||
websiteRepository.search(query).collectLatest {
|
websiteRepository.search(query).collectLatest {
|
||||||
websiteResult.postValue(it)
|
websiteResult.postValue(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobs += async {
|
jobs += async(Dispatchers.Default) {
|
||||||
fileRepository.search(query).collectLatest { files ->
|
fileRepository.search(query).collectLatest { files ->
|
||||||
hiddenItemKeys.collectLatest { hiddenKeys ->
|
hiddenItemKeys.collectLatest { hiddenKeys ->
|
||||||
val results = files.partition { !hiddenKeys.contains(it.key) }
|
val results = files.partition { !hiddenKeys.contains(it.key) }
|
||||||
@ -170,19 +170,19 @@ class SearchVM : ViewModel(), KoinComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobs += async {
|
jobs += async(Dispatchers.Default) {
|
||||||
websearchRepository.search(query).collectLatest {
|
websearchRepository.search(query).collectLatest {
|
||||||
websearchResults.postValue(it)
|
websearchResults.postValue(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jobs += async {
|
jobs += async(Dispatchers.Default) {
|
||||||
appShortcutRepository.search(query).collectLatest { shortcuts ->
|
appShortcutRepository.search(query).collectLatest { shortcuts ->
|
||||||
hiddenItemKeys.collectLatest { hidden ->
|
hiddenItemKeys.collectLatest { hidden ->
|
||||||
appShortcutResults.postValue(shortcuts.filter { !hidden.contains(it.key) })
|
appShortcutResults.postValue(shortcuts.filter { !hidden.contains(it.key) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
launch {
|
launch(Dispatchers.Default) {
|
||||||
hiddenItems.collectLatest {
|
hiddenItems.collectLatest {
|
||||||
hiddenResults.postValue(it.joinToList())
|
hiddenResults.postValue(it.joinToList())
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user