Skip to content

Commit

Permalink
Sort the laundry rooms so they are stable when refreshing.
Browse files Browse the repository at this point in the history
  • Loading branch information
meiron03 committed Apr 21, 2024
1 parent a4dfcf6 commit f687a2c
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ class LaundryFragment : Fragment() {
laundryRooms.addAll(favorites.favoriteRooms)
roomsData.addAll(favorites.roomsData)

// sort laundry rooms data by hall name
laundryRooms.sortWith { usage1, usage2 -> usage2.id - usage1.id }

// sort laundry rooms by name
roomsData.sortWith { room1, room2 -> room2.id - room1.id }

for (pos in 0 until LaundryViewModel.maxNumRooms) {
mAdapter!!.notifyItemChanged(pos)
}
Expand Down Expand Up @@ -121,8 +127,8 @@ class LaundryFragment : Fragment() {
val bearerToken = "Bearer " + sharedPreferences
.getString(getString(R.string.access_token), "").toString()
laundryViewModel.getFavorites(mStudentLife, bearerToken)
binding.laundryMachineRefresh.isRefreshing = false
}
binding.laundryMachineRefresh.isRefreshing = false
}

private fun initAppBar() {
Expand Down

0 comments on commit f687a2c

Please sign in to comment.