Commit 6f1e285e authored by Geoffrey Métais's avatar Geoffrey Métais

Properly get artists tracks

parent a637c43b
......@@ -339,7 +339,7 @@ std::vector<medialibrary::MediaPtr>
AndroidMediaLibrary::mediaFromArtist( int64_t artistId )
{
auto artist = p_ml->artist(artistId);
return artist == nullptr ? std::vector<medialibrary::MediaPtr>() : artist->media();
return artist == nullptr ? std::vector<medialibrary::MediaPtr>() : artist->media(medialibrary::SortingCriteria::Album);
}
std::vector<medialibrary::AlbumPtr>
......@@ -353,7 +353,7 @@ std::vector<medialibrary::MediaPtr>
AndroidMediaLibrary::mediaFromGenre( int64_t genreId )
{
auto genre = p_ml->genre(genreId);
return genre == nullptr ? std::vector<medialibrary::MediaPtr>() : genre->tracks();
return genre == nullptr ? std::vector<medialibrary::MediaPtr>() : genre->tracks(medialibrary::SortingCriteria::Album);
}
std::vector<medialibrary::AlbumPtr>
......
......@@ -559,12 +559,7 @@ jobjectArray
getMediaFromArtist(JNIEnv* env, jobject thiz, jobject medialibrary, jlong id)
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary);
std::vector<medialibrary::AlbumPtr> albumList = aml->albumsFromArtist(id);
std::vector<medialibrary::MediaPtr> mediaList;
for (medialibrary::AlbumPtr album : albumList) {
std::vector<medialibrary::MediaPtr> tracks = album->tracks();
mediaList.insert(std::end(mediaList), std::begin(tracks), std::end(tracks));
}
std::vector<medialibrary::MediaPtr> mediaList = aml->mediaFromArtist(id);
jobjectArray mediaRefs = (jobjectArray) env->NewObjectArray(mediaList.size(), ml_fields.MediaWrapper.clazz, NULL);
int index = -1, drops = 0;
for(medialibrary::MediaPtr const& media : mediaList) {
......
......@@ -281,8 +281,7 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
}
private void updateList() {
if (mItem == null || getActivity() == null)
return;
if (mItem == null || getActivity() == null) return;
VLCApplication.runBackground(new Runnable() {
@Override
......@@ -292,12 +291,8 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
albums = Util.arrayToMediaArrayList(((Artist) mItem).getAlbums());
} else if (mItem.getItemType() == MediaLibraryItem.TYPE_GENRE)
albums = Util.arrayToMediaArrayList(((Genre) mItem).getAlbums());
else
return;
final List<MediaLibraryItem> songs = new ArrayList<>();
for (MediaLibraryItem album : albums) {
songs.addAll(Util.arrayToArrayList(album.getTracks()));
}
else return;
final List<MediaLibraryItem> songs = Util.arrayToMediaArrayList(mItem.getTracks());
mAlbumsAdapter.update(albums);
mSongsAdapter.update(songs);
}
......@@ -308,6 +303,7 @@ public class AudioAlbumsSongsFragment extends BaseAudioBrowser implements SwipeR
public void onUpdateFinished(RecyclerView.Adapter adapter) {
mFastScroller.setRecyclerView(getCurrentRV());
mSwipeRefreshLayout.setRefreshing(false);
if (mAlbumsAdapter.isEmpty()) mViewPager.setCurrentItem(1);
}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment