Sort app lists alphabetially
This commit is contained in:
committed by
Rahul Kumar Patel
parent
de0fc90cfe
commit
6ccdf09551
@@ -31,6 +31,7 @@ import com.aurora.store.viewmodel.BaseAndroidViewModel
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.supervisorScope
|
import kotlinx.coroutines.supervisorScope
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class BlacklistViewModel(application: Application) : BaseAndroidViewModel(application) {
|
class BlacklistViewModel(application: Application) : BaseAndroidViewModel(application) {
|
||||||
|
|
||||||
@@ -70,7 +71,7 @@ class BlacklistViewModel(application: Application) : BaseAndroidViewModel(applic
|
|||||||
}
|
}
|
||||||
blackList.add(black)
|
blackList.add(black)
|
||||||
}
|
}
|
||||||
liveData.postValue(blackList.sortedBy { it.displayName })
|
liveData.postValue(blackList.sortedBy { it.displayName.toLowerCase(Locale.getDefault()) })
|
||||||
requestState = RequestState.Complete
|
requestState = RequestState.Complete
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import kotlinx.coroutines.launch
|
|||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class InstalledViewModel(application: Application) : BaseAppsViewModel(application) {
|
class InstalledViewModel(application: Application) : BaseAppsViewModel(application) {
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ class InstalledViewModel(application: Application) : BaseAppsViewModel(applicati
|
|||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
appList.flushAndAdd(getFilteredApps())
|
appList.flushAndAdd(getFilteredApps())
|
||||||
liveData.postValue(appList.sortedBy { it.displayName })
|
liveData.postValue(appList.sortedBy { it.displayName.toLowerCase(Locale.getDefault()) })
|
||||||
requestState = RequestState.Complete
|
requestState = RequestState.Complete
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
requestState = RequestState.Pending
|
requestState = RequestState.Pending
|
||||||
@@ -78,7 +79,7 @@ class InstalledViewModel(application: Application) : BaseAppsViewModel(applicati
|
|||||||
appList.flushAndAdd(updatedList)
|
appList.flushAndAdd(updatedList)
|
||||||
|
|
||||||
//Post new update list
|
//Post new update list
|
||||||
liveData.postValue(appList.sortedBy { it.displayName })
|
liveData.postValue(appList.sortedBy { it.displayName.toLowerCase(Locale.getDefault()) })
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import kotlinx.coroutines.launch
|
|||||||
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.EventBus
|
||||||
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.Subscribe
|
||||||
import org.greenrobot.eventbus.ThreadMode
|
import org.greenrobot.eventbus.ThreadMode
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
class UpdatesViewModel(application: Application) : BaseAppsViewModel(application) {
|
class UpdatesViewModel(application: Application) : BaseAppsViewModel(application) {
|
||||||
|
|
||||||
@@ -67,7 +68,7 @@ class UpdatesViewModel(application: Application) : BaseAppsViewModel(application
|
|||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}.also { apps ->
|
}.sortedBy { it.displayName.toLowerCase(Locale.getDefault()) }.also { apps ->
|
||||||
apps.forEach {
|
apps.forEach {
|
||||||
updateFileMap[it.id] = UpdateFile(it)
|
updateFileMap[it.id] = UpdateFile(it)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user