Android: Convert PercentSliderSetting to Kotlin

This commit is contained in:
Charles Lombardo 2023-03-15 03:28:07 -04:00
parent 72be338d56
commit 62679bacc1
2 changed files with 27 additions and 36 deletions

View File

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

View File

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