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.launch
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
import java.util.*
|
||||
|
||||
class BlacklistViewModel(application: Application) : BaseAndroidViewModel(application) {
|
||||
|
||||
@@ -70,7 +71,7 @@ class BlacklistViewModel(application: Application) : BaseAndroidViewModel(applic
|
||||
}
|
||||
blackList.add(black)
|
||||
}
|
||||
liveData.postValue(blackList.sortedBy { it.displayName })
|
||||
liveData.postValue(blackList.sortedBy { it.displayName.toLowerCase(Locale.getDefault()) })
|
||||
requestState = RequestState.Complete
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
@@ -83,4 +84,4 @@ class BlacklistViewModel(application: Application) : BaseAndroidViewModel(applic
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import kotlinx.coroutines.launch
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.util.*
|
||||
|
||||
class InstalledViewModel(application: Application) : BaseAppsViewModel(application) {
|
||||
|
||||
@@ -43,7 +44,7 @@ class InstalledViewModel(application: Application) : BaseAppsViewModel(applicati
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
appList.flushAndAdd(getFilteredApps())
|
||||
liveData.postValue(appList.sortedBy { it.displayName })
|
||||
liveData.postValue(appList.sortedBy { it.displayName.toLowerCase(Locale.getDefault()) })
|
||||
requestState = RequestState.Complete
|
||||
} catch (e: Exception) {
|
||||
requestState = RequestState.Pending
|
||||
@@ -78,11 +79,11 @@ class InstalledViewModel(application: Application) : BaseAppsViewModel(applicati
|
||||
appList.flushAndAdd(updatedList)
|
||||
|
||||
//Post new update list
|
||||
liveData.postValue(appList.sortedBy { it.displayName })
|
||||
liveData.postValue(appList.sortedBy { it.displayName.toLowerCase(Locale.getDefault()) })
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
EventBus.getDefault().unregister(this)
|
||||
super.onCleared()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import kotlinx.coroutines.launch
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
import java.util.*
|
||||
|
||||
class UpdatesViewModel(application: Application) : BaseAppsViewModel(application) {
|
||||
|
||||
@@ -67,7 +68,7 @@ class UpdatesViewModel(application: Application) : BaseAppsViewModel(application
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}.also { apps ->
|
||||
}.sortedBy { it.displayName.toLowerCase(Locale.getDefault()) }.also { apps ->
|
||||
apps.forEach {
|
||||
updateFileMap[it.id] = UpdateFile(it)
|
||||
}
|
||||
@@ -154,4 +155,4 @@ class UpdatesViewModel(application: Application) : BaseAppsViewModel(application
|
||||
EventBus.getDefault().unregister(this)
|
||||
super.onCleared()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user