mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
Implemented Top Songs view per artist
This commit is contained in:
parent
7ad2e1da1d
commit
f321a5520f
6 changed files with 37 additions and 26 deletions
|
|
@ -284,6 +284,27 @@ public class ArtistRepository {
|
||||||
return randomSongs;
|
return randomSongs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MutableLiveData<List<Song>> getTopSongs(String artistName, int count) {
|
||||||
|
MutableLiveData<List<Song>> topSongs = new MutableLiveData<>();
|
||||||
|
|
||||||
|
App.getSubsonicClientInstance(application, false)
|
||||||
|
.getBrowsingClient()
|
||||||
|
.getTopSongs(artistName, count)
|
||||||
|
.enqueue(new Callback<SubsonicResponse>() {
|
||||||
|
@Override
|
||||||
|
public void onResponse(Call<SubsonicResponse> call, Response<SubsonicResponse> response) {
|
||||||
|
topSongs.setValue(MappingUtil.mapSong(response.body().getTopSongs().getSongs()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Call<SubsonicResponse> call, Throwable t) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return topSongs;
|
||||||
|
}
|
||||||
|
|
||||||
private void addToMutableLiveData(MutableLiveData<List<Artist>> liveData, Artist artist) {
|
private void addToMutableLiveData(MutableLiveData<List<Artist>> liveData, Artist artist) {
|
||||||
List<Artist> liveArtists = liveData.getValue();
|
List<Artist> liveArtists = liveData.getValue();
|
||||||
liveArtists.add(artist);
|
liveArtists.add(artist);
|
||||||
|
|
|
||||||
|
|
@ -110,9 +110,9 @@ public class BrowsingClient {
|
||||||
return browsingService.getSimilarSongs2(subsonic.getParams(), id, limit);
|
return browsingService.getSimilarSongs2(subsonic.getParams(), id, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Call<SubsonicResponse> getTopSongs(String id, int count) {
|
public Call<SubsonicResponse> getTopSongs(String artist, int count) {
|
||||||
Log.d(TAG, "getTopSongs()");
|
Log.d(TAG, "getTopSongs()");
|
||||||
return browsingService.getTopSongs(subsonic.getParams(), id, count);
|
return browsingService.getTopSongs(subsonic.getParams(), artist, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
private OkHttpClient getOkHttpClient() {
|
private OkHttpClient getOkHttpClient() {
|
||||||
|
|
|
||||||
|
|
@ -59,5 +59,5 @@ public interface BrowsingService {
|
||||||
Call<SubsonicResponse> getSimilarSongs2(@QueryMap Map<String, String> params, @Query("id") String id, @Query("count") int count);
|
Call<SubsonicResponse> getSimilarSongs2(@QueryMap Map<String, String> params, @Query("id") String id, @Query("count") int count);
|
||||||
|
|
||||||
@GET("getTopSongs")
|
@GET("getTopSongs")
|
||||||
Call<SubsonicResponse> getTopSongs(@QueryMap Map<String, String> params, @Query("id") String id, @Query("count") int count);
|
Call<SubsonicResponse> getTopSongs(@QueryMap Map<String, String> params, @Query("artist") String artist, @Query("count") int count);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ public class SubsonicResponse {
|
||||||
@Element
|
@Element
|
||||||
private Error error;
|
private Error error;
|
||||||
private ScanStatus scanStatus;
|
private ScanStatus scanStatus;
|
||||||
|
@Element(name = "topSongs")
|
||||||
private TopSongs topSongs;
|
private TopSongs topSongs;
|
||||||
@Element(name = "similarSongs2")
|
@Element(name = "similarSongs2")
|
||||||
private SimilarSongs2 similarSongs2;
|
private SimilarSongs2 similarSongs2;
|
||||||
|
|
|
||||||
|
|
@ -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 TopSongs {
|
public class TopSongs {
|
||||||
|
@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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public class ArtistPageViewModel extends AndroidViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Song>> getArtistTopSongList() {
|
public LiveData<List<Song>> getArtistTopSongList() {
|
||||||
// songList = songRepository.getArtistListLiveTopSongSample(artist.id);
|
songList = artistRepository.getTopSongs(artist.getName(), 50);
|
||||||
return songList;
|
return songList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue