https://github.com/hichamboushaba/reactivecompass
A small library that wraps orientation sensors listeners into RxJava2
https://github.com/hichamboushaba/reactivecompass
android rxjava2 sensors
Last synced: about 1 month ago
JSON representation
A small library that wraps orientation sensors listeners into RxJava2
- Host: GitHub
- URL: https://github.com/hichamboushaba/reactivecompass
- Owner: hichamboushaba
- Created: 2018-06-13T10:33:34.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-13T11:26:57.000Z (about 8 years ago)
- Last Synced: 2024-10-19T06:27:45.436Z (over 1 year ago)
- Topics: android, rxjava2, sensors
- Language: Kotlin
- Homepage:
- Size: 131 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ReactiveCompass
A small library that wraps orientation sensors listeners into [RxJava2](https://github.com/ReactiveX/RxJava) observables
To use:
```kotlin
val compass = Compass(this)
compass.observeAzimuth()
.distinctUntilChanged({ i1, i2 -> Math.abs(i1 - i2) < 1 })
.subscribe { println("Azimuth: ${it.toInt()}") }
compass.observeAccuracy()
.distinctUntilChanged()
.map {
when (it) {
ICompass.Accuracy.ACCURATE -> "Accurate"
ICompass.Accuracy.MEDIUM -> "Medium"
ICompass.Accuracy.NOT_ACCURATE -> "Inaccurate"
}
}
.subscribe { println("Accuracy: $it") }
```