mirror of
https://github.com/antebudimir/tempus.git
synced 2026-04-16 08:47:24 +00:00
feat: add sorting and search functionality for song list
This commit is contained in:
parent
780f1c3a2e
commit
9e6926fc97
8 changed files with 198 additions and 9 deletions
|
|
@ -26,6 +26,7 @@ import com.cappielloantonio.tempo.util.Preferences;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
|
@ -230,4 +231,20 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void sort(String order) {
|
||||
switch (order) {
|
||||
case Constants.MEDIA_BY_TITLE:
|
||||
songs.sort(Comparator.comparing(Child::getTitle));
|
||||
break;
|
||||
case Constants.MEDIA_MOST_RECENTLY_STARRED:
|
||||
songs.sort(Comparator.comparing(Child::getStarred, Comparator.nullsLast(Comparator.reverseOrder())));
|
||||
break;
|
||||
case Constants.MEDIA_LEAST_RECENTLY_STARRED:
|
||||
songs.sort(Comparator.comparing(Child::getStarred, Comparator.nullsLast(Comparator.naturalOrder())));
|
||||
break;
|
||||
}
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue