summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-03-07 22:36:14 +0100
committerbunnei <bunneidev@gmail.com>2023-06-03 09:05:35 +0200
commita0e91e3a93673d6478ecaa7eea158b2289d61f97 (patch)
treeae0af9c79ffff978679563692345772ae2e7e19e /src
parentandroid: Convert SettingsItem to Kotlin (diff)
downloadyuzu-a0e91e3a93673d6478ecaa7eea158b2289d61f97.tar
yuzu-a0e91e3a93673d6478ecaa7eea158b2289d61f97.tar.gz
yuzu-a0e91e3a93673d6478ecaa7eea158b2289d61f97.tar.bz2
yuzu-a0e91e3a93673d6478ecaa7eea158b2289d61f97.tar.lz
yuzu-a0e91e3a93673d6478ecaa7eea158b2289d61f97.tar.xz
yuzu-a0e91e3a93673d6478ecaa7eea158b2289d61f97.tar.zst
yuzu-a0e91e3a93673d6478ecaa7eea158b2289d61f97.zip
Diffstat (limited to 'src')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.java60
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt44
2 files changed, 44 insertions, 60 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.java
deleted file mode 100644
index 619df6d52..000000000
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.yuzu.yuzu_emu.features.settings.model.view;
-
-import org.yuzu.yuzu_emu.features.settings.model.IntSetting;
-import org.yuzu.yuzu_emu.features.settings.model.Setting;
-
-public final class SingleChoiceSetting extends SettingsItem {
- private int mDefaultValue;
-
- private int mChoicesId;
- private int mValuesId;
-
- public SingleChoiceSetting(String key, String section, int titleId, int descriptionId,
- int choicesId, int valuesId, int defaultValue, Setting setting) {
- super(key, section, setting, titleId, descriptionId);
- mValuesId = valuesId;
- mChoicesId = choicesId;
- mDefaultValue = defaultValue;
- }
-
- public int getChoicesId() {
- return mChoicesId;
- }
-
- public int getValuesId() {
- return mValuesId;
- }
-
- public int getSelectedValue() {
- if (getSetting() != null) {
- IntSetting setting = (IntSetting) getSetting();
- return setting.getValue();
- } else {
- return mDefaultValue;
- }
- }
-
- /**
- * Write a value to the backing int. If that int was previously null,
- * initializes a new one and returns it, so it can be added to the Hashmap.
- *
- * @param selection New value of the int.
- * @return null if overwritten successfully otherwise; a newly created IntSetting.
- */
- public IntSetting setSelectedValue(int selection) {
- if (getSetting() == null) {
- IntSetting setting = new IntSetting(getKey(), getSection(), selection);
- setSetting(setting);
- return setting;
- } else {
- IntSetting setting = (IntSetting) getSetting();
- setting.setValue(selection);
- return null;
- }
- }
-
- @Override
- public int getType() {
- return TYPE_SINGLE_CHOICE;
- }
-}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt
new file mode 100644
index 000000000..060d324c1
--- /dev/null
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/SingleChoiceSetting.kt
@@ -0,0 +1,44 @@
+package org.yuzu.yuzu_emu.features.settings.model.view
+
+import org.yuzu.yuzu_emu.features.settings.model.IntSetting
+import org.yuzu.yuzu_emu.features.settings.model.Setting
+
+class SingleChoiceSetting(
+ key: String,
+ section: String,
+ setting: Setting?,
+ titleId: Int,
+ descriptionId: Int,
+ val choicesId: Int,
+ val valuesId: Int,
+ private val defaultValue: Int,
+) : SettingsItem(key, section, setting, titleId, descriptionId) {
+ override val type = TYPE_SINGLE_CHOICE
+
+ val selectedValue: Int
+ get() = if (setting != null) {
+ val setting = setting as IntSetting
+ setting.value
+ } else {
+ defaultValue
+ }
+
+ /**
+ * Write a value to the backing int. If that int was previously null,
+ * initializes a new one and returns it, so it can be added to the Hashmap.
+ *
+ * @param selection New value of the int.
+ * @return null if overwritten successfully otherwise; a newly created IntSetting.
+ */
+ fun setSelectedValue(selection: Int): IntSetting? {
+ return if (setting == null) {
+ val newSetting = IntSetting(key!!, section!!, selection)
+ setting = newSetting
+ newSetting
+ } else {
+ val newSetting = setting as IntSetting
+ newSetting.value = selection
+ null
+ }
+ }
+}