项目作者: anboralabs

项目描述 :
GPS Android component with lifecycle
高级语言: Java
项目地址: git://github.com/anboralabs/gps-component.git
创建时间: 2019-09-22T19:41:58Z
项目社区:https://github.com/anboralabs/gps-component

开源协议:MIT License

下载


GPS Component

GPS Component: It is a library to avoid boilerplate code with Android GPS. This project uses Android architecture components to managing life cycle states.

Installation

Add dependency with gradle.

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }
  1. implementation 'com.github.anboralabs:gps-component:1.2.0'

Usage

  1. val locationUpdate = LocationUpdate(
  2. 10, 10,
  3. LocationUpdate.PRIORITY_HIGH_ACCURACY
  4. );
  5. val locationComponent = LocationComponent.Builder()
  6. .build(this, locationUpdate)
  7. locationComponent
  8. .onLastLocation(LastLocationCallback())
  9. .whenLocationChange()
  10. .onLocationChanged(object : CallbackLocation {
  11. override fun onLocationResult(location: Location?) {
  12. location?.run {
  13. current_location.text = getString(R.string.location, this.latitude, this.longitude)
  14. }
  15. }
  16. override fun onLocationError() {
  17. }
  18. }).attachState().observe(lifecycle)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT