Preparation for requesting album information

This commit is contained in:
CappielloAntonio 2021-08-02 18:27:45 +02:00
parent 199482f83d
commit ca37adc33a
5 changed files with 69 additions and 89 deletions

View file

@ -6,6 +6,7 @@ import android.os.Parcelable;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import com.cappielloantonio.play.subsonic.models.AlbumID3; import com.cappielloantonio.play.subsonic.models.AlbumID3;
import com.cappielloantonio.play.subsonic.models.AlbumInfo;
import com.cappielloantonio.play.subsonic.models.AlbumWithSongsID3; import com.cappielloantonio.play.subsonic.models.AlbumWithSongsID3;
import com.cappielloantonio.play.util.MappingUtil; import com.cappielloantonio.play.util.MappingUtil;
@ -28,6 +29,7 @@ public class Album implements Parcelable {
public String blurHash; public String blurHash;
public boolean favorite; public boolean favorite;
public List<Song> songs; public List<Song> songs;
public String notes;
public Album(AlbumID3 albumID3) { public Album(AlbumID3 albumID3) {
this.id = albumID3.getId(); this.id = albumID3.getId();
@ -50,6 +52,10 @@ public class Album implements Parcelable {
this.songs = MappingUtil.mapSong(albumWithSongsID3.getSongs()); this.songs = MappingUtil.mapSong(albumWithSongsID3.getSongs());
} }
public Album(AlbumInfo info) {
this.notes = info.getNotes();
}
public String getId() { public String getId() {
return id; return id;
} }
@ -122,6 +128,14 @@ public class Album implements Parcelable {
this.songs = songs; this.songs = songs;
} }
public String getNotes() {
return notes;
}
public void setNotes(String notes) {
this.notes = notes;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;

View file

@ -223,6 +223,29 @@ public class AlbumRepository {
return album; return album;
} }
public MutableLiveData<Album> getAlbumInfo(String id) {
MutableLiveData<Album> album = new MutableLiveData<>();
App.getSubsonicClientInstance(application, false)
.getBrowsingClient()
.getAlbumInfo2(id)
.enqueue(new Callback<SubsonicResponse>() {
@Override
public void onResponse(Call<SubsonicResponse> call, Response<SubsonicResponse> response) {
if (response.body().getStatus().getValue().equals(ResponseStatus.OK)) {
album.setValue(MappingUtil.mapAlbum(response.body().getAlbumInfo()));
}
}
@Override
public void onFailure(Call<SubsonicResponse> call, Throwable t) {
}
});
return album;
}
public void getInstantMix(Album album, int count, MediaCallback callback) { public void getInstantMix(Album album, int count, MediaCallback callback) {
App.getSubsonicClientInstance(application, false) App.getSubsonicClientInstance(application, false)
.getBrowsingClient() .getBrowsingClient()

View file

@ -1,131 +1,68 @@
package com.cappielloantonio.play.subsonic.models; package com.cappielloantonio.play.subsonic.models;
public class AlbumInfo { import com.tickaroo.tikxml.annotation.Attribute;
protected String notes; import com.tickaroo.tikxml.annotation.Xml;
protected String musicBrainzId;
protected String lastFmUrl;
protected String smallImageUrl;
protected String mediumImageUrl;
protected String largeImageUrl;
/** @Xml
* Gets the value of the notes property. public class AlbumInfo {
* @Attribute
* @return possible object is protected String notes;
* {@link String } @Attribute
*/ protected String musicBrainzId;
@Attribute
protected String lastFmUrl;
@Attribute
protected String smallImageUrl;
@Attribute
protected String mediumImageUrl;
@Attribute
protected String largeImageUrl;
public String getNotes() { public String getNotes() {
return notes; return notes;
} }
/**
* Sets the value of the notes property.
*
* @param value allowed object is
* {@link String }
*/
public void setNotes(String value) { public void setNotes(String value) {
this.notes = value; this.notes = value;
} }
/**
* Gets the value of the musicBrainzId property.
*
* @return possible object is
* {@link String }
*/
public String getMusicBrainzId() { public String getMusicBrainzId() {
return musicBrainzId; return musicBrainzId;
} }
/**
* Sets the value of the musicBrainzId property.
*
* @param value allowed object is
* {@link String }
*/
public void setMusicBrainzId(String value) { public void setMusicBrainzId(String value) {
this.musicBrainzId = value; this.musicBrainzId = value;
} }
/**
* Gets the value of the lastFmUrl property.
*
* @return possible object is
* {@link String }
*/
public String getLastFmUrl() { public String getLastFmUrl() {
return lastFmUrl; return lastFmUrl;
} }
/**
* Sets the value of the lastFmUrl property.
*
* @param value allowed object is
* {@link String }
*/
public void setLastFmUrl(String value) { public void setLastFmUrl(String value) {
this.lastFmUrl = value; this.lastFmUrl = value;
} }
/**
* Gets the value of the smallImageUrl property.
*
* @return possible object is
* {@link String }
*/
public String getSmallImageUrl() { public String getSmallImageUrl() {
return smallImageUrl; return smallImageUrl;
} }
/**
* Sets the value of the smallImageUrl property.
*
* @param value allowed object is
* {@link String }
*/
public void setSmallImageUrl(String value) { public void setSmallImageUrl(String value) {
this.smallImageUrl = value; this.smallImageUrl = value;
} }
/**
* Gets the value of the mediumImageUrl property.
*
* @return possible object is
* {@link String }
*/
public String getMediumImageUrl() { public String getMediumImageUrl() {
return mediumImageUrl; return mediumImageUrl;
} }
/**
* Sets the value of the mediumImageUrl property.
*
* @param value allowed object is
* {@link String }
*/
public void setMediumImageUrl(String value) { public void setMediumImageUrl(String value) {
this.mediumImageUrl = value; this.mediumImageUrl = value;
} }
/**
* Gets the value of the largeImageUrl property.
*
* @return possible object is
* {@link String }
*/
public String getLargeImageUrl() { public String getLargeImageUrl() {
return largeImageUrl; return largeImageUrl;
} }
/**
* Sets the value of the largeImageUrl property.
*
* @param value allowed object is
* {@link String }
*/
public void setLargeImageUrl(String value) { public void setLargeImageUrl(String value) {
this.largeImageUrl = value; this.largeImageUrl = value;
} }
} }

View file

@ -18,6 +18,7 @@ public class SubsonicResponse {
@Element(name = "artistInfo2") @Element(name = "artistInfo2")
private ArtistInfo2 artistInfo2; private ArtistInfo2 artistInfo2;
private ArtistInfo artistInfo; private ArtistInfo artistInfo;
@Element(name = "albumInfo")
private AlbumInfo albumInfo; private AlbumInfo albumInfo;
@Element(name = "starred2") @Element(name = "starred2")
private Starred2 starred2; private Starred2 starred2;

View file

@ -7,6 +7,7 @@ import com.cappielloantonio.play.model.Playlist;
import com.cappielloantonio.play.model.Queue; import com.cappielloantonio.play.model.Queue;
import com.cappielloantonio.play.model.Song; import com.cappielloantonio.play.model.Song;
import com.cappielloantonio.play.subsonic.models.AlbumID3; import com.cappielloantonio.play.subsonic.models.AlbumID3;
import com.cappielloantonio.play.subsonic.models.AlbumInfo;
import com.cappielloantonio.play.subsonic.models.AlbumWithSongsID3; import com.cappielloantonio.play.subsonic.models.AlbumWithSongsID3;
import com.cappielloantonio.play.subsonic.models.ArtistID3; import com.cappielloantonio.play.subsonic.models.ArtistID3;
import com.cappielloantonio.play.subsonic.models.ArtistInfo2; import com.cappielloantonio.play.subsonic.models.ArtistInfo2;
@ -43,6 +44,10 @@ public class MappingUtil {
return new Album(albumWithSongsID3); return new Album(albumWithSongsID3);
} }
public static Album mapAlbum(AlbumInfo albumInfo) {
return new Album(albumInfo);
}
public static ArrayList<Artist> mapArtist(List<ArtistID3> artistID3List) { public static ArrayList<Artist> mapArtist(List<ArtistID3> artistID3List) {
ArrayList<Artist> artists = new ArrayList(); ArrayList<Artist> artists = new ArrayList();