Skip to content

Instantly share code, notes, and snippets.

@utsmannn
Created June 28, 2020 05:12
Show Gist options
  • Save utsmannn/e1ebce5b59da7a70f7d85dfc7846c7c8 to your computer and use it in GitHub Desktop.
Save utsmannn/e1ebce5b59da7a70f7d85dfc7846c7c8 to your computer and use it in GitHub Desktop.
private fun getLocation(latLng: LatLng, done: (Item) -> Unit) {
val at = "${latLng.latitude},${latLng.longitude}"
if (!hasFetch) {
animateMarker = false
progress_circular.visibility = View.VISIBLE
GlobalScope.launch {
try {
val places = retrofitInstance.getLocation(at).items
runOnUiThread {
if (places.isNotEmpty()) {
progress_circular.visibility = View.GONE
done.invoke(places.first())
}
}
} catch (e: Throwable) {
e.printStackTrace()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment