this.fillEmpty = fillEmpty;
}
@Override
protected Playlist doInBackground() throws Exception {
Playlist newPlaylist = new Playlist();
String str = search.toLowerCase().trim();
String[] text = str.split("\\s+");
if (!str.isEmpty() && text.length > 0) {
for (int i = 0, playlistSize = playlist.size(); i < playlistSize; i++) {
Track track = playlist.get(i);
boolean hasText[] = new boolean[text.length];
for (FieldKey field : fields) {
FieldValues values = track.getTrackData().getTagFieldValues(field);
if (values != null) {
for (int k = 0; k < values.size(); k++) {
String value = values.get(k);
if (!Util.isEmpty(value)) {
value = value.toLowerCase();
String[] vals = value.split("\\s+");
for (String val : vals) {
for (int j = 0, textLength = text.length; j < textLength; j++) {
String s = text[j];
if (val.startsWith(s)) {
hasText[j] = true;
}
}
}
}
}
}
}
boolean toAdd = true;
for (boolean b : hasText) {
toAdd &= b;
}
if (toAdd) {
newPlaylist.add(track);
viewToModelList.add(i);
}
}
} else if (fillEmpty) {
newPlaylist.addAll(playlist);
}
return newPlaylist;
}