Last active
May 14, 2019 09:02
-
-
Save 0xBADDCAFE/7a6e660dc5394f7df0f5bb9e4ab3c56b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fun confirm() { | |
requestLocationWithCheck() | |
} | |
@NeedsPermission(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION) | |
fun requestLocation() { | |
fusedLocationClient.lastLocation.addOnSuccessListener { | |
send(it) | |
fragmentManager.beginTransaction() | |
.replace(R.id.container, MyFragment.newInstance()) | |
.commit() | |
} | |
} | |
@OnPermissionDenied | |
fun locationDenied() { | |
fragmentManager.beginTransaction() | |
.replace(R.id.container, MyFragment.newInstance()) | |
.commit() | |
} |
This file contains hidden or 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
fun confirm() = launch { | |
val location = requestLocationWithCheck() | |
location?.let{ | |
send(it) | |
} | |
fragmentManager.beginTransaction() | |
.replace(R.id.container, MyFragment.newInstance()) | |
.commit() | |
} | |
@NeedsPermission(Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION) | |
suspend fun requestLocation() = suspendCoroutine<Location> { cont -> | |
fusedLocationClient.lastLocation.addOnSuccessListener { | |
cont.resume(it) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment