[Android] Audio browser: call requestLayout() in updateLists() to fix the the lists sometimes not updated when the fragment starts
Adrien Maglo
git at videolan.org
Thu Nov 28 16:27:10 CET 2013
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Thu Nov 28 16:26:06 2013 +0100| [cdd195a2cf43d0e18805d3cc713a3529861844d6] | committer: Adrien Maglo
Audio browser: call requestLayout() in updateLists() to fix the the lists sometimes not updated when the fragment starts
It may look like a hack but notifyDataSetChanged(), in this case, does not seem to trigger ListView refresh.
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=cdd195a2cf43d0e18805d3cc713a3529861844d6
---
.../vlc/gui/audio/AudioBrowserFragment.java | 42 ++++++++++++--------
1 file changed, 26 insertions(+), 16 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 e302f83..cc8b9b1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -71,6 +71,11 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
private AudioServiceController mAudioController;
private MediaLibrary mMediaLibrary;
+ ListView mSongsList;
+ ListView mArtistList;
+ ListView mAlbumList;
+ ListView mGenreList;
+
private AudioBrowserListAdapter mSongsAdapter;
private AudioBrowserListAdapter mArtistsAdapter;
private AudioBrowserListAdapter mAlbumsAdapter;
@@ -121,25 +126,25 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
}
});
- ListView songsList = (ListView)v.findViewById(R.id.songs_list);
- ListView artistList = (ListView)v.findViewById(R.id.artists_list);
- ListView albumList = (ListView)v.findViewById(R.id.albums_list);
- ListView genreList = (ListView)v.findViewById(R.id.genres_list);
+ mSongsList = (ListView)v.findViewById(R.id.songs_list);
+ mArtistList = (ListView)v.findViewById(R.id.artists_list);
+ mAlbumList = (ListView)v.findViewById(R.id.albums_list);
+ mGenreList = (ListView)v.findViewById(R.id.genres_list);
- songsList.setAdapter(mSongsAdapter);
- artistList.setAdapter(mArtistsAdapter);
- albumList.setAdapter(mAlbumsAdapter);
- genreList.setAdapter(mGenresAdapter);
+ mSongsList.setAdapter(mSongsAdapter);
+ mArtistList.setAdapter(mArtistsAdapter);
+ mAlbumList.setAdapter(mAlbumsAdapter);
+ mGenreList.setAdapter(mGenresAdapter);
- songsList.setOnItemClickListener(songListener);
- artistList.setOnItemClickListener(artistListListener);
- albumList.setOnItemClickListener(albumListListener);
- genreList.setOnItemClickListener(genreListListener);
+ mSongsList.setOnItemClickListener(songListener);
+ mArtistList.setOnItemClickListener(artistListListener);
+ mAlbumList.setOnItemClickListener(albumListListener);
+ mGenreList.setOnItemClickListener(genreListListener);
- registerForContextMenu(songsList);
- registerForContextMenu(artistList);
- registerForContextMenu(albumList);
- registerForContextMenu(genreList);
+ registerForContextMenu(mSongsList);
+ registerForContextMenu(mArtistList);
+ registerForContextMenu(mAlbumList);
+ registerForContextMenu(mGenreList);
return v;
}
@@ -399,6 +404,11 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
mArtistsAdapter.notifyDataSetChanged();
mAlbumsAdapter.notifyDataSetChanged();
mGenresAdapter.notifyDataSetChanged();
+
+ mSongsList.requestLayout();
+ mArtistList.requestLayout();
+ mAlbumList.requestLayout();
+ mGenreList.requestLayout();
}
@Override
More information about the Android
mailing list