From 21841b65206bd960d98586283d716e3351445caf Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Tue, 7 Mar 2023 15:38:44 -0500 Subject: [PATCH] android: Convert DateTimeSetting to Kotlin --- .../settings/model/view/DateTimeSetting.java | 40 ------------------- .../settings/model/view/DateTimeSetting.kt | 35 ++++++++++++++++ 2 files changed, 35 insertions(+), 40 deletions(-) delete mode 100644 src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/DateTimeSetting.java create mode 100644 src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/DateTimeSetting.kt diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/DateTimeSetting.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/DateTimeSetting.java deleted file mode 100644 index 17b2f11881..0000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/DateTimeSetting.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.yuzu.yuzu_emu.features.settings.model.view; - -import org.yuzu.yuzu_emu.features.settings.model.Setting; -import org.yuzu.yuzu_emu.features.settings.model.StringSetting; - -public final class DateTimeSetting extends SettingsItem { - private String mDefaultValue; - - public DateTimeSetting(String key, String section, int titleId, int descriptionId, - String defaultValue, Setting setting) { - super(key, section, setting, titleId, descriptionId); - mDefaultValue = defaultValue; - } - - public String getValue() { - if (getSetting() != null) { - StringSetting setting = (StringSetting) getSetting(); - return setting.getValue(); - } else { - return mDefaultValue; - } - } - - public StringSetting setSelectedValue(String datetime) { - if (getSetting() == null) { - StringSetting setting = new StringSetting(getKey(), getSection(), datetime); - setSetting(setting); - return setting; - } else { - StringSetting setting = (StringSetting) getSetting(); - setting.setValue(datetime); - return null; - } - } - - @Override - public int getType() { - return TYPE_DATETIME_SETTING; - } -} \ No newline at end of file diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/DateTimeSetting.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/DateTimeSetting.kt new file mode 100644 index 0000000000..a3388468db --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/view/DateTimeSetting.kt @@ -0,0 +1,35 @@ +package org.yuzu.yuzu_emu.features.settings.model.view + +import org.yuzu.yuzu_emu.features.settings.model.Setting +import org.yuzu.yuzu_emu.features.settings.model.StringSetting + +class DateTimeSetting( + key: String, + section: String, + titleId: Int, + descriptionId: Int, + private val defaultValue: String, + setting: Setting +) : SettingsItem(key, section, setting, titleId, descriptionId) { + override val type = TYPE_DATETIME_SETTING + + val value: String + get() = if (setting != null) { + val setting = setting as StringSetting + setting.value + } else { + defaultValue + } + + fun setSelectedValue(datetime: String): StringSetting? { + return if (setting == null) { + val newSetting = StringSetting(key!!, section!!, datetime) + setting = newSetting + newSetting + } else { + val newSetting = setting as StringSetting + newSetting.value = datetime + null + } + } +}