[Android] Release mediaBrowser on background
Geoffrey Métais
git at videolan.org
Mon Feb 9 11:30:49 CET 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 4 19:37:20 2015 +0100| [f9bb39ec48b194d71b7bebb518dae89a73ad6c90] | committer: Geoffrey Métais
Release mediaBrowser on background
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=f9bb39ec48b194d71b7bebb518dae89a73ad6c90
---
.../src/org/videolan/vlc/gui/network/NetworkFragment.java | 4 ++--
.../videolan/vlc/gui/tv/browser/BrowserGridFragment.java | 11 +++++++----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/network/NetworkFragment.java b/vlc-android/src/org/videolan/vlc/gui/network/NetworkFragment.java
index c9a1331..db226b7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/network/NetworkFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/network/NetworkFragment.java
@@ -98,12 +98,12 @@ public class NetworkFragment extends BrowserFragment implements IRefreshable, Me
public void onStop(){
super.onStop();
+ mMediaBrowser.release();
savedPosition = mRecyclerView.getScrollY();
}
public void onStart(){
super.onStart();
- if (mMediaBrowser == null)
- mMediaBrowser = new MediaBrowser(mLibVLC, this);
+ mMediaBrowser = new MediaBrowser(mLibVLC, this);
if (mAdapter.isEmpty()) {
refresh();
} else {
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
index 93a5003..eef8632 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
@@ -63,10 +63,9 @@ public class BrowserGridFragment extends GridFragment implements MediaBrowser.Ev
super.onResume();
if (mAdapter.size() == 0) {
if (mAdapter.size() == 0) {
- if (mMediaBrowser == null)
- try {
- mMediaBrowser = new MediaBrowser(LibVLC.getInstance(), this);
- } catch (LibVlcException e) {}
+ try {
+ mMediaBrowser = new MediaBrowser(LibVLC.getInstance(), this);
+ } catch (LibVlcException e) {}
if (mMediaBrowser != null) {
mMediaList = new ArrayList<>();
if (mMrl != null)
@@ -81,6 +80,10 @@ public class BrowserGridFragment extends GridFragment implements MediaBrowser.Ev
}
}
+ public void onPause(){
+ super.onPause();
+ mMediaBrowser.release();
+ }
@Override
public void onMediaAdded(int index, Media media) {
mMediaList.add(new MediaWrapper(media));
More information about the Android
mailing list