Skip to content

Commit 499cbf6

Browse files
authored
Fix incorrect selection of counties (#247)
1 parent 6c2f42c commit 499cbf6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/src/main/java/ro/code4/monitorizarevot/ui/section/selection/PollingStationSelectionViewModel.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class PollingStationSelectionViewModel : BaseViewModel() {
3939
.doOnSuccess {
4040
counties.clear()
4141
counties.addAll(it)
42+
counties.sortBy { c -> c.order }
4243
}
4344
.observeOn(AndroidSchedulers.mainThread())
4445
.subscribe({
@@ -54,11 +55,11 @@ class PollingStationSelectionViewModel : BaseViewModel() {
5455
val countyNames = counties.sortedBy { county -> county.order }.map { it.name }
5556

5657
if (countyCode.isNullOrBlank()) {
57-
countiesLiveData.postValue(Result.Success(listOf(app.getString(R.string.polling_station_spinner_choose)) + countyNames))
58+
countiesLiveData.postValue(Result.Success(listOf(app.getString(R.string.polling_station_spinner_choose)) + countyNames.toList()))
5859
} else {
5960
hadSelectedCounty = true
6061
val selectedCountyIndex = counties.indexOfFirst { it.code == countyCode }
61-
countiesLiveData.postValue(Result.Success(countyNames))
62+
countiesLiveData.postValue(Result.Success(countyNames.toList()))
6263

6364
if (selectedCountyIndex >= 0) {
6465
selectionLiveData.postValue(Pair(selectedCountyIndex, pollingStationNumber))

0 commit comments

Comments
 (0)