QuickPermissions / QuickPermissions-Kotlin

The most easiest way to handle Android Runtime Permissions in Kotlin
Apache License 2.0
313 stars 35 forks source link

Use generic return type for runWithPermissions functions. #19

Open acsbendi opened 4 years ago

acsbendi commented 4 years ago

This can be useful to preserve the original function's return type. My use case:

interface InterfaceWithUnitMethod{
        fun unitMethod()
}
class MyFragment() : Fragment(), InterfaceWithUnitMethod{
       override fun unitMethod() = runWithPermissions(...){
                ...
       }
}

The override will only work if the return type matches the interface's, that is, Unit. Therefore, the previous Any? return type won't work in this scenario.