Guest User

Untitled

a guest
Apr 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. ArrayList<ContactItem> numberResults = new ArrayList<ContactItem>();
  2. Set<ContactItem> allResults = new LinkedHashSet<ContactItem>();
  3. static ArrayList<ContactItem> contacts = new ArrayList<ContactItem>();
  4. + static String input;
  5.  
  6. public T9Search(Context context) {
  7. mContext = context;
  8. @@ -126,17 +127,20 @@ class T9Search {
  9. public T9SearchResult search(String number) {
  10. nameResults.clear();
  11. numberResults.clear();
  12. - allResults.clear();
  13. number=number.replaceAll( "[^\\d]", "" );
  14. + if (input== null || number.length() < input.length()) {
  15. + allResults.clear();
  16. + }
  17. + input = number;
  18. int pos = 0;
  19. mSortMode = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(mContext).getString("t9_sort", "1"));
  20. //Go through each contact
  21. - for (ContactItem item : contacts) {
  22. - if (item.normalNumber.contains(number)) {
  23. - item.matchId = item.normalNumber.indexOf(number);
  24. + for (ContactItem item : (number.length() < input.length() ? contacts : allResults)) {
Add Comment
Please, Sign In to add comment