pull songs and albums at the same time for artist details
This commit is contained in:
parent
3517e145a6
commit
a4963583e0
5 changed files with 19 additions and 40 deletions
|
|
@ -389,6 +389,7 @@ public class MusicPlayerRemote {
|
|||
if (musicService != null) {
|
||||
return musicService.getAudioSessionId();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@ package com.kabouzeid.gramophone.model;
|
|||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.kabouzeid.gramophone.util.MusicUtil;
|
||||
|
||||
import org.jellyfin.apiclient.model.dto.BaseItemDto;
|
||||
|
||||
|
|
@ -15,27 +12,24 @@ public class Artist implements Parcelable {
|
|||
public static final String UNKNOWN_ARTIST_DISPLAY_NAME = "Unknown Artist";
|
||||
|
||||
public List<Album> albums;
|
||||
public List<String> genres;
|
||||
public List<Song> songs;
|
||||
|
||||
public String id;
|
||||
public String name;
|
||||
public long duration;
|
||||
public int albumCount;
|
||||
public int songCount;
|
||||
|
||||
public Artist(BaseItemDto itemDto) {
|
||||
this.id = itemDto.getId();
|
||||
this.name = itemDto.getName();
|
||||
this.duration = itemDto.getRunTimeTicks() / 10000;
|
||||
this.albumCount = itemDto.getAlbumCount() != null ? itemDto.getAlbumCount() : 0;
|
||||
this.songCount = itemDto.getSongCount() != null ? itemDto.getSongCount() : 0;
|
||||
|
||||
this.albums = new ArrayList<>();
|
||||
this.genres = itemDto.getGenres();
|
||||
this.songs = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Artist() {
|
||||
this.albums = new ArrayList<>();
|
||||
this.songs = new ArrayList<>();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
|
@ -47,11 +41,7 @@ public class Artist implements Parcelable {
|
|||
}
|
||||
|
||||
public int getSongCount() {
|
||||
int songCount = 0;
|
||||
for (Album album : albums) {
|
||||
songCount += album.getSongCount();
|
||||
}
|
||||
return songCount;
|
||||
return songs.size();
|
||||
}
|
||||
|
||||
public int getAlbumCount() {
|
||||
|
|
@ -59,10 +49,6 @@ public class Artist implements Parcelable {
|
|||
}
|
||||
|
||||
public List<Song> getSongs() {
|
||||
List<Song> songs = new ArrayList<>();
|
||||
for (Album album : albums) {
|
||||
songs.addAll(album.songs);
|
||||
}
|
||||
return songs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,19 +28,12 @@ public class Genre implements Parcelable {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = id;
|
||||
result = 31 * result + name.hashCode();
|
||||
result = 31 * result + songCount;
|
||||
return result;
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Genre{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", songCount=" + songCount + '\'' +
|
||||
'}';
|
||||
return Integer.toString(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -127,19 +127,16 @@ public class ArtistDetailActivity extends AbsSlidingMusicPanelActivity implement
|
|||
public void onLoadMedia(List<?> media) {
|
||||
artist.albums = (List<Album>) media;
|
||||
setArtist(artist);
|
||||
|
||||
QueryUtil.getSongs(query, new MediaCallback() {
|
||||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
for (Album album : artist.albums) {
|
||||
for (Song song : (List<Song>) media) {
|
||||
if (song.albumId.equals(album.id)) album.songs.add(song);
|
||||
}
|
||||
}
|
||||
|
||||
setArtist(artist);
|
||||
}
|
||||
});
|
||||
|
||||
ItemQuery querys = new ItemQuery();
|
||||
querys.setArtistIds(new String[]{artist.id});
|
||||
QueryUtil.getSongs(querys, new MediaCallback() {
|
||||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
artist.songs = (List<Song>) media;
|
||||
setArtist(artist);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ public class GenresFragment extends AbsLibraryPagerRecyclerViewFragment<GenreAda
|
|||
@Override
|
||||
protected GenreAdapter createAdapter() {
|
||||
List<Genre> dataSet = getAdapter() == null ? new ArrayList<>() : getAdapter().getDataSet();
|
||||
return new GenreAdapter(getLibraryFragment().getMainActivity(), dataSet, R.layout.item_list_no_image);
|
||||
|
||||
GenreAdapter adapter = new GenreAdapter(getLibraryFragment().getMainActivity(), dataSet, R.layout.item_list_no_image);
|
||||
return adapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue