Skip to content
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

Populate list of items #12

Closed
danielpassos opened this issue Dec 3, 2015 · 4 comments
Closed

Populate list of items #12

danielpassos opened this issue Dec 3, 2015 · 4 comments
Milestone

Comments

@danielpassos
Copy link
Contributor

It is not so clear only looking for the API or reading the wiki, you need populate the list of items in FlexibleAdapter using the method filterItems. If you don't do that you will get a RuntimeException.

IMHO populate the list of items should be a construction responsabilite. Wdyt?.

@davideas
Copy link
Owner

davideas commented Dec 5, 2015

@danielpassos how do you get RuntimeException? In my example if I remove the call from updateDataset (the only point where is called) it simply doesn't filter anymore.

filterItems is a new function, but it's an option for the developer to call it if he wants to use the search, but being protected it cannot be called from the Activity and it must be called from the adapter implementation.

You also say that the constructor should accept the list and assign it to mItems?

@danielpassos
Copy link
Contributor Author

how do you get RuntimeException? In my example if I remove the call from updateDataset (the only point where is called) it simply doesn't filter anymore.

I mean if you don't call updateDataset nor filterItems you got a NPE. I'll create a new blank project to show you the problem.

You also say that the constructor should accept the list and assign it to mItems?

Yes. I think it's more natural/intuitive/commons for developer. In 100% of adapters, we pass the list of data in constructor (like in ArrayAdapter). It make sure we always will have the data set

@davideas
Copy link
Owner

davideas commented Dec 5, 2015

The reason the constructor doesn't accept the list, it's that updateDataset is called often in the Activity, so it's nice to centralize the point where the data is loaded and I've identified that method.
I can try but I need some time to apply the changes in a convenient way.

PS. Better if you keep tabulation to indent the code.

@davideas
Copy link
Owner

davideas commented Dec 6, 2015

For the moment I added a constructor that accept the list and initialize mItems.
Then, it's always the developer that should call super(List) or still initialize mItems by himself in his Adapter implementation.

@davideas davideas added this to the 4.2.0 milestone Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants