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

[TIMOB-17456]: Treat 'null' values as '' for searchableText #5949

Merged
merged 3 commits into from
Aug 21, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -933,13 +933,17 @@ public void applyFilter(String searchText) {
//Add new results
for (int i = 0; i < listItemData.size(); ++i) {
String searchableText = listItemData.get(i).getSearchableText();
//Treat null as ""
if (searchableText == null) {
searchableText = "";
}
//Handle case sensitivity
if (caseInsensitive) {
searchText = searchText.toLowerCase();
searchableText = searchableText.toLowerCase();
}
//String comparison
if (searchableText != null && searchableText.contains(searchText)) {
if (searchableText.contains(searchText)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it crash if searchableText is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's handled above, converting null to ""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if searchableText is null and searchText is ""? I think when searchableText is not specified, it means the search functionality is not enabled. No matter you want to show all the items or hide all the items in this case, you can treat this is a special situation and take care of it at the beginning so it does not need to go through all the following logic and code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will initialize searchableText to "" instead of null.

filterIndices.add(i);
}
}
Expand Down