Android: Convert InvertedSwitchSetting to Kotlin
This commit is contained in:
parent
2369977e14
commit
56c33890b9
|
@ -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.AbstractBooleanSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting;
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
|
||||
|
||||
public final class InvertedSwitchSetting extends SwitchSetting
|
||||
{
|
||||
public InvertedSwitchSetting(Context context, AbstractBooleanSetting setting, int titleId,
|
||||
int descriptionId)
|
||||
{
|
||||
super(context, setting, titleId, descriptionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked()
|
||||
{
|
||||
return !mSetting.getBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChecked(Settings settings, boolean checked)
|
||||
{
|
||||
mSetting.setBoolean(settings, !checked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractSetting getSetting()
|
||||
{
|
||||
return mSetting;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
// 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.AbstractBooleanSetting
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.AbstractSetting
|
||||
import org.dolphinemu.dolphinemu.features.settings.model.Settings
|
||||
|
||||
class InvertedSwitchSetting(
|
||||
context: Context,
|
||||
setting: AbstractBooleanSetting,
|
||||
titleId: Int,
|
||||
descriptionId: Int
|
||||
) : SwitchSetting(context, setting, titleId, descriptionId) {
|
||||
override val setting: AbstractSetting
|
||||
get() = booleanSetting
|
||||
|
||||
override val isChecked: Boolean
|
||||
get() = !booleanSetting.boolean
|
||||
|
||||
override fun setChecked(settings: Settings?, checked: Boolean) {
|
||||
booleanSetting.setBoolean(settings!!, !checked)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue