23 lines
595 B
Kotlin
23 lines
595 B
Kotlin
package com.example.defenseapplication.utils
|
|
|
|
object DeviceUpdateEvent {
|
|
private val listeners = mutableListOf<DeviceUpdateListener>()
|
|
|
|
interface DeviceUpdateListener {
|
|
fun onDeviceUpdated(deviceId: String)
|
|
}
|
|
|
|
fun addListener(listener: DeviceUpdateListener) {
|
|
if (!listeners.contains(listener)) {
|
|
listeners.add(listener)
|
|
}
|
|
}
|
|
|
|
fun removeListener(listener: DeviceUpdateListener) {
|
|
listeners.remove(listener)
|
|
}
|
|
|
|
fun notifyDeviceUpdated(deviceId: String) {
|
|
listeners.forEach { it.onDeviceUpdated(deviceId) }
|
|
}
|
|
} |