From 62679bacc10ee31d112766787b29a4f8d5bc2132 Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Wed, 15 Mar 2023 03:28:07 -0400 Subject: [PATCH] Android: Convert PercentSliderSetting to Kotlin --- .../model/view/PercentSliderSetting.java | 36 ------------------- .../model/view/PercentSliderSetting.kt | 27 ++++++++++++++ 2 files changed, 27 insertions(+), 36 deletions(-) delete mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/PercentSliderSetting.java create mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/PercentSliderSetting.kt diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/PercentSliderSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/PercentSliderSetting.java deleted file mode 100644 index 834b10e077..0000000000 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/PercentSliderSetting.java +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later - -package org.dolphinemu.dolphinemu.features.settings.model.view; - -import android.content.Context; - -import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting; -import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting; -import org.dolphinemu.dolphinemu.features.settings.model.Settings; - -public final class PercentSliderSetting extends FloatSliderSetting -{ - public PercentSliderSetting(Context context, AbstractFloatSetting setting, int titleId, - int descriptionId, int min, int max, String units, int stepSize) - { - super(context, setting, titleId, descriptionId, min, max, units, stepSize); - } - - @Override - public int getSelectedValue() - { - return Math.round(mSetting.getFloat() * 100); - } - - @Override - public void setSelectedValue(Settings settings, float selection) - { - mSetting.setFloat(settings, selection / 100); - } - - @Override - public AbstractSetting getSetting() - { - return mSetting; - } -} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/PercentSliderSetting.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/PercentSliderSetting.kt new file mode 100644 index 0000000000..db6454b0c5 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/view/PercentSliderSetting.kt @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.settings.model.view + +import android.content.Context +import org.dolphinemu.dolphinemu.features.settings.model.AbstractFloatSetting +import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting +import org.dolphinemu.dolphinemu.features.settings.model.Settings +import kotlin.math.roundToInt + +class PercentSliderSetting( + context: Context, + override val setting: AbstractFloatSetting, + titleId: Int, + descriptionId: Int, + min: Int, + max: Int, + units: String?, + stepSize: Int +) : FloatSliderSetting(context, setting, titleId, descriptionId, min, max, units, stepSize) { + override val selectedValue: Int + get() = (floatSetting.float * 100).roundToInt() + + override fun setSelectedValue(settings: Settings?, selection: Float) { + floatSetting.setFloat(settings!!, selection / 100) + } +}