litho icon indicating copy to clipboard operation
litho copied to clipboard

Create an AdapterProxy to directly call through to underlying Adapter

Open vinc3m1 opened this issue 7 years ago • 8 comments

vinc3m1 avatar Jan 26 '19 02:01 vinc3m1

Tests to come (probably next week) but let me know what you think about the API

vinc3m1 avatar Jan 26 '19 02:01 vinc3m1

@vinc3m1, is the purpose of this diff to avoid using ViewRenderInfo and instead use Adapter interface directly? If that's the only intention, I'm not sure whether the benefits outweigh the introduced complexity (with this we'll have three ways of handling views: components, ViewRenderInfo and AdapterProxy). One thing that comes to my mind when using this approach is to avoid calling findViewById and use ViewHolders directly outside.

cc @pasqualeanatriello, thoughts?

muraziz avatar Jan 28 '19 15:01 muraziz

We've definitely seen some metrics improvements and are exclusively using this over ViewRenderInfo actually. The improvements are reduced overhead, much simpler integration with existing RV Adapters, and fixed some bugs when dealing with insert/remove functions when proxying to an underlying adapter (due to positions no longer matching)

The main issue with ViewRenderInfos is that the position isn't passed through its function calls so we can't directly proxy to the underlying adapter without tracking the positions and updating them on insert/remove, which gets quite complicated.

vinc3m1 avatar Jan 29 '19 00:01 vinc3m1

@vinc3m1 I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project.

facebook-github-bot avatar Feb 03 '19 18:02 facebook-github-bot

This seems interesting, can you explain more how it's used? Like, is this when embedding a RecyclerBinder within part of an existing RecyclerView? Or is it embedding an existing RV inside a RB?

astreet avatar Jul 10 '19 21:07 astreet

When adding RecyclerBinder to an existing RecyclerView + Adapter, this allows the adapter calls to go directly through to the underlying Adapter without the overhead/indirection/API differences of using a ViewRenderInfo for ever row.

vinc3m1 avatar Jul 10 '19 22:07 vinc3m1

Can you maybe give a code example of how the API would be used? (in the Javadocs would be even better)

astreet avatar Jul 11 '19 10:07 astreet

I think this is an interesting idea, and it would be great to make RecyclerBinder more flexible in how it integrates with existing RecyclerViews. I think this API in this form might be complicating things a bit though; this is providing an Adapter proxy which is only capable of creating ViewHolders, but doesn't also handle operations. It's basically just a view creator&binder so calling it an adaptor might be a bit confusing. Would it make sense for this use case to pass a custom adapter to the RecyclerBinder instead?

mihaelao avatar Jul 16 '19 16:07 mihaelao