mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Android: Convert FloatSliderSetting to Kotlin
This commit is contained in:
@ -1,44 +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 class FloatSliderSetting extends SliderSetting
|
|
||||||
{
|
|
||||||
protected AbstractFloatSetting mSetting;
|
|
||||||
|
|
||||||
public FloatSliderSetting(Context context, AbstractFloatSetting setting, int titleId,
|
|
||||||
int descriptionId, int min, int max, String units, int stepSize)
|
|
||||||
{
|
|
||||||
super(context, titleId, descriptionId, min, max, units, stepSize);
|
|
||||||
mSetting = setting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FloatSliderSetting(AbstractFloatSetting setting, CharSequence name,
|
|
||||||
CharSequence description, int min, int max, String units)
|
|
||||||
{
|
|
||||||
super(name, description, min, max, units);
|
|
||||||
mSetting = setting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSelectedValue()
|
|
||||||
{
|
|
||||||
return Math.round(mSetting.getFloat());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectedValue(Settings settings, float selection)
|
|
||||||
{
|
|
||||||
mSetting.setFloat(settings, selection);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AbstractSetting getSetting()
|
|
||||||
{
|
|
||||||
return mSetting;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,47 @@
|
|||||||
|
// 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
|
||||||
|
|
||||||
|
open class FloatSliderSetting : SliderSetting {
|
||||||
|
var floatSetting: AbstractFloatSetting
|
||||||
|
|
||||||
|
override val setting: AbstractSetting
|
||||||
|
get() = floatSetting
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
context: Context,
|
||||||
|
setting: AbstractFloatSetting,
|
||||||
|
titleId: Int,
|
||||||
|
descriptionId: Int,
|
||||||
|
min: Int,
|
||||||
|
max: Int,
|
||||||
|
units: String?,
|
||||||
|
stepSize: Int
|
||||||
|
) : super(context, titleId, descriptionId, min, max, units, stepSize) {
|
||||||
|
floatSetting = setting
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
setting: AbstractFloatSetting,
|
||||||
|
name: CharSequence,
|
||||||
|
description: CharSequence?,
|
||||||
|
min: Int,
|
||||||
|
max: Int,
|
||||||
|
units: String?
|
||||||
|
) : super(name, description, min, max, units) {
|
||||||
|
floatSetting = setting
|
||||||
|
}
|
||||||
|
|
||||||
|
override val selectedValue: Int
|
||||||
|
get() = floatSetting.float.roundToInt()
|
||||||
|
|
||||||
|
open fun setSelectedValue(settings: Settings?, selection: Float) {
|
||||||
|
floatSetting.setFloat(settings!!, selection)
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user