diff options
| author | 2023-05-02 00:14:58 -0400 | |
|---|---|---|
| committer | 2023-06-03 00:05:58 -0700 | |
| commit | 03541703fa7bc2c349ea7ec80ada7441574e9081 (patch) | |
| tree | b7b071afa9db0b02ed02dfda222d29bd599eccfe /src/android | |
| parent | android: New icons for navigation bar (diff) | |
| download | yuzu-03541703fa7bc2c349ea7ec80ada7441574e9081.tar.gz yuzu-03541703fa7bc2c349ea7ec80ada7441574e9081.tar.xz yuzu-03541703fa7bc2c349ea7ec80ada7441574e9081.zip | |
android: Sort games alphabetically by default
Diffstat (limited to 'src/android')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt index cc17b8626..0b4ae8744 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/GamesFragment.kt | |||
| @@ -20,8 +20,10 @@ import org.yuzu.yuzu_emu.R | |||
| 20 | import org.yuzu.yuzu_emu.adapters.GameAdapter | 20 | import org.yuzu.yuzu_emu.adapters.GameAdapter |
| 21 | import org.yuzu.yuzu_emu.databinding.FragmentGamesBinding | 21 | import org.yuzu.yuzu_emu.databinding.FragmentGamesBinding |
| 22 | import org.yuzu.yuzu_emu.layout.AutofitGridLayoutManager | 22 | import org.yuzu.yuzu_emu.layout.AutofitGridLayoutManager |
| 23 | import org.yuzu.yuzu_emu.model.Game | ||
| 23 | import org.yuzu.yuzu_emu.model.GamesViewModel | 24 | import org.yuzu.yuzu_emu.model.GamesViewModel |
| 24 | import org.yuzu.yuzu_emu.model.HomeViewModel | 25 | import org.yuzu.yuzu_emu.model.HomeViewModel |
| 26 | import java.util.Locale | ||
| 25 | 27 | ||
| 26 | class GamesFragment : Fragment() { | 28 | class GamesFragment : Fragment() { |
| 27 | private var _binding: FragmentGamesBinding? = null | 29 | private var _binding: FragmentGamesBinding? = null |
| @@ -73,7 +75,7 @@ class GamesFragment : Fragment() { | |||
| 73 | binding.swipeRefresh.isRefreshing = isReloading | 75 | binding.swipeRefresh.isRefreshing = isReloading |
| 74 | } | 76 | } |
| 75 | gamesViewModel.games.observe(viewLifecycleOwner) { | 77 | gamesViewModel.games.observe(viewLifecycleOwner) { |
| 76 | (binding.gridGames.adapter as GameAdapter).submitList(it) | 78 | submitGamesList(it) |
| 77 | if (it.isEmpty()) { | 79 | if (it.isEmpty()) { |
| 78 | binding.noticeText.visibility = View.VISIBLE | 80 | binding.noticeText.visibility = View.VISIBLE |
| 79 | } else { | 81 | } else { |
| @@ -83,7 +85,7 @@ class GamesFragment : Fragment() { | |||
| 83 | 85 | ||
| 84 | gamesViewModel.shouldSwapData.observe(viewLifecycleOwner) { shouldSwapData -> | 86 | gamesViewModel.shouldSwapData.observe(viewLifecycleOwner) { shouldSwapData -> |
| 85 | if (shouldSwapData) { | 87 | if (shouldSwapData) { |
| 86 | (binding.gridGames.adapter as GameAdapter).submitList(gamesViewModel.games.value) | 88 | submitGamesList(gamesViewModel.games.value!!) |
| 87 | gamesViewModel.setShouldSwapData(false) | 89 | gamesViewModel.setShouldSwapData(false) |
| 88 | } | 90 | } |
| 89 | } | 91 | } |
| @@ -107,6 +109,11 @@ class GamesFragment : Fragment() { | |||
| 107 | } | 109 | } |
| 108 | } | 110 | } |
| 109 | 111 | ||
| 112 | private fun submitGamesList(gameList: List<Game>) { | ||
| 113 | val sortedList = gameList.sortedBy { it.title.lowercase(Locale.getDefault()) } | ||
| 114 | (binding.gridGames.adapter as GameAdapter).submitList(sortedList) | ||
| 115 | } | ||
| 116 | |||
| 110 | override fun onDestroyView() { | 117 | override fun onDestroyView() { |
| 111 | super.onDestroyView() | 118 | super.onDestroyView() |
| 112 | _binding = null | 119 | _binding = null |