xaverkapeller / SortedListAdapter

The RecyclerView.Adapter that makes your life easy!
https://wrdlbrnft.github.io/SortedListAdapter/
MIT License
49 stars 13 forks source link

Native ads support #5

Open stanbar opened 7 years ago

stanbar commented 7 years ago

Hello. Is there any way to support different viewTypes that doesn't extends Model like AdExpressViewHolder ? The problem is that in your implementation onCreateViewHolder must return something that extend Model class ViewHolder<? extends ExampleModel> onCreateViewHolder Is it possible in my situation ?

@Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        final View v = inflater.inflate(viewType, parent, false);
        if (viewType == VIEW_TYPE_COLLAPSED) {
            return new CollapsedVH(v, this);
        } else if (viewType == VIEW_TYPE_EXPANDED) {
            return new ExpandedVH(v, this);
        } else if (viewType == VIEW_TYPE_AD_EXPRESS) {
            return new AdExpressViewHolder(v);
        } else return null;
    }
xaverkapeller commented 7 years ago

Hi! At the moment this is not possible. The Adapter has to enforce that type constraint to allow for the simplified binding functionality. However there are ways to still have the simplified binding feature and allow for any type of ViewHolder to be used. I am going to look into this at some point in the near future. In the meantime this issue is going to stay open until I either implemented this change or decided not to implement it at all.