From 75f6f5e31c9d7b5a525bc34d5faac34a8095a41c Mon Sep 17 00:00:00 2001 From: "hacobot.dev" Date: Thu, 12 Jan 2023 05:02:03 -0700 Subject: [PATCH] pull request requested changes --- app/src/main/java/emu/skyline/MainActivity.kt | 13 +++++++++---- ...oxPreference.kt => RefreshCheckBoxPreference.kt} | 5 ++--- app/src/main/res/xml/preferences.xml | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) rename app/src/main/java/emu/skyline/preference/{ChkBoxPreference.kt => RefreshCheckBoxPreference.kt} (63%) diff --git a/app/src/main/java/emu/skyline/MainActivity.kt b/app/src/main/java/emu/skyline/MainActivity.kt index 09cfc033..421c79b3 100644 --- a/app/src/main/java/emu/skyline/MainActivity.kt +++ b/app/src/main/java/emu/skyline/MainActivity.kt @@ -64,6 +64,11 @@ class MainActivity : AppCompatActivity() { private var formatFilter : RomFormat? = null private var appEntries : Map>? = null + enum class SortingOrder { + AlphabeticalAsc, + AlphabeticalDesc + } + private var refreshIconVisible = false set(visible) { field = visible @@ -245,14 +250,14 @@ class MainActivity : AppCompatActivity() { } } - private fun sortGameList(gameList : List) : MutableList { + private fun sortGameList(gameList : List) : List { val sortedApps : MutableList = mutableListOf() gameList.forEach { entry -> sortedApps.add(entry) } when (preferenceSettings.sortAppsBy) { - 1 -> sortedApps.sortByDescending { it.name } - else -> sortedApps.sortBy { it.name } + SortingOrder.AlphabeticalAsc.ordinal -> sortedApps.sortBy { it.name } + SortingOrder.AlphabeticalDesc.ordinal -> sortedApps.sortByDescending { it.name } } - return sortedApps + return sortedApps.toList() } private fun handleState(state : MainState) = when (state) { diff --git a/app/src/main/java/emu/skyline/preference/ChkBoxPreference.kt b/app/src/main/java/emu/skyline/preference/RefreshCheckBoxPreference.kt similarity index 63% rename from app/src/main/java/emu/skyline/preference/ChkBoxPreference.kt rename to app/src/main/java/emu/skyline/preference/RefreshCheckBoxPreference.kt index 58c8fce3..7a192f45 100644 --- a/app/src/main/java/emu/skyline/preference/ChkBoxPreference.kt +++ b/app/src/main/java/emu/skyline/preference/RefreshCheckBoxPreference.kt @@ -1,6 +1,6 @@ /* * 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 @@ -14,8 +14,7 @@ import emu.skyline.di.getSettings /** * 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() { context?.getSettings()?.refreshRequired = true super.onClick() diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index cea9e6ce..5c65119b 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -22,7 +22,7 @@ app:key="layout_type" app:title="@string/layout_type" app:useSimpleSummaryProvider="true" /> -