当前位置:网站首页>Compile time annotation automatically generates dataholder

Compile time annotation automatically generates dataholder

2022-06-21 14:04:00 Funny 2233

Written by Android DataAdapter as well as DataHolder It has been a very troublesome time , So I want to use compile time annotations without affecting the performance of automatic generation DataAdapter as well as DataHolder But a closer look reveals , To unify DataAdapter Is a very troublesome thing and DataAdapter Not only manage data, but also manage events , Events require a variety of resources , Therefore, it is automatically generated after the last step DataHolder It mainly manages data

Use effect

 Insert picture description here
The default data binding is to use map Mapping to various situations , The scenario has been processed , You can add custom processors , You can also add a naming processor to handle special view data binding
 Insert picture description here
Use JavaBean Corresponding to the view object , Because reflection cannot be used at compile time , Can't parse layout.xml Get the corresponding type information , You can only write the full class name in this way
 Insert picture description here
Use the tool class to pass JavaBean Get the corresponding DataHolder object

Generated files

 Insert picture description here

Project structure

 Insert picture description here
api: Exposure oriented api
compiler: Compile time annotation processor
share:api,compiler Shared objects , because api Android features are required , and compiler To use AbstractProcessor, Cannot rely directly on api project

Code cloud address

https://gitee.com/shaokang123/auto-data-holder

原网站

版权声明
本文为[Funny 2233]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202221430106230.html