devunwired / recyclerview-playground

Examples of RecyclerView use and custom LayoutManager implementations
MIT License
1.25k stars 270 forks source link

A question about Filterable #2

Closed AndroidDeveloperLB closed 9 years ago

AndroidDeveloperLB commented 10 years ago

Has handling of filtering of the items using RecyclerView changed over the normal way of ListView ? How should it be handled now?

devunwired commented 9 years ago

Filterable was supported by the common adapter types with ListView/AdapterView (e.g. ArrayAdapter, CursorAdapter). The RecyclerView.Adapter does not have this support built-in. The best place to apply filters to your data set is definitely still in your adapter subclass, but you will have to do a bit of work to integrate the feature yourself as it is not baked in (from what I can tell).

AndroidDeveloperLB commented 9 years ago

What do you mean? that by using RecyclerView, I won't be able to filter data? That I would need to imitate the way it worked for AdapterView ?

devunwired commented 9 years ago

I mean that you will need to build the logic to filter the dataset your adapter presents to the view yourself. The framework view isn't going to do any lifting here. You can choose whether to build that on top of Filterable or your own concoction.

AndroidDeveloperLB commented 9 years ago

This sounds to me as if only a part of the RecyclerView was implemented, since it's supposed to replace ListView...

devunwired commented 9 years ago

Anyone who tells you that RecyclerView is supposed to replace ListView is lying to you and to themselves. RecyclerView is an extensible widget that allows you to create collections that weren't possible in the previous framework (including something that resembles a vertical list), but there are many focused features (like filtering, fast scrolling, choice modes, header/footer views) that will always be unique to ListView.

AndroidDeveloperLB commented 9 years ago

Well that's what Google called it "ListView v2" ... Surely it's possible to use all of ListView's features on RecyclerView, no?

devunwired commented 9 years ago

They did throw that term out at I/O, but if you ask them they will equivocate on what that really means. I'm certain it's possible, but that doesn't mean Google will do it. I imagine RecyclerView will see more new features down the road, but I doubt the feature sets of the two will harmonize completely anytime in the foreseeable future. Some of those features (e.g. fast indexed scrolling) don't map well to a non-vertical scrolling view.

AndroidDeveloperLB commented 9 years ago

True, they've already tried to do so with GridLayout, and I still think the others are way easier to use and have less issues. Recently I've even made a post about it, trying to optimize the way my app works (http://stackoverflow.com/q/26619445) .

Do you think it would be hard to convert a complicated adapter of a listView to RecyclerView? What do you think are the advantages of using RecyclerView? All I've found is that it gets divided to multiple class, based on their purpose, and I think it's easier to handle animations.

devunwired commented 9 years ago

Primarily better animation support plus any-directional layouts and scrolling. It also disables much of the things by default that developers would intentionally turn off in many modern ListView implementations (scrollbars, dividers, default selectors). The decorator features are also a nice way of providing child view margins.

AndroidDeveloperLB commented 9 years ago

I see. Thank you.