diff options
| author | 2023-03-07 17:20:31 -0500 | |
|---|---|---|
| committer | 2023-06-03 00:05:36 -0700 | |
| commit | 412ec72d26ae40aa78f91b3c7a9e52da8e05b6ee (patch) | |
| tree | 70670086944687c6ed53c5c7a803647cfa76759b /src/android | |
| parent | android: Convert Setting to Kotlin (diff) | |
| download | yuzu-412ec72d26ae40aa78f91b3c7a9e52da8e05b6ee.tar.gz yuzu-412ec72d26ae40aa78f91b3c7a9e52da8e05b6ee.tar.xz yuzu-412ec72d26ae40aa78f91b3c7a9e52da8e05b6ee.zip | |
android: Convert SettingSection to Kotlin
Diffstat (limited to 'src/android')
2 files changed, 34 insertions, 55 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/SettingSection.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/SettingSection.java deleted file mode 100644 index da9d40c78..000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/SettingSection.java +++ /dev/null | |||
| @@ -1,55 +0,0 @@ | |||
| 1 | package org.yuzu.yuzu_emu.features.settings.model; | ||
| 2 | |||
| 3 | import java.util.HashMap; | ||
| 4 | |||
| 5 | /** | ||
| 6 | * A semantically-related group of Settings objects. These Settings are | ||
| 7 | * internally stored as a HashMap. | ||
| 8 | */ | ||
| 9 | public final class SettingSection { | ||
| 10 | private String mName; | ||
| 11 | |||
| 12 | private HashMap<String, Setting> mSettings = new HashMap<>(); | ||
| 13 | |||
| 14 | /** | ||
| 15 | * Create a new SettingSection with no Settings in it. | ||
| 16 | * | ||
| 17 | * @param name The header of this section; e.g. [Core] or [Enhancements] without the brackets. | ||
| 18 | */ | ||
| 19 | public SettingSection(String name) { | ||
| 20 | mName = name; | ||
| 21 | } | ||
| 22 | |||
| 23 | public String getName() { | ||
| 24 | return mName; | ||
| 25 | } | ||
| 26 | |||
| 27 | /** | ||
| 28 | * Convenience method; inserts a value directly into the backing HashMap. | ||
| 29 | * | ||
| 30 | * @param setting The Setting to be inserted. | ||
| 31 | */ | ||
| 32 | public void putSetting(Setting setting) { | ||
| 33 | mSettings.put(setting.getKey(), setting); | ||
| 34 | } | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Convenience method; gets a value directly from the backing HashMap. | ||
| 38 | * | ||
| 39 | * @param key Used to retrieve the Setting. | ||
| 40 | * @return A Setting object (you should probably cast this before using) | ||
| 41 | */ | ||
| 42 | public Setting getSetting(String key) { | ||
| 43 | return mSettings.get(key); | ||
| 44 | } | ||
| 45 | |||
| 46 | public HashMap<String, Setting> getSettings() { | ||
| 47 | return mSettings; | ||
| 48 | } | ||
| 49 | |||
| 50 | public void mergeSection(SettingSection settingSection) { | ||
| 51 | for (Setting setting : settingSection.mSettings.values()) { | ||
| 52 | putSetting(setting); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | } | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/SettingSection.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/SettingSection.kt new file mode 100644 index 000000000..929884e30 --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/SettingSection.kt | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | package org.yuzu.yuzu_emu.features.settings.model | ||
| 2 | |||
| 3 | /** | ||
| 4 | * A semantically-related group of Settings objects. These Settings are | ||
| 5 | * internally stored as a HashMap. | ||
| 6 | */ | ||
| 7 | class SettingSection(val name: String) { | ||
| 8 | val settings = HashMap<String, Setting>() | ||
| 9 | |||
| 10 | /** | ||
| 11 | * Convenience method; inserts a value directly into the backing HashMap. | ||
| 12 | * | ||
| 13 | * @param setting The Setting to be inserted. | ||
| 14 | */ | ||
| 15 | fun putSetting(setting: Setting) { | ||
| 16 | settings[setting.key] = setting | ||
| 17 | } | ||
| 18 | |||
| 19 | /** | ||
| 20 | * Convenience method; gets a value directly from the backing HashMap. | ||
| 21 | * | ||
| 22 | * @param key Used to retrieve the Setting. | ||
| 23 | * @return A Setting object (you should probably cast this before using) | ||
| 24 | */ | ||
| 25 | fun getSetting(key: String): Setting? { | ||
| 26 | return settings[key] | ||
| 27 | } | ||
| 28 | |||
| 29 | fun mergeSection(settingSection: SettingSection) { | ||
| 30 | for (setting in settingSection.settings.values) { | ||
| 31 | putSetting(setting) | ||
| 32 | } | ||
| 33 | } | ||
| 34 | } | ||