diff options
| author | JosJuice <josjuice@gmail.com> | 2023-03-15 21:53:29 +0100 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2023-12-07 21:09:17 +0100 |
| commit | d80f9d53fc70e4d4197bea5bfaf1afd63b7f7879 (patch) | |
| tree | 8570e51c2392cd92285c7eb4e02b82c72da02353 /Source/Android/app/src/main/java | |
| parent | 2ece642cf82b431a2612deb7afee7661aa6635be (diff) | |
Android: Expose config changed callbacks
Diffstat (limited to 'Source/Android/app/src/main/java')
| -rw-r--r-- | Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/ConfigChangedCallback.kt | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/ConfigChangedCallback.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/ConfigChangedCallback.kt new file mode 100644 index 0000000000..4415efa9e8 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/ConfigChangedCallback.kt @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +package org.dolphinemu.dolphinemu.features.settings.model + +import androidx.annotation.Keep + +/** + * Calls the passed-in Runnable when Dolphin's config changes. + * + * Please note: The Runnable may be called from any thread. + */ +class ConfigChangedCallback(runnable: Runnable) { + @Keep + private var pointer: Long = initialize(runnable) + + /** + * Stops the callback from being called in the future. + */ + fun unregister() { + if (pointer != 0L) { + deinitialize(pointer) + pointer = 0L + } + } + + companion object { + @JvmStatic + private external fun initialize(runnable: Runnable): Long + + @JvmStatic + private external fun deinitialize(pointer: Long) + } +} |
