[Android] Split audio lists updates
Geoffrey Métais
git at videolan.org
Fri Feb 24 17:47:31 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb 24 17:45:31 2017 +0100| [a1d5f53226245b12756751879ba5a8ae0c7f6a2a] | committer: Geoffrey Métais
Split audio lists updates
Load each content separately, to avoid wait before displaying the first
one
> https://code.videolan.org/videolan/vlc-android/commit/a1d5f53226245b12756751879ba5a8ae0c7f6a2a
---
.../vlc/gui/audio/AudioBrowserFragment.java | 90 ++++++++++++++++------
1 file changed, 67 insertions(+), 23 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index 75e5ebb..cd1ef26 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -716,30 +716,74 @@ public class AudioBrowserFragment extends BaseAudioBrowser implements DevicesDis
@MainThread
private void updateLists() {
- mTabLayout.setVisibility(View.VISIBLE);
- mHandler.sendEmptyMessageDelayed(MSG_LOADING, 300);
- mHandler.removeMessages(UPDATE_LIST);
+ mTabLayout.setVisibility(View.VISIBLE);
+ mHandler.sendEmptyMessageDelayed(MSG_LOADING, 300);
+ mHandler.removeMessages(UPDATE_LIST);
+ updateArtists();
+ updateAlbums();
+ updateSongs();
+ updateGenres();
+ updatePlaylists();
+ }
- VLCApplication.runBackground(new Runnable() {
- @Override
- public void run() {
- final Artist[] artists = mMediaLibrary.getArtists();
- final Album[] albums = mMediaLibrary.getAlbums();
- final MediaWrapper[] media = mMediaLibrary.getAudio();
- final Genre[] genres = mMediaLibrary.getGenres();
- final Playlist[] playlists = mMediaLibrary.getPlaylists();
- VLCApplication.runOnMainThread(new Runnable() {
- @Override
- public void run() {
- mArtistsAdapter.update(artists);
- mAlbumsAdapter.update(albums);
- mSongsAdapter.update(media);
- mGenresAdapter.update(genres);
- mPlaylistAdapter.update(playlists);
- }
- });
- }
- });
+ private void updateArtists() {
+ VLCApplication.runBackground(new Runnable() {
+ @Override
+ public void run() {
+ final Artist[] artists = mMediaLibrary.getArtists();
+ VLCApplication.runOnMainThread(new Runnable() {
+ @Override
+ public void run() {
+ mArtistsAdapter.update(artists);
+ }
+ });
+ }
+ });
+ }
+
+ private void updateAlbums() {
+ VLCApplication.runBackground(new Runnable() {
+ @Override
+ public void run() {
+ final Album[] albums = mMediaLibrary.getAlbums();
+ VLCApplication.runOnMainThread(new Runnable() {
+ @Override
+ public void run() {
+ mAlbumsAdapter.update(albums);
+ }
+ });
+ }
+ });
+ }
+
+ private void updateSongs() {
+ VLCApplication.runBackground(new Runnable() {
+ @Override
+ public void run() {
+ final MediaWrapper[] media = mMediaLibrary.getAudio();
+ VLCApplication.runOnMainThread(new Runnable() {
+ @Override
+ public void run() {
+ mSongsAdapter.update(media);
+ }
+ });
+ }
+ });
+ }
+
+ private void updateGenres() {
+ VLCApplication.runBackground(new Runnable() {
+ @Override
+ public void run() {
+ final Genre[] genres = mMediaLibrary.getGenres();
+ VLCApplication.runOnMainThread(new Runnable() {
+ @Override
+ public void run() {
+ mGenresAdapter.update(genres);
+ }
+ });
+ }
+ });
}
private void updatePlaylists() {
More information about the Android
mailing list