Location Data Sources
class RobotVacuumLocationSource(private val robots: ArrayList<MPLocation>): MPLocationSource {
private val mObservers = ArrayList<MPLocationsObserver>()
private var mStatus = MPLocationSourceStatus.NOT_INITIALIZED
override fun getLocations(): MutableList<MPLocation> {
return robots
}
override fun addLocationsObserver(observer: MPLocationsObserver?) {
if (observer != null) {
mObservers.add(observer)
}
}
override fun removeLocationsObserver(observer: MPLocationsObserver?) {
if (observer != null) {
mObservers.remove(observer)
}
}
private fun notifyUpdateLocations() {
for (observer in mObservers) {
observer.onLocationsUpdated(robots, this)
}
}
override fun getStatus(): MPLocationSourceStatus {
return mStatus
}
override fun getSourceId(): Int {
return 10101010
}
override fun clearCache() {
robots.clear()
mObservers.clear()
}
override fun terminate() {
robots.clear()
mObservers.clear()
}
}Last updated
Was this helpful?