Guest User

Untitled

a guest
Nov 21st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. @Override
  2. public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  3.  
  4. Log.i(TAG, "Search text: " + charSequence);
  5. List<AllAttendance> list = new ArrayList<>();
  6.  
  7. //filter from all List
  8.  
  9. if (rbtnAll.isChecked())
  10. list = filter(mAttendanceList, charSequence);
  11. else if (rbtnPending.isChecked())
  12. list = filter(mPendingAttendanceList, charSequence);
  13.  
  14. setAdapterData(list);
  15. rvAttendance.scrollToPosition(0);
  16. }
  17.  
  18. private List<AllAttendance> filter(List<AllAttendance> mAttendanceList, CharSequence charSequence) {
  19.  
  20. String text = String.valueOf(charSequence);
  21. text = text.toLowerCase();
  22.  
  23. List<AllAttendance> filteredList = new ArrayList<>();
  24. for (AllAttendance attendance : mAttendanceList){
  25.  
  26. if (attendance.getMandalName().toLowerCase().contains(text) || attendance.getSabhaName().toLowerCase().contains(text) || attendance.getSabhaDate().toLowerCase().contains(text))
  27. filteredList.add(attendance);
  28. }
  29. return filteredList;
  30. }
Add Comment
Please, Sign In to add comment