permissions-dispatcher / PermissionsDispatcher

A declarative API to handle Android runtime permissions.
https://github.com/permissions-dispatcher/PermissionsDispatcher
Apache License 2.0
11.21k stars 1.44k forks source link

Make the annotations arguments dynamic #662

Closed sagarnayak closed 4 years ago

sagarnayak commented 4 years ago

I would like to push the code for the 3 handler methods to a super activity. and I want to pass the permissions required as arguments for the activity during initialization or as a method. is this possible?

I tried to make the args dynamic for @NeedsPermission but got the error - annotation parameter must be compile-time constant

mannodermaus commented 4 years ago

Yeah, this is impossible with a purely annotation-based approach, since those are processed at compilation time and cannot receive dynamic information at runtime - hence why you're getting this particular message from the compiler. The only way to make a non-literal work in an annotation would be a const val in Kotlin, but that's technically not even a variable anyway, and it wouldn't help you at runtime either.

Unfortunately, I'm afraid you'll have to find a different solution for your use case.

sagarnayak commented 4 years ago

Yeah, I thought so. this is library is perfect to be used inside the activity. but I wanted to squeeze those methods inside the parent. please consider adding such functionality where the code does not require to be written on the main presenter page.

regards