mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 01:53:31 +00:00
Reimplemented a basic track download functionality
This commit is contained in:
parent
b7a77cf32b
commit
dee845ebff
17 changed files with 154 additions and 214 deletions
|
|
@ -16,6 +16,8 @@ import com.cappielloantonio.play.model.Song;
|
|||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.QueueRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
import com.cappielloantonio.play.util.DownloadUtil;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -45,11 +47,6 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
|||
return queueRepository.getLiveQueue();
|
||||
}
|
||||
|
||||
public Song getCurrentSong() {
|
||||
// return MusicPlayerRemote.getCurrentSong();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setFavorite(Context context, Song song) {
|
||||
if (song != null) {
|
||||
if (song.isFavorite()) {
|
||||
|
|
@ -60,7 +57,7 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
|||
song.setFavorite(true);
|
||||
|
||||
if (PreferenceUtil.getInstance(context).isStarredSyncEnabled()) {
|
||||
// DownloadUtil.getDownloadTracker(context).download(Collections.singletonList(song), null, null);
|
||||
DownloadUtil.getDownloadTracker(context).download(MappingUtil.mapMediaItem(context, song, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -71,7 +68,6 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
|
|||
}
|
||||
|
||||
public void refreshSongInfo(LifecycleOwner owner, Song song) {
|
||||
// songLiveData.postValue(song);
|
||||
songRepository.getSongLyrics(song).observe(owner, lyricsLiveData::postValue);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import android.content.Context;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
|
|
@ -15,10 +14,9 @@ import com.cappielloantonio.play.repository.AlbumRepository;
|
|||
import com.cappielloantonio.play.repository.ArtistRepository;
|
||||
import com.cappielloantonio.play.repository.SongRepository;
|
||||
import com.cappielloantonio.play.util.DownloadUtil;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class SongBottomSheetViewModel extends AndroidViewModel {
|
||||
private final SongRepository songRepository;
|
||||
private final AlbumRepository albumRepository;
|
||||
|
|
@ -50,8 +48,8 @@ public class SongBottomSheetViewModel extends AndroidViewModel {
|
|||
songRepository.star(song.getId());
|
||||
song.setFavorite(true);
|
||||
|
||||
if(PreferenceUtil.getInstance(context).isStarredSyncEnabled()) {
|
||||
// DownloadUtil.getDownloadTracker(context).download(Collections.singletonList(song), null, null);
|
||||
if (PreferenceUtil.getInstance(context).isStarredSyncEnabled()) {
|
||||
DownloadUtil.getDownloadTracker(context).download(MappingUtil.mapMediaItem(context, song, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue