mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 02:13:33 +00:00
Implementation of album and artist catalog recovery
This commit is contained in:
parent
64cd8ed0ac
commit
98ffec9b72
15 changed files with 330 additions and 160 deletions
|
|
@ -7,6 +7,7 @@ import androidx.lifecycle.MutableLiveData;
|
|||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.subsonic.models.ResponseStatus;
|
||||
import com.cappielloantonio.play.subsonic.models.SubsonicResponse;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
|
|
@ -94,6 +95,7 @@ public class AlbumRepository {
|
|||
|
||||
@Override
|
||||
public void onFailure(Call<SubsonicResponse> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -150,4 +152,50 @@ public class AlbumRepository {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Song>> getAlbumTracks(String id) {
|
||||
MutableLiveData<List<Song>> albumTracks = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getBrowsingClient()
|
||||
.getAlbum(id)
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<SubsonicResponse> call, Response<SubsonicResponse> response) {
|
||||
List<Song> tracks = new ArrayList<>(MappingUtil.mapSong(response.body().getAlbum().getSongs()));
|
||||
albumTracks.setValue(tracks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<SubsonicResponse> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return albumTracks;
|
||||
}
|
||||
|
||||
public MutableLiveData<List<Album>> getArtistAlbums(String id) {
|
||||
MutableLiveData<List<Album>> artistsAlbum = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getBrowsingClient()
|
||||
.getArtist(id)
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<SubsonicResponse> call, Response<SubsonicResponse> response) {
|
||||
if (response.body().getStatus().getValue().equals(ResponseStatus.OK)) {
|
||||
List<Album> albums = new ArrayList<>(MappingUtil.mapAlbum(response.body().getArtist().getAlbums()));
|
||||
artistsAlbum.setValue(albums);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<SubsonicResponse> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return artistsAlbum;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import android.app.Application;
|
|||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.subsonic.models.ArtistWithAlbumsID3;
|
||||
import com.cappielloantonio.play.subsonic.models.IndexID3;
|
||||
|
|
@ -84,6 +85,9 @@ public class ArtistRepository {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Metodo che mi restituisce le informazioni essenzionali dell'artista (cover, numero di album...)
|
||||
*/
|
||||
public void getArtistInfo(List<Artist> artists, MutableLiveData<List<Artist>> list) {
|
||||
for (Artist artist : artists) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
|
|
@ -103,6 +107,51 @@ public class ArtistRepository {
|
|||
}
|
||||
}
|
||||
|
||||
public MutableLiveData<Artist> getArtistInfo(String id) {
|
||||
MutableLiveData<Artist> artist = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getBrowsingClient()
|
||||
.getArtist(id)
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<SubsonicResponse> call, Response<SubsonicResponse> response) {
|
||||
artist.setValue(MappingUtil.mapArtistWithAlbum(response.body().getArtist()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<SubsonicResponse> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return artist;
|
||||
}
|
||||
|
||||
/*
|
||||
* Metodo che mi restituisce le informazioni complete dell'artista (bio, immagini prese da last.fm, artisti simili...)
|
||||
*/
|
||||
public MutableLiveData<Artist> getArtistFullInfo(String id) {
|
||||
MutableLiveData<Artist> artistFullInfo = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getBrowsingClient()
|
||||
.getArtistInfo2(id)
|
||||
.enqueue(new Callback<SubsonicResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<SubsonicResponse> call, Response<SubsonicResponse> response) {
|
||||
artistFullInfo.setValue(MappingUtil.mapArtist(response.body().getArtistInfo2()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<SubsonicResponse> call, Throwable t) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
return artistFullInfo;
|
||||
}
|
||||
|
||||
public void star(String id) {
|
||||
App.getSubsonicClientInstance(application, false)
|
||||
.getMediaAnnotationClient()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue