New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ViewHolder as InnerClass of a Adapter #20
Comments
I'm not sure how this code can help you to have an ViewHolder inner of an adapter. |
example ViewHolder
if you put ViewHolder inside a Adapter ,the constructor is auto modified by the Adapter privately like this,the first paramater is the outter Adapter self
so that's is why we add the code below to make it work。the parameterTypes[0] is the adpater,
|
If your call is just to have access to the adapter within your EfficientViewHolder, why don't override the method "generateViewHolder" and call a method "setAdapter" into? good question. we have consider this method,two reason not use it 1: we want easy to write viewHolder,just like a inner class can share outter class;frameWork should do this work.2: add this feature to improve the range of ViewHolder exist type is fine |
Ok I got your point, thanks. Make sense. Any reason you're using an inner class over a static-nested class? You need an access to the adapter within your ViewHolder? |
because in our project, some time the information is not satisfy by the model provided;so we need a link to adapter |
Ok, I would avoid using an inner class for that but I got your point and agree that many developers would love to have this fix. I will work on that (or you can still open a PR, so you will be an official contributor of the project ;) ) but will change few stuffs:
Thanks again for your contribution |
i am zheXian,thanks for inviting and this good project, i have used it for the recyclerView's adapter in my project and feel good i also change the sequence of isAssignableFrom() ,because this method is used to check whether the paramater can be cast to the caller's class.,so the class of paramater should be the caller's class or it's subClass
here's the code
|
support for viewHolder in adapter is added in pr #22 |
some time,we need the ViewHolder to be a innerClass of a Adapter ,incase to share the variable of it。
so here is the code we modified to support this feature。it both support single ViewHolder class or as innerClass in Adapter。
AdapterHelper.class
EfficientRecyclerAdapter.class
The text was updated successfully, but these errors were encountered: