QuickPermissions-Kotlin
QuickPermissions-Kotlin copied to clipboard
Use generic return type for runWithPermissions functions.
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.