[Android] Prevent IllegalStateException on browser updates
Geoffrey Métais
git at videolan.org
Mon Jul 10 09:33:58 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jul 10 09:33:20 2017 +0200| [cd1c99efc68bb3f60a47d2272c57f68cd9cb34e4] | committer: Geoffrey Métais
Prevent IllegalStateException on browser updates
> https://code.videolan.org/videolan/vlc-android/commit/cd1c99efc68bb3f60a47d2272c57f68cd9cb34e4
---
vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java | 4 +++-
.../src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index 6302caf24..030948d13 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -316,6 +316,8 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
@Override
public void onBrowseEnd() {
+ if (!isAdded())
+ return;
mHandler.sendEmptyMessage(BrowserFragmentHandler.MSG_HIDE_LOADING);
releaseBrowser();
VLCApplication.runOnMainThread(new Runnable() {
@@ -639,7 +641,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
@Override
public void onBrowseEnd() {
synchronized (currentMediaList) {
- if (currentMediaList.isEmpty() || getActivity() == null) {
+ if (currentMediaList.isEmpty() || !isAdded()) {
mCurrentParsedPosition = -1;
releaseBrowser();
return;
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
index 457f99d97..c48b6ee5f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/NetworkBrowserFragment.java
@@ -126,6 +126,8 @@ public class NetworkBrowserFragment extends BaseBrowserFragment {
@Override
protected void browseRoot() {
+ if (!isAdded())
+ return;
updateFavorites();
mAdapter.setTop(mAdapter.getItemCount());
if (allowLAN())
More information about the Android
mailing list