drakeet / MultiType

Flexible multiple types for Android RecyclerView.
Apache License 2.0
5.76k stars 751 forks source link

How can i remove element from the list if it is not found withClassLinker? #201

Closed hk4774 closed 6 years ago

hk4774 commented 6 years ago
.withClassLinker(test -> {
                    switch (some condition from test) {
                        case test.data:
                            return Test1.class;
                        case test.data2:
                            return Test2.class;
                        default:
                            // rather returning something...delete the element from the arraylist.
                       }
}
drakeet commented 6 years ago

You can not do that. If you can judge that you are going to delete it, why do not you check when add it to your items?

If you just want to hide it, you can provide an ItemViewBinder with Object bound and return it as the default. You can set this binder height to 0 so that it is not visible.

But this is not recommended, the best practice is to throw an exception, because you should check when add.

drakeet commented 6 years ago

MultiType is just your type distribution framework and it should not change your data.