Get similar song from subsonic response

This commit is contained in:
CappielloAntonio 2021-07-27 14:52:37 +02:00
parent cf366f6ee8
commit 737eaa1822
2 changed files with 16 additions and 26 deletions

View file

@ -16,6 +16,7 @@ import com.cappielloantonio.play.glide.CustomGlideRequest;
import com.cappielloantonio.play.interfaces.MediaCallback; import com.cappielloantonio.play.interfaces.MediaCallback;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.repository.QueueRepository; import com.cappielloantonio.play.repository.QueueRepository;
import com.cappielloantonio.play.repository.SongRepository;
import com.cappielloantonio.play.service.MusicPlayerRemote; import com.cappielloantonio.play.service.MusicPlayerRemote;
import com.cappielloantonio.play.ui.activity.MainActivity; import com.cappielloantonio.play.ui.activity.MainActivity;
import com.cappielloantonio.play.util.PreferenceUtil; import com.cappielloantonio.play.util.PreferenceUtil;
@ -85,8 +86,8 @@ public class DiscoverSongAdapter extends RecyclerView.Adapter<DiscoverSongAdapte
@Override @Override
public void onClick(View view) { public void onClick(View view) {
SyncUtil.getInstantMix(context, new MediaCallback() { SongRepository songRepository = new SongRepository(App.getInstance());
songRepository.getInstantMix(songs.get(getBindingAdapterPosition()), 20, new MediaCallback() {
@Override @Override
public void onError(Exception exception) { public void onError(Exception exception) {
Log.e(TAG, "onError: " + exception.getMessage()); Log.e(TAG, "onError: " + exception.getMessage());
@ -98,11 +99,11 @@ public class DiscoverSongAdapter extends RecyclerView.Adapter<DiscoverSongAdapte
List<Song> mix = queueRepository.insertMix((ArrayList<Song>) media); List<Song> mix = queueRepository.insertMix((ArrayList<Song>) media);
activity.isBottomSheetInPeek(true); activity.isBottomSheetInPeek(true);
activity.setBottomSheetMusicInfo(mix.get(0)); activity.setBottomSheetMusicInfo((Song) media.get(0));
MusicPlayerRemote.openQueue(mix, 0, true); MusicPlayerRemote.openQueue((List<Song>) media, 0, true);
} }
}, SyncUtil.SONG, songs.get(getBindingAdapterPosition()).getId(), PreferenceUtil.getInstance(context).getInstantMixSongNumber()); });
} }
} }
} }

View file

@ -1,35 +1,24 @@
package com.cappielloantonio.play.subsonic.models; package com.cappielloantonio.play.subsonic.models;
import com.tickaroo.tikxml.annotation.Element;
import com.tickaroo.tikxml.annotation.Xml;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@Xml
public class SimilarSongs2 { public class SimilarSongs2 {
@Element(name = "song")
protected List<Child> songs; protected List<Child> songs;
/**
* Gets the value of the songs property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the songs property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getSongs().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link Child }
*/
public List<Child> getSongs() { public List<Child> getSongs() {
if (songs == null) { if (songs == null) {
songs = new ArrayList<Child>(); songs = new ArrayList<>();
} }
return this.songs; return this.songs;
} }
public void setSongs(List<Child> songs) {
this.songs = songs;
}
} }