[Android] Prevent NPE on TV browsers

Geoffrey Métais git at videolan.org
Thu Aug 25 14:50:23 CEST 2016


vlc-android | branch: 2.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Aug 25 13:24:02 2016 +0200| [b4606d64a92da372d14db3b948fdc1238990e17f] | committer: Geoffrey Métais

Prevent NPE on TV browsers

(cherry picked from commit 7a66fbddd96da475f0bff6d4eccfee30a06a40c6)

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

 .../src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java  | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java
index be51664..35d99dc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java
@@ -24,6 +24,7 @@
 package org.videolan.vlc.gui.tv.browser;
 
 import android.annotation.TargetApi;
+import android.app.Activity;
 import android.content.Intent;
 import android.os.Build;
 import android.os.Bundle;
@@ -171,11 +172,14 @@ public abstract class SortedBrowserFragment extends BrowseFragment implements Br
 
     @Override
     public void updateList() {
+        Activity activity = getActivity();
+        if (activity == null)
+            return;
         mAdapter.clear();
         ArrayObjectAdapter adapter;
         HeaderItem header;
         for (ListItem item : mMediaItemMap.values()){
-            adapter = new ArrayObjectAdapter(new CardPresenter(getActivity()));
+            adapter = new ArrayObjectAdapter(new CardPresenter(activity));
             header = new HeaderItem(0, item.Letter);
             adapter.addAll(0, item.mediaList);
             mAdapter.add(new ListRow(header, adapter));



More information about the Android mailing list