package app.furmeet.events.system.helper

import android.database.DataSetObserver
import app.furmeet.events.system.helper.observables.Observer

class ObserverDataSetObserverAdapter {
    val convertedObservers: MutableMap<DataSetObserver, Observer<Any?>> = mutableMapOf()

    operator fun get(dataSetObserver: DataSetObserver): Observer<Any?> {
        if (dataSetObserver !in convertedObservers) {
            convertedObservers[dataSetObserver] = Observer { _, _ -> dataSetObserver.onChanged() }
        }
        return convertedObservers[dataSetObserver]!!
    }

    fun remove(dataSetObserver: DataSetObserver) = convertedObservers.remove(dataSetObserver)
}
