[Android] Prevent NPE for SortableFragment children classes

Geoffrey Métais git at videolan.org
Wed Nov 8 10:54:45 CET 2017


vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov  8 10:12:54 2017 +0100| [9a1fb008ed21c88cbc575ebaee81f206199d3478] | committer: Geoffrey Métais

Prevent NPE for SortableFragment children classes

(cherry picked from commit 1783ea1279f2f4f965351af75a386c4b416bcf73)

> https://code.videolan.org/videolan/vlc-android/commit/9a1fb008ed21c88cbc575ebaee81f206199d3478
---

 vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java
index 3b5246885..2688df43f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/SortableFragment.java
@@ -51,7 +51,9 @@ public abstract class SortableFragment<T extends SortableAdapter> extends MediaB
     @Override
     public void onHiddenChanged(boolean hidden) {
         super.onHiddenChanged(hidden);
-        getCurrentAdapter().updateIfSortChanged();
+        final T adapter = getCurrentAdapter();
+        if (adapter != null)
+            adapter.updateIfSortChanged();
     }
 
     @Override



More information about the Android mailing list