[Android] Prevent NPE
Geoffrey Métais
git at videolan.org
Sat Feb 11 03:46:50 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Sat Feb 11 03:45:56 2017 +0100| [362fe03079b363561fac9e305627bc18ca7b8460] | committer: Geoffrey Métais
Prevent NPE
> https://code.videolan.org/videolan/vlc-android/commit/362fe03079b363561fac9e305627bc18ca7b8460
---
.../src/org/videolan/vlc/gui/SearchActivity.java | 28 ++++++++++++----------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/SearchActivity.java b/vlc-android/src/org/videolan/vlc/gui/SearchActivity.java
index 22e41ac..a876320 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SearchActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/SearchActivity.java
@@ -63,19 +63,21 @@ public class SearchActivity extends AppCompatActivity implements TextWatcher, Te
public void run() {
final SearchAggregate searchAggregate = mMedialibrary.search(query);
mBinding.setSearchAggregate(searchAggregate);
- SearchActivity.this.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- ((SearchResultAdapter)mBinding.albumsResults.getAdapter()).add(searchAggregate.getAlbums());
- ((SearchResultAdapter)mBinding.artistsResults.getAdapter()).add(searchAggregate.getArtists());
- ((SearchResultAdapter)mBinding.genresResults.getAdapter()).add(searchAggregate.getGenres());
- ((SearchResultAdapter)mBinding.playlistsResults.getAdapter()).add(searchAggregate.getPlaylists());
- ((SearchResultAdapter)mBinding.episodesResults.getAdapter()).add(searchAggregate.getMediaSearchAggregate().getEpisodes());
- ((SearchResultAdapter)mBinding.moviesResults.getAdapter()).add(searchAggregate.getMediaSearchAggregate().getMovies());
- ((SearchResultAdapter)mBinding.othersResults.getAdapter()).add(searchAggregate.getMediaSearchAggregate().getOthers());
- ((SearchResultAdapter)mBinding.songsResults.getAdapter()).add(searchAggregate.getMediaSearchAggregate().getTracks());
- }
- });
+ if (searchAggregate != null) {
+ VLCApplication.runOnMainThread(new Runnable() {
+ @Override
+ public void run() {
+ ((SearchResultAdapter)mBinding.albumsResults.getAdapter()).add(searchAggregate.getAlbums());
+ ((SearchResultAdapter)mBinding.artistsResults.getAdapter()).add(searchAggregate.getArtists());
+ ((SearchResultAdapter)mBinding.genresResults.getAdapter()).add(searchAggregate.getGenres());
+ ((SearchResultAdapter)mBinding.playlistsResults.getAdapter()).add(searchAggregate.getPlaylists());
+ ((SearchResultAdapter)mBinding.episodesResults.getAdapter()).add(searchAggregate.getMediaSearchAggregate().getEpisodes());
+ ((SearchResultAdapter)mBinding.moviesResults.getAdapter()).add(searchAggregate.getMediaSearchAggregate().getMovies());
+ ((SearchResultAdapter)mBinding.othersResults.getAdapter()).add(searchAggregate.getMediaSearchAggregate().getOthers());
+ ((SearchResultAdapter)mBinding.songsResults.getAdapter()).add(searchAggregate.getMediaSearchAggregate().getTracks());
+ }
+ });
+ }
}
});
}
More information about the Android
mailing list