mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Android: Convert PercentSliderSetting to Kotlin
This commit is contained in:
parent
72be338d56
commit
62679bacc1
@ -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;
|
||||
}
|
||||
}
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user