blob: 8b56fff3f6ccde522409c23d3ef91bcc5f158d8a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package com.soy.android.maps.livedata
import android.location.Location
import androidx.lifecycle.Observer
import com.example.mapbox.livedata.HeadingSensorLiveData
import com.example.mapbox.livedata.LocationWithHeadingLiveData
import javax.inject.Inject
class MapViewSensors
@Inject constructor(
val locationLiveData: LocationWithHeadingLiveData,
val headingLiveData: HeadingSensorLiveData
) {
fun requestUpdates(
locationObserver: Observer<Location>? = null,
headingObserver: Observer<Float>? = null
) {
locationObserver?.let {
locationLiveData.observeForever(it)
}
headingObserver?.let {
headingLiveData.observeForever(it)
}
}
fun removeUpdates(
locationObserver: Observer<Location>? = null,
headingObserver: Observer<Float>? = null
) {
locationObserver?.let {
locationLiveData.removeObserver(it)
}
headingObserver?.let {
headingLiveData.removeObserver(it)
}
}
}
|