mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 09:53:33 +00:00
chg: Move the playlist duplicates option to preferences
As per the recommendation of @eddyizm
This commit is contained in:
parent
a22883fdde
commit
1c2f1aa061
6 changed files with 43 additions and 28 deletions
|
|
@ -2,6 +2,7 @@ package com.cappielloantonio.tempo.viewmodel;
|
|||
|
||||
import android.app.Application;
|
||||
import android.app.Dialog;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
|
|
@ -12,6 +13,7 @@ import androidx.lifecycle.MutableLiveData;
|
|||
import com.cappielloantonio.tempo.repository.PlaylistRepository;
|
||||
import com.cappielloantonio.tempo.subsonic.models.Child;
|
||||
import com.cappielloantonio.tempo.subsonic.models.Playlist;
|
||||
import com.cappielloantonio.tempo.util.Preferences;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -34,9 +36,12 @@ public class PlaylistChooserViewModel extends AndroidViewModel {
|
|||
return playlists;
|
||||
}
|
||||
|
||||
public void addSongsToPlaylist(LifecycleOwner owner, Dialog dialog, String playlistId, boolean skipDuplicates) {
|
||||
public void addSongsToPlaylist(LifecycleOwner owner, Dialog dialog, String playlistId) {
|
||||
List<String> songIds = Lists.transform(toAdd, Child::getId);
|
||||
if (skipDuplicates) {
|
||||
if (Preferences.allowPlaylistDuplicates()) {
|
||||
playlistRepository.addSongToPlaylist(playlistId, new ArrayList<>(songIds));
|
||||
dialog.dismiss();
|
||||
} else {
|
||||
playlistRepository.getPlaylistSongs(playlistId).observe(owner, playlistSongs -> {
|
||||
if (playlistSongs != null) {
|
||||
List<String> playlistSongIds = Lists.transform(playlistSongs, Child::getId);
|
||||
|
|
@ -45,9 +50,6 @@ public class PlaylistChooserViewModel extends AndroidViewModel {
|
|||
playlistRepository.addSongToPlaylist(playlistId, new ArrayList<>(songIds));
|
||||
dialog.dismiss();
|
||||
});
|
||||
} else {
|
||||
playlistRepository.addSongToPlaylist(playlistId, new ArrayList<>(songIds));
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue