Implemented preference for starred-sync support

This commit is contained in:
CappielloAntonio 2021-09-13 11:28:48 +02:00
parent 147560224f
commit 575c77baf9
11 changed files with 168 additions and 5 deletions

View file

@ -1,6 +1,7 @@
package com.cappielloantonio.play.viewmodel;
import android.app.Application;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
@ -11,7 +12,9 @@ import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.QueueRepository;
import com.cappielloantonio.play.repository.SongRepository;
import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.util.DownloadUtil;
import java.util.Collections;
import java.util.List;
public class PlayerBottomSheetViewModel extends AndroidViewModel {
@ -40,7 +43,7 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
}
public void setFavorite() {
public void setFavorite(Context context) {
Song song = MusicPlayerRemote.getCurrentSong();
if (song != null) {
@ -50,6 +53,7 @@ public class PlayerBottomSheetViewModel extends AndroidViewModel {
} else {
songRepository.star(song.getId());
song.setFavorite(true);
DownloadUtil.getDownloadTracker(context).download(Collections.singletonList(song), null, null);
}
}
}