https://kotlinlang.org logo
#android
Title
# android
m

Massimo Carli

11/22/2018, 11:36 AM
Hi All. I'm trying to use a high order function in order to check for permission in Android with this function:
Copy code
@ExperimentalContracts
inline fun runIfGranted(context: Context, permission: String, fn: () -> Unit) {
    contract { returns(true) implies WHAT'S HERE? }  
    if (ContextCompat.checkSelfPermission(
            context,
            permission
        ) == PackageManager.PERMISSION_GRANTED
    ) {
        fn()
    }
}
. In order to remove the IntelliJ warning, I could use the
@SuppressLint("MissingPermission")
but I think that a contract would be the right solution. In that case, what should I put in the comment in the previous code in place of the literal
true
?
r

radityagumay

11/23/2018, 12:11 AM
@Massimo Carli hmm.. I am not sure why you put
true
there
m

Massimo Carli

11/24/2018, 1:47 AM
@radityagumay I've updated the message. I'm asking what to put instead of the true.