Created
September 7, 2020 10:57
-
-
Save yusufceylan/9658143c05a1b6fc5a1ac3f487e622af to your computer and use it in GitHub Desktop.
Huawei Location Kit - Location Callback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun createLocationCallback( | |
onSuccess: ((location: Location?) -> Unit)? = null, | |
onFail: ((locationAvailability: LocationAvailability?) -> Unit)? = null | |
): LocationCallback { | |
return object : LocationCallback() { | |
override fun onLocationResult(locationResult: LocationResult) { | |
val currentLatLng = LatLng( | |
locationResult.lastLocation.latitude, | |
locationResult.lastLocation.longitude | |
) | |
LogUtils.d("LocationKit -> currentLatLng: $currentLatLng") | |
// Notify | |
onSuccess?.invoke(locationResult.lastLocation) | |
} | |
override fun onLocationAvailability(locationAvailability: LocationAvailability) { | |
val flag = locationAvailability.isLocationAvailable | |
LogUtils.i("LocationKit isLocationAvailable:$flag") | |
// Notify | |
onFail?.invoke(locationAvailability) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment