Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to put "custom conversions" with @BindingConversion in Android Data Binding and why?

The official documentation on custom conversions in Android Data Binding is pretty scant. It says to create a static converter with the method signature to match the conversion, and annotate it with @BindingConversion, but it doesn't say where it will look for those methods. Does it just scan every static method in the whole app for BindingConversion annotations? Should I create a specific class for these conversions? Should it be in a specific package? Obviously it should be public. Please elaborate.

like image 217
Travis Well Avatar asked Jan 18 '26 19:01

Travis Well


1 Answers

Yes, it can be any class in any package. It uses the java annotation processor, so it only picks up the annotated methods.

like image 193
George Mount Avatar answered Jan 20 '26 10:01

George Mount