We all know that handling Android Permission logic is full of boilerplate code, that’s why I searched for an idea to avoid this, I saw many ideas with coroutines and suspend functions and so on.
But some idea popped in my mind make it very simple to implement handling permissions with Higher-Order function, clean, simple and very easy to use.
Let’s get into it…
This will be the BaseActivity we put our code here because we need to override onRequestPermissionsResult I believe there is no way else to do.
You may notice afterPermissionFunc this is the key to our trick.
I’ve been searching about mocking up retrofit 2 but all I found was in test phase, what if we want to make mock up response in running app just like a real server, I tried to build a Mock up feature and I came up with an easy and simple solution, let’s figure what it is.
First of all this solution depends on adding a Call Adapter to our API call to extract the Mock Up Data then adding Interceptor to inject the Mock Up Data to our call then give it back to retrofit.
Note: in this article we…
Senior Android Developer