diff options
author | malwoodsantoro <mallorywood413@gmail.com> | 2019-07-10 10:50:20 -0700 |
---|---|---|
committer | malwoodsantoro <mallorywood413@gmail.com> | 2019-07-10 10:50:20 -0700 |
commit | a2115c086f40007aca016cef5f5c99284728fa17 (patch) | |
tree | 7acb162a76376d02c33d321952ffabbd81fe4e73 /platform/android/wearapp/src/main/java/com/mapbox/mapboxsdk/wearapp/livedata/MapViewSensors.kt | |
parent | 6b1fb1a1dbff55472511f08167b915b0925e1ea3 (diff) | |
download | qtlocation-mapboxgl-a2115c086f40007aca016cef5f5c99284728fa17.tar.gz |
add relevant code
Diffstat (limited to 'platform/android/wearapp/src/main/java/com/mapbox/mapboxsdk/wearapp/livedata/MapViewSensors.kt')
-rw-r--r-- | platform/android/wearapp/src/main/java/com/mapbox/mapboxsdk/wearapp/livedata/MapViewSensors.kt | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/platform/android/wearapp/src/main/java/com/mapbox/mapboxsdk/wearapp/livedata/MapViewSensors.kt b/platform/android/wearapp/src/main/java/com/mapbox/mapboxsdk/wearapp/livedata/MapViewSensors.kt new file mode 100644 index 0000000000..8b56fff3f6 --- /dev/null +++ b/platform/android/wearapp/src/main/java/com/mapbox/mapboxsdk/wearapp/livedata/MapViewSensors.kt @@ -0,0 +1,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) + } + } +} |