Created
June 15, 2015 11:07
-
-
Save kmdupr33/7d70bdc59cea4e35c8f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class ArrayFilter extends Filter { | |
@Override | |
protected FilterResults performFiltering(CharSequence prefix) { | |
FilterResults results = new FilterResults(); | |
if (prefix == null || prefix.length() == 0) { | |
ArrayList<T> list; | |
synchronized (mLock) { | |
list = new ArrayList<T>(mOriginalValues); | |
} | |
results.values = list; | |
results.count = list.size(); | |
} else { | |
//... | |
final ArrayList<T> newValues = new ArrayList<T>(); | |
for (int i = 0; i < count; i++) { | |
final T value = values.get(i); | |
final String valueText = value.toString().toLowerCase(); | |
// First match against the whole, non-splitted value | |
if (valueText.startsWith(prefixString)) { | |
newValues.add(value); | |
} else { | |
//... | |
} | |
} | |
} | |
return results; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment