yuzu-emu
/
yuzu
Archived
1
0
Fork 0

android: Convert DateTimeSetting to Kotlin

This commit is contained in:
Charles Lombardo 2023-03-07 15:38:44 -05:00 committed by bunnei
parent 4d9cfc6798
commit 21841b6520
2 changed files with 35 additions and 40 deletions

View File

@ -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;
}
}

View File

@ -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
}
}
}