Last active
March 1, 2019 02:53
-
-
Save DiegoGSantos/76506ab582404805ab422b9634c66971 to your computer and use it in GitHub Desktop.
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
class Activity { | |
val permissionManager: PermissionManager | |
fun selectImage() { | |
if (permissionManager.isStoragePermissionGranted(this)) { | |
getImage() | |
} else { | |
askPermission() | |
} | |
} | |
private fun askPermission() { | |
permissionManager.askForPermission(this) | |
} | |
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) { | |
super.onRequestPermissionsResult(requestCode, permissions, grantResults) | |
if (permissionManager.isPermissionGranted(grantResults[0])) { | |
// Treat request granted | |
} else { | |
// Treat request denied | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment