I have android search query and performing filtering. All cases works exept one letter search - "ә" (kazakh language)
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
final List<SongModel> l = dc.songList;
int count = l.size();
List<SongModel> nSongList = new ArrayList<SongModel>(count);
for (SongModel p : l) {
if ("ә".contains(constraint.toString())) {
nSongList.add(p);
}
}
results.values = nSongList;
results.count = nSongList.size();
return results;
}
If I enter to search field "ә" letter they are not equal in my if case. "ә".contains(constraint.toString()) returns false.
I changed ASCII code of my char(letter): s.replace((char)601,(char)1241); Because performFiltering gives me 'ә' letter as 601. Then I changed it to correct one 1241. And now it works properly in my case.
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults results = new FilterResults();
final List<SongModel> l = dc.songList;
int count = l.size();
List<SongModel> nSongList = new ArrayList<SongModel>(count);
String s = constraint.toString();
s = s.replace((char)601,(char)1241);
// or s.replace('\u0259','\u04D9');
for (SongModel p : l) {
if (p.getName().contains(s)) {
nSongList.add(p);
}
}
results.values = nSongList;
results.count = nSongList.size();
return results;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With