Android: Expose config changed callbacks

This commit is contained in:
JosJuice
2023-03-15 21:53:29 +01:00
parent 2ece642cf8
commit d80f9d53fc
5 changed files with 91 additions and 0 deletions

View File

@ -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)
}
}