Update README instructions for converting existing ViewHolders
See original GitHub issueI’m using trying to convert an existing Java ViewHolder to use with Groupie. In the docs the only thing I can find about this is under the Kotlin section (I’m only sadly using Java and not Kotlin, but the Kotlin section was the only place that mentioned existing ViewHolders) and it says
If you’re converting existing ViewHolders, you can leave them as they are by making an
Item<MyViewHolder>
.
The way I interpret that is that, if I leave my existing ViewHolder alone I should be able to use it seamlessly with Groupie.
public static class MyViewHolder extends RecyclerView.ViewHolder {
//TextViews and stuff
public MyViewHolder(View itemView) {
super(itemView);
//Butterknife.bind(...)
}
//bindTo(){
//Method recommended by Yigit to be implemented in each VH to handle the actual binding
//}
}
This existing RecyclerView.ViewHolder
lives in MyCustomAdapter.java
Now I go to create my Item
since I want to use Groupie.
public class MyItem extends Item<MyCustomAdapter. MyViewHolder>{
@Override
public void bind(@NonNull MyCustomAdapter. MyViewHolder viewHolder, int position) {
//bind
}
@Override
public int getLayout() {
return R.layout.my_item;
}
}
I get an error message in the IDE on the first line of the last code snippet (public class MyItem extends Item< MyCustomAdapter. MyViewHolder>{
) specifically under <MyCustomAdapter. MyViewHolder>
that says
Type parameter
com.myapp.MyCustomAdapter.MyViewHolder
is not within its bound; should extendcom.xwray.groupie.ViewHolder
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
I updated the README to explicitly include a section on legacy viewholders. If you think it could be more clear PRs welcome 😃
Thank you so much @aayushthakur . It’s unbelievable that I solved this problem and have now forgotten (twice) that I did so.
I will make a point to update the README to explain. It’s not difficult but it’s definitely not intuitive!