Hi, I built a small library for Android, it helps ...
# android
o
Hi, I built a small library for Android, it helps you to add custom annotations on retrofit calls and retrieve them later via interceptor Check it out and give me your feedback https://t.co/FF72E0GR1s
๐Ÿ‘€ 1
๐Ÿ‘ 1
๐Ÿ™‚ 1
t
I think there is an easier way. but i have not played with it yet. Retrofit adds an implicit
Tag
called
Invocation
that has a reference to the
Method
at which point you can query for custom annotations via the normal reflection api's. All of which can be done in an interceptor without the need for a custom call adapter factory.
Been meaning to POC this out. let me see what I can throw together today and i'll post back here
๐Ÿ‘ 1
single base class that is pretty damn simple. then the test file has an example use-case
something wrong in the way I am mutating the request but proves that it at least picked up the annotation and tried to muck with it
o
very cool that's a better and simpler way to do it ๐Ÿ‘
i wasn't aware that retrofit add
Invocation
Tag to all its requests
t
I knew about tag. but Jesse wilson is who got me thinking about how to do some of this easier. https://twitter.com/jessewilson/status/1231569857986035712
only other note i'd add about that, is the call to
Method.getAnnotation(Class<T>)
might be expensive and worth caching in a map. ie
val annotationCache: MutableMap<Method, T>
where T is the annotation.
๐Ÿ‘ 1
o
yes totally agree caching annotation worth it