Skip to content
Birju Vachhani edited this page Sep 23, 2019 · 9 revisions

Locus-Android

Locus is a life-cycle aware android library for retrieving location updates by writing just a few lines. It uses Google's FusedLocationProviderApi to retrieve location and uses LiveData to notify observers on location updates.

Topics

Features

  • Android Q support
  • Completely written in Kotlin
  • Easy Initialization
  • Handles Permission Model
  • No Boilerplate
  • Built on Kotlin DSL
  • Manifest Permission Check
  • Life-Cycle Aware Location Updates
  • Location Settings Check
  • Location Settings Request
  • Custom Location Options Configuration
  • Custom Relation Dialog configuration
  • Custom Permission Blocked Dialog configuration

Installation

Gradle Dependency

  • Add the JitPack repository to your project level build.gradle file.
allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
  • Add the library dependency in your app level build.gradle file.
dependencies {
    implementation 'com.github.BirjuVachhani:locus-android:3.0.1'
}

Usage

Continuous Updates

Locus.startLocationUpdates(this) { result ->
    result.location?.let { /* Received location update */ }
    result.error?.let { /* Received error! */ }
}

Single Update

Locus.getCurrentLocation(this) { result ->
    result.location?.let { /* Received location update */ }
    result.error?.let { /* Received error! */ }
}

Handle errors:

when {
    error.isDenied -> { /* Permission denied */ }
    error.isPermanentlyDenied -> { /* Permission is permanently denied */ }
    error.isFatal -> { /* Something else went wrong! */ }
    error.isSettingsDenied -> { /* Settings resolution denied by the user */ }
    error.isSettingsResolutionFailed -> { /* Settings resolution failed! */ }
}

3. Stop Receiving Location

Locus.stopTrackingLocation()

So easy right? That's what we wanted to achieve: a hassle free location retrieval process.

License

   Copyright © 2019 BirjuVachhani

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
Clone this wiki locally