mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 01:53:31 +00:00
Fix song duration visualization
This commit is contained in:
parent
8f72e4234c
commit
8f08b12b69
8 changed files with 34 additions and 11 deletions
|
|
@ -50,7 +50,7 @@ public class PlayerSongQueueAdapter extends RecyclerView.Adapter<PlayerSongQueue
|
|||
|
||||
holder.songTitle.setText(song.getTitle());
|
||||
holder.songArtist.setText(song.getArtistName());
|
||||
holder.songDuration.setText(MusicUtil.getReadableDurationString(song.getDuration()));
|
||||
holder.songDuration.setText(MusicUtil.getReadableDurationString(song.getDuration(), false));
|
||||
|
||||
CustomGlideRequest.Builder
|
||||
.from(context, song.getPrimary(), song.getBlurHash(), CustomGlideRequest.SONG_PIC)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class SongHorizontalAdapter extends RecyclerView.Adapter<SongHorizontalAd
|
|||
|
||||
holder.songTitle.setText(song.getTitle());
|
||||
holder.songArtist.setText(song.getArtistName());
|
||||
holder.songDuration.setText(MusicUtil.getReadableDurationString(song.getDuration()));
|
||||
holder.songDuration.setText(MusicUtil.getReadableDurationString(song.getDuration(), false));
|
||||
|
||||
if (song.isOffline()) {
|
||||
holder.downloadIndicator.setVisibility(View.VISIBLE);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import com.cappielloantonio.play.model.Queue;
|
|||
import com.cappielloantonio.play.model.RecentSearch;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
|
||||
@Database(entities = {Queue.class, RecentSearch.class}, version = 2, exportSchema = false)
|
||||
@Database(entities = {Queue.class, RecentSearch.class}, version = 3, exportSchema = false)
|
||||
public abstract class AppDatabase extends RoomDatabase {
|
||||
private static final String TAG = "AppDatabase";
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,10 @@ public class Queue {
|
|||
@ColumnInfo(name = "primary")
|
||||
private String primary;
|
||||
|
||||
public Queue(int trackOrder, String songID, String title, String albumId, String albumName, String artistId, String artistName, String primary) {
|
||||
@ColumnInfo(name = "duration")
|
||||
private long duration;
|
||||
|
||||
public Queue(int trackOrder, String songID, String title, String albumId, String albumName, String artistId, String artistName, String primary, long duration) {
|
||||
this.trackOrder = trackOrder;
|
||||
this.songID = songID;
|
||||
this.title = title;
|
||||
|
|
@ -42,6 +45,7 @@ public class Queue {
|
|||
this.artistId = artistId;
|
||||
this.artistName = artistName;
|
||||
this.primary = primary;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public int getTrackOrder() {
|
||||
|
|
@ -107,4 +111,12 @@ public class Queue {
|
|||
public void setPrimary(String primary) {
|
||||
this.primary = primary;
|
||||
}
|
||||
|
||||
public long getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ public class Song implements Parcelable {
|
|||
this.artistId = queue.getArtistId();
|
||||
this.artistName = queue.getArtistName();
|
||||
this.primary = queue.getPrimary();
|
||||
this.duration = queue.getDuration();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ public class PlayerBottomSheetFragment extends Fragment implements MusicServiceE
|
|||
bind.playerBodyLayout.playerBigSeekBar.setMax(total);
|
||||
bind.playerBodyLayout.playerBigSeekBar.setProgress(progress);
|
||||
|
||||
bind.playerBodyLayout.playerBigSongTimeIn.setText(MusicUtil.getReadableDurationString(progress));
|
||||
bind.playerBodyLayout.playerBigSongDuration.setText(MusicUtil.getReadableDurationString(total));
|
||||
bind.playerBodyLayout.playerBigSongTimeIn.setText(MusicUtil.getReadableDurationString(progress, true));
|
||||
bind.playerBodyLayout.playerBigSongDuration.setText(MusicUtil.getReadableDurationString(total, true));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,9 +31,19 @@ public class MusicUtil {
|
|||
"&id=" + song.getId();
|
||||
}
|
||||
|
||||
public static String getReadableDurationString(long songDurationMillis) {
|
||||
long minutes = (songDurationMillis / 1000) / 60;
|
||||
long seconds = (songDurationMillis / 1000) % 60;
|
||||
public static String getReadableDurationString(long duration, boolean millis) {
|
||||
long minutes = 0;
|
||||
long seconds = 0;
|
||||
|
||||
if(millis) {
|
||||
minutes = (duration / 1000) / 60;
|
||||
seconds = (duration / 1000) % 60;
|
||||
}
|
||||
else {
|
||||
minutes = duration / 60;
|
||||
seconds = duration % 60;
|
||||
}
|
||||
|
||||
|
||||
if (minutes < 60) {
|
||||
return String.format(Locale.getDefault(), "%01d:%02d", minutes, seconds);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ public class QueueUtil {
|
|||
private static final String TAG = "QueueUtil";
|
||||
|
||||
public static Queue getQueueElementFromSong(Song song, int startingPosition) {
|
||||
return new Queue(startingPosition, song.getId(), song.getTitle(), song.getAlbumId(), song.getAlbumName(), song.getArtistId(), song.getArtistName(), song.getPrimary());
|
||||
return new Queue(startingPosition, song.getId(), song.getTitle(), song.getAlbumId(), song.getAlbumName(), song.getArtistId(), song.getArtistName(), song.getPrimary(), song.getDuration());
|
||||
}
|
||||
|
||||
public static List<Queue> getQueueElementsFromSongs(List<Song> songs) {
|
||||
|
|
@ -18,7 +18,7 @@ public class QueueUtil {
|
|||
List<Queue> queue = new ArrayList<>();
|
||||
|
||||
for (Song song : songs) {
|
||||
queue.add(new Queue(counter, song.getId(), song.getTitle(), song.getAlbumId(), song.getAlbumName(), song.getArtistId(), song.getArtistName(), song.getPrimary()));
|
||||
queue.add(new Queue(counter, song.getId(), song.getTitle(), song.getAlbumId(), song.getAlbumName(), song.getArtistId(), song.getArtistName(), song.getPrimary(), song.getDuration()));
|
||||
counter++;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue