mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-06 16:18:58 +00:00
Android: Expose config changed callbacks
This commit is contained in:
parent
2ece642cf8
commit
d80f9d53fc
5 changed files with 91 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue