How about an interface with name ViewDataBinding, providing necessary methods on it. along with one bind(Object) method to pass data for actual binding.
So on the user's part, user now will have to create two class file per view item, one extending Item, other implementing ViewDataBinding.
I'm working on this now. My current approach (so far so good) is to split the library so non-data-binding Groupie doesn't require or include it. Of course, it will be a breaking change.
I'm considering this naming convention: you pick one of
com.xwray.groupie:groupie-databinding:2.0.0 [Data binding]
or
com.xwray.groupie:groupie:2.0.0 [No data binding]
The only problem I have with this is it looks like no data binding is the default or suggested version. Obviously, all the current users use data binding and I'd hate to sow confusion (not to mention, I would like to steer undecided people to data binding as a default). I'm also considering instead something like groupie-vanilla for the non-data-binding version. Input welcome. :)
Hi Lisa,
I completely see your point for databinding as default and I greatly appreciate your effort to provide also a non databinding version.
If your main goal is to favorite the version with databinding, having that version as default lib name makes totally sense 馃憤馃徎
I'm pretty sure that vanilla gives enough information or creates enough curiosity to make users to check this variant.
Can't wait for a ViewHolder version to try it out in my projects 馃槏
Thanks @lisawray for the amazing work!!
Personally I think that the best way would be to provide the core without any data binding, and then have people that want to use it add the relative dependency. I understand that this would be a breaking change for existing users, but this is also a 2.0 version so breaking changes are kind of expected :)
Agree with @Takhion. @lisawray, the naming convention you listed above will work fine since it would be a breaking change anyway.
Preview version WITHOUT data binding is now available:
compile 'com.xwray:groupie:2.0.0-alpha1'
Preview version WITH data binding may take a few hours to make it to jcenter:
compile 'com.xwray:groupie-databinding:2.0.0-alpha1'
Existing code: MyItem extends Item should change to MyItem extends BindableItem.
All other references to Item and Group should be able to remain as-is.
A fun side effect of the rewrite is that you can mix binding and non-binding Items, so if you have a large RecyclerView you're thinking about switching over, you can now do it gradually.
I'm planning to cut the production build after I give them a full once over for playing nice with Kotlin, hopefully next week!
I refined this a little: https://github.com/lisawray/groupie/pull/96
If you use Kotlin Activity Extensions, then you can use groupie without creating any view holders, just the same as data binding. I like that a lot.
Still not in love: you have to explicitly declare Item<ViewHolder>() and GroupAdapter<ViewHolder>() for the vanilla version. Continuing to think about naming to resolve the issue.
Most helpful comment
Preview version WITHOUT data binding is now available:
compile 'com.xwray:groupie:2.0.0-alpha1'
Preview version WITH data binding may take a few hours to make it to jcenter:
compile 'com.xwray:groupie-databinding:2.0.0-alpha1'
Existing code:
MyItem extends Itemshould change toMyItem extends BindableItem.All other references to
ItemandGroupshould be able to remain as-is.A fun side effect of the rewrite is that you can mix binding and non-binding Items, so if you have a large RecyclerView you're thinking about switching over, you can now do it gradually.
I'm planning to cut the production build after I give them a full once over for playing nice with Kotlin, hopefully next week!