mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 02:13:33 +00:00
Map SimilarArtist models and show them in artist's page
This commit is contained in:
parent
5f0427598f
commit
7ad2e1da1d
5 changed files with 77 additions and 7 deletions
|
|
@ -8,6 +8,7 @@ import androidx.annotation.NonNull;
|
||||||
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;
|
||||||
import com.cappielloantonio.play.subsonic.models.ArtistWithAlbumsID3;
|
import com.cappielloantonio.play.subsonic.models.ArtistWithAlbumsID3;
|
||||||
|
import com.cappielloantonio.play.subsonic.models.SimilarArtistID3;
|
||||||
import com.cappielloantonio.play.util.MappingUtil;
|
import com.cappielloantonio.play.util.MappingUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
@ -53,8 +54,16 @@ public class Artist implements Parcelable {
|
||||||
this.albums = MappingUtil.mapAlbum(artistWithAlbumsID3.getAlbums());
|
this.albums = MappingUtil.mapAlbum(artistWithAlbumsID3.getAlbums());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Artist(SimilarArtistID3 similarArtistID3) {
|
||||||
|
this.id = similarArtistID3.getId();
|
||||||
|
this.name = similarArtistID3.getName();
|
||||||
|
this.primary = similarArtistID3.getCoverArtId();
|
||||||
|
this.backdrop = similarArtistID3.getCoverArtId();
|
||||||
|
this.albumCount = similarArtistID3.getAlbumCount();
|
||||||
|
}
|
||||||
|
|
||||||
public Artist(ArtistInfo2 artistInfo2) {
|
public Artist(ArtistInfo2 artistInfo2) {
|
||||||
this.similarArtists = MappingUtil.mapArtist(artistInfo2.getSimilarArtists());
|
this.similarArtists = MappingUtil.mapSimilarArtist(artistInfo2.getSimilarArtists());
|
||||||
this.bio = artistInfo2.getBiography();
|
this.bio = artistInfo2.getBiography();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,17 @@ import java.util.List;
|
||||||
|
|
||||||
@Xml
|
@Xml
|
||||||
public class ArtistInfo2 extends ArtistInfoBase {
|
public class ArtistInfo2 extends ArtistInfoBase {
|
||||||
@Element(name = "similarArtist", typesByElement = @ElementNameMatcher(type = ArtistID3.class))
|
@Element(name = "similarArtist")
|
||||||
protected List<ArtistID3> similarArtists;
|
protected List<SimilarArtistID3> similarArtists;
|
||||||
|
|
||||||
public List<ArtistID3> getSimilarArtists() {
|
public List<SimilarArtistID3> getSimilarArtists() {
|
||||||
if (similarArtists == null) {
|
if (similarArtists == null) {
|
||||||
similarArtists = new ArrayList<>();
|
similarArtists = new ArrayList<>();
|
||||||
}
|
}
|
||||||
return this.similarArtists;
|
return this.similarArtists;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSimilarArtists(List<ArtistID3> similarArtists) {
|
public void setSimilarArtists(List<SimilarArtistID3> similarArtists) {
|
||||||
this.similarArtists = similarArtists;
|
this.similarArtists = similarArtists;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.cappielloantonio.play.subsonic.models;
|
||||||
|
|
||||||
|
import com.tickaroo.tikxml.annotation.Attribute;
|
||||||
|
import com.tickaroo.tikxml.annotation.Xml;
|
||||||
|
import com.tickaroo.tikxml.converters.date.rfc3339.DateRfc3339TypeConverter;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Xml(name = "similarArtist")
|
||||||
|
public class SimilarArtistID3 {
|
||||||
|
@Attribute
|
||||||
|
protected String id;
|
||||||
|
@Attribute
|
||||||
|
protected String name;
|
||||||
|
@Attribute(name = "coverArt")
|
||||||
|
protected String coverArtId;
|
||||||
|
@Attribute
|
||||||
|
protected int albumCount;
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String value) {
|
||||||
|
this.id = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String value) {
|
||||||
|
this.name = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCoverArtId() {
|
||||||
|
return coverArtId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCoverArtId(String value) {
|
||||||
|
this.coverArtId = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAlbumCount() {
|
||||||
|
return albumCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAlbumCount(int value) {
|
||||||
|
this.albumCount = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -185,8 +185,7 @@ public class ArtistPageFragment extends Fragment {
|
||||||
artistSimilarAdapter = new ArtistSimilarAdapter(requireContext());
|
artistSimilarAdapter = new ArtistSimilarAdapter(requireContext());
|
||||||
bind.similarArtistsRecyclerView.setAdapter(artistSimilarAdapter);
|
bind.similarArtistsRecyclerView.setAdapter(artistSimilarAdapter);
|
||||||
artistPageViewModel.getArtistInfo(artistPageViewModel.getArtist().getId()).observe(requireActivity(), artist -> {
|
artistPageViewModel.getArtistInfo(artistPageViewModel.getArtist().getId()).observe(requireActivity(), artist -> {
|
||||||
if (bind != null)
|
if (bind != null) bind.similarArtistSector.setVisibility(!artist.getSimilarArtists().isEmpty() ? View.VISIBLE : View.GONE);
|
||||||
bind.similarArtistSector.setVisibility(!artist.getSimilarArtists().isEmpty() ? View.VISIBLE : View.GONE);
|
|
||||||
artistSimilarAdapter.setItems(artist.getSimilarArtists());
|
artistSimilarAdapter.setItems(artist.getSimilarArtists());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import com.cappielloantonio.play.subsonic.models.ArtistInfo2;
|
||||||
import com.cappielloantonio.play.subsonic.models.ArtistWithAlbumsID3;
|
import com.cappielloantonio.play.subsonic.models.ArtistWithAlbumsID3;
|
||||||
import com.cappielloantonio.play.subsonic.models.Child;
|
import com.cappielloantonio.play.subsonic.models.Child;
|
||||||
import com.cappielloantonio.play.subsonic.models.Genre;
|
import com.cappielloantonio.play.subsonic.models.Genre;
|
||||||
|
import com.cappielloantonio.play.subsonic.models.SimilarArtistID3;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -64,6 +65,16 @@ public class MappingUtil {
|
||||||
return new Artist(artistWithAlbumsID3);
|
return new Artist(artistWithAlbumsID3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ArrayList<Artist> mapSimilarArtist(List<SimilarArtistID3> similarArtistID3s) {
|
||||||
|
ArrayList<Artist> artists = new ArrayList();
|
||||||
|
|
||||||
|
for (SimilarArtistID3 similarArtistID3 : similarArtistID3s) {
|
||||||
|
artists.add(new Artist(similarArtistID3));
|
||||||
|
}
|
||||||
|
|
||||||
|
return artists;
|
||||||
|
}
|
||||||
|
|
||||||
public static ArrayList<Song> mapQueue(List<Queue> queueList) {
|
public static ArrayList<Song> mapQueue(List<Queue> queueList) {
|
||||||
ArrayList<Song> songs = new ArrayList();
|
ArrayList<Song> songs = new ArrayList();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue