mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Android: Convert ReadOnlyCheat to Kotlin
This commit is contained in:
parent
59ecda7939
commit
fb177631ef
@ -1,36 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.dolphinemu.dolphinemu.features.cheats.model;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public abstract class ReadOnlyCheat implements Cheat
|
||||
{
|
||||
private Runnable mChangedCallback = null;
|
||||
|
||||
public int trySet(@NonNull String name, @NonNull String creator, @NonNull String notes,
|
||||
@NonNull String code)
|
||||
{
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
setEnabledImpl(enabled);
|
||||
onChanged();
|
||||
}
|
||||
|
||||
public void setChangedCallback(@Nullable Runnable callback)
|
||||
{
|
||||
mChangedCallback = callback;
|
||||
}
|
||||
|
||||
protected void onChanged()
|
||||
{
|
||||
if (mChangedCallback != null)
|
||||
mChangedCallback.run();
|
||||
}
|
||||
|
||||
protected abstract void setEnabledImpl(boolean enabled);
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
package org.dolphinemu.dolphinemu.features.cheats.model
|
||||
|
||||
abstract class ReadOnlyCheat : Cheat {
|
||||
private var onChangedCallback: Runnable? = null
|
||||
|
||||
override fun setCheat(
|
||||
name: String,
|
||||
creator: String,
|
||||
notes: String,
|
||||
code: String
|
||||
): Int {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
override fun setEnabled(isChecked: Boolean) {
|
||||
setEnabledImpl(isChecked)
|
||||
onChanged()
|
||||
}
|
||||
|
||||
override fun setChangedCallback(callback: Runnable?) {
|
||||
onChangedCallback = callback
|
||||
}
|
||||
|
||||
protected fun onChanged() {
|
||||
if (onChangedCallback != null) onChangedCallback!!.run()
|
||||
}
|
||||
|
||||
protected abstract fun setEnabledImpl(enabled: Boolean)
|
||||
}
|
Loading…
Reference in New Issue
Block a user