ground-android icon indicating copy to clipboard operation
ground-android copied to clipboard

[Code health] Use `getFromLocation` with `GeocodeListener` instead of deprecated blocking version

Open gino-m opened this issue 2 years ago • 0 comments

Adapter for Coroutines might look something like this:

internal class CancellableGeocodeListener(
  private val cont: CancellableContinuation<List<Address>>
) : GeocodeListener {
  @OptIn(ExperimentalCoroutinesApi::class)
  override fun onGeocode(addresses: MutableList<Address>) = cont.resume(addresses)

  override fun onError(errorMessage: String?) {
    cont.cancel(errorMessage?.let { error(it) })
  }
}

gino-m avatar Jul 26 '23 14:07 gino-m