[Android] Fix double update in TV fragments
Geoffrey Métais
git at videolan.org
Fri Jul 10 12:11:10 CEST 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jul 10 12:10:47 2015 +0200| [0f8959a764322698c93962b7beae6695b81c3264] | committer: Geoffrey Métais
Fix double update in TV fragments
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=0f8959a764322698c93962b7beae6695b81c3264
---
.../videolan/vlc/gui/tv/browser/MusicFragment.java | 18 +++++++++++++++---
.../vlc/gui/tv/browser/VideoGridFragment.java | 11 ++++++++---
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/MusicFragment.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/MusicFragment.java
index 52ed7c1..07fa357 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/MusicFragment.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/MusicFragment.java
@@ -62,6 +62,7 @@ public class MusicFragment extends MediaLibBrowserFragment {
protected Map<String, ListItem> mMediaItemMap;
protected ArrayList<ListItem> mMediaItemList;
+ private volatile AsyncAudioUpdate mUpdater = null;
String mFilter;
int mCategory;
@@ -82,12 +83,20 @@ public class MusicFragment extends MediaLibBrowserFragment {
public void onResume() {
super.onResume();
- if (mAdapter.size() == 0) {
- new AsyncAudioUpdate().execute();
+ if (mAdapter.size() == 0 && mUpdater == null) {
+ mUpdater = new AsyncAudioUpdate();
+ mUpdater.execute();
}
mMediaLibrary.addUpdateHandler(mHandler);
}
+ @Override
+ public void onPause() {
+ super.onPause();
+ if (mUpdater != null)
+ mUpdater.cancel(true);
+ }
+
public void onSaveInstanceState(Bundle outState){
super.onSaveInstanceState(outState);
outState.putInt(AUDIO_CATEGORY, mCategory);
@@ -232,7 +241,10 @@ public class MusicFragment extends MediaLibBrowserFragment {
@Override
protected void updateList() {
- new AsyncAudioUpdate().execute();
+ if (mUpdater == null) {
+ mUpdater = new AsyncAudioUpdate();
+ mUpdater.execute();
+ }
}
private MediaLibHandler mHandler = new MediaLibHandler(this);
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/VideoGridFragment.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/VideoGridFragment.java
index 1257fb6..57596c8 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/VideoGridFragment.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/browser/VideoGridFragment.java
@@ -43,6 +43,8 @@ public class VideoGridFragment extends MediaLibBrowserFragment implements IVideo
private Handler mHandler = new VideoListHandler(this);
protected static Thumbnailer sThumbnailer;
+ private volatile AsyncVideoUpdate mUpdater = null;
+
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sThumbnailer = MainTvActivity.getThumbnailer();
@@ -51,8 +53,9 @@ public class VideoGridFragment extends MediaLibBrowserFragment implements IVideo
public void onResume() {
super.onResume();
mMediaLibrary.addUpdateHandler(mHandler);
- if (mAdapter.size() == 0) {
- new AsyncVideoUpdate().execute();
+ if (mAdapter.size() == 0 && mUpdater == null) {
+ mUpdater = new AsyncVideoUpdate();
+ mUpdater.execute();
}
if (sThumbnailer != null)
sThumbnailer.setVideoBrowser(this);
@@ -125,7 +128,9 @@ public class VideoGridFragment extends MediaLibBrowserFragment implements IVideo
@Override
public void updateList() {
- new AsyncVideoUpdate().execute();
+ if (mUpdater == null) {
+ new AsyncVideoUpdate().execute();
+ }
}
@Override
More information about the Android
mailing list