pull request requested changes

This commit is contained in:
hacobot.dev 2023-01-12 05:02:03 -07:00 committed by Billy Laws
parent 7cd13916a3
commit 75f6f5e31c
3 changed files with 12 additions and 8 deletions

View File

@ -64,6 +64,11 @@ class MainActivity : AppCompatActivity() {
private var formatFilter : RomFormat? = null private var formatFilter : RomFormat? = null
private var appEntries : Map<RomFormat, List<AppEntry>>? = null private var appEntries : Map<RomFormat, List<AppEntry>>? = null
enum class SortingOrder {
AlphabeticalAsc,
AlphabeticalDesc
}
private var refreshIconVisible = false private var refreshIconVisible = false
set(visible) { set(visible) {
field = visible field = visible
@ -245,14 +250,14 @@ class MainActivity : AppCompatActivity() {
} }
} }
private fun sortGameList(gameList : List<AppEntry>) : MutableList<AppEntry> { private fun sortGameList(gameList : List<AppEntry>) : List<AppEntry> {
val sortedApps : MutableList<AppEntry> = mutableListOf<AppEntry>() val sortedApps : MutableList<AppEntry> = mutableListOf<AppEntry>()
gameList.forEach { entry -> sortedApps.add(entry) } gameList.forEach { entry -> sortedApps.add(entry) }
when (preferenceSettings.sortAppsBy) { when (preferenceSettings.sortAppsBy) {
1 -> sortedApps.sortByDescending { it.name } SortingOrder.AlphabeticalAsc.ordinal -> sortedApps.sortBy { it.name }
else -> sortedApps.sortBy { it.name } SortingOrder.AlphabeticalDesc.ordinal -> sortedApps.sortByDescending { it.name }
} }
return sortedApps return sortedApps.toList()
} }
private fun handleState(state : MainState) = when (state) { private fun handleState(state : MainState) = when (state) {

View File

@ -1,6 +1,6 @@
/* /*
* SPDX-License-Identifier: MPL-2.0 * SPDX-License-Identifier: MPL-2.0
* Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) * Copyright © 2023 Skyline Team and Contributors (https://github.com/skyline-emu/)
*/ */
package emu.skyline.preference package emu.skyline.preference
@ -14,8 +14,7 @@ import emu.skyline.di.getSettings
/** /**
* This preference is used with checkboxes that need to refresh the main activity when changed * This preference is used with checkboxes that need to refresh the main activity when changed
*/ */
class ChkBoxPreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = R.attr.checkBoxPreferenceStyle) : CheckBoxPreference(context, attrs, defStyleAttr) { class RefreshCheckBoxPreference @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = R.attr.checkBoxPreferenceStyle) : CheckBoxPreference(context, attrs, defStyleAttr) {
override fun onClick() { override fun onClick() {
context?.getSettings()?.refreshRequired = true context?.getSettings()?.refreshRequired = true
super.onClick() super.onClick()

View File

@ -22,7 +22,7 @@
app:key="layout_type" app:key="layout_type"
app:title="@string/layout_type" app:title="@string/layout_type"
app:useSimpleSummaryProvider="true" /> app:useSimpleSummaryProvider="true" />
<emu.skyline.preference.ChkBoxPreference <emu.skyline.preference.RefreshCheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:summaryOff="@string/group_by_format_desc_off" android:summaryOff="@string/group_by_format_desc_off"
android:summaryOn="@string/group_by_format_desc_on" android:summaryOn="@string/group_by_format_desc_on"