mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-26 07:50:05 +00:00
android: Convert DateTimeSetting to Kotlin
This commit is contained in:
parent
4d9cfc6798
commit
21841b6520
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user