mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
feat: as an option show the item's rating and whether it is marked as a favorite
This commit is contained in:
parent
4b9eaa8c3d
commit
58d540b939
12 changed files with 70 additions and 14 deletions
|
|
@ -17,6 +17,7 @@ import com.cappielloantonio.tempo.subsonic.models.Child;
|
|||
import com.cappielloantonio.tempo.util.Constants;
|
||||
import com.cappielloantonio.tempo.util.DownloadUtil;
|
||||
import com.cappielloantonio.tempo.util.MusicUtil;
|
||||
import com.cappielloantonio.tempo.util.Preferences;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
|
@ -59,11 +60,13 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
song.getArtist()
|
||||
),
|
||||
MusicUtil.getReadableDurationString(song.getDuration(), false),
|
||||
MusicUtil.getReadableAudioQualityString(song)
|
||||
MusicUtil.getReadableAudioQualityString(song),
|
||||
MusicUtil.getRatingNumber(song.getUserRating())
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
holder.item.trackNumberTextView.setText(MusicUtil.getReadableTrackNumber(holder.itemView.getContext(), song.getTrack()));
|
||||
if (Preferences.showItemRating()) holder.item.preferredIcon.setVisibility(song.getStarred() != null ? View.VISIBLE : View.GONE);
|
||||
|
||||
if (DownloadUtil.getDownloadTracker(holder.itemView.getContext()).isDownloaded(song.getId())) {
|
||||
holder.item.searchResultDownloadIndicatorImageView.setVisibility(View.VISIBLE);
|
||||
|
|
|
|||
|
|
@ -195,6 +195,21 @@ public class MusicUtil {
|
|||
return context.getString(R.string.label_placeholder);
|
||||
}
|
||||
|
||||
public static String getRatingNumber(Integer ratingNumber) {
|
||||
if (ratingNumber == null || !Preferences.showItemRating()) return "";
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("•");
|
||||
builder.append(" ");
|
||||
|
||||
for (int i = 0; i < ratingNumber; i++) {
|
||||
builder.append("★");
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static String forceReadableString(String string) {
|
||||
if (string != null) {
|
||||
return getReadableString(string)
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ object Preferences {
|
|||
private const val ALWAYS_ON_DISPLAY = "always_on_display"
|
||||
private const val AUDIO_QUALITY_PER_ITEM = "audio_quality_per_item"
|
||||
private const val HOME_SECTOR_LIST = "home_sector_list"
|
||||
private const val RATING_PER_ITEM = "rating_per_item"
|
||||
|
||||
|
||||
@JvmStatic
|
||||
|
|
@ -396,4 +397,9 @@ object Preferences {
|
|||
fun setHomeSectorList(extension: List<HomeSector>?) {
|
||||
App.getInstance().preferences.edit().putString(HOME_SECTOR_LIST, Gson().toJson(extension)).apply()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun showItemRating(): Boolean {
|
||||
return App.getInstance().preferences.getBoolean(RATING_PER_ITEM, false)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue