[Android] thumbnail: manager doesn't belong in MainActivity anymore
Sébastien Toque
git at videolan.org
Tue Mar 12 11:48:48 CET 2013
vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Tue Mar 12 11:48:38 2013 +0100| [69a45d0c48ccba48c4cfea4805d0f5496a91e5a1] | committer: Sébastien Toque
thumbnail: manager doesn't belong in MainActivity anymore
It is only needed when thumbnail are displayed.
This also avoid long thumbnail process when using only audio.
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=69a45d0c48ccba48c4cfea4805d0f5496a91e5a1
---
.../src/org/videolan/vlc/ThumbnailerManager.java | 2 --
.../src/org/videolan/vlc/gui/MainActivity.java | 15 ---------------
.../videolan/vlc/gui/video/VideoGridFragment.java | 20 ++++++++++++++++----
3 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java b/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java
index bd19251..fc5c44a 100644
--- a/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java
+++ b/vlc-android/src/org/videolan/vlc/ThumbnailerManager.java
@@ -79,7 +79,6 @@ public class ThumbnailerManager implements Runnable {
isStopping = false;
if (mThread == null || mThread.getState() == State.TERMINATED) {
mVideoGridFragment = videoGridFragment;
- mVideoGridFragment.setThumbnailerManager(this);
mThread = new Thread(this);
mThread.start();
}
@@ -191,7 +190,6 @@ public class ThumbnailerManager implements Runnable {
/* cleanup */
MainActivity.hideProgressBar(mContext);
MainActivity.clearTextInfo(mContext);
- mVideoGridFragment.setThumbnailerManager(null);
mVideoGridFragment = null;
Log.d(TAG, "Thumbnailer stopped");
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 142249c..da7e1be 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -26,12 +26,10 @@ import org.videolan.vlc.LibVLC;
import org.videolan.vlc.LibVlcException;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.R;
-import org.videolan.vlc.ThumbnailerManager;
import org.videolan.vlc.Util;
import org.videolan.vlc.VLCCallbackTask;
import org.videolan.vlc.gui.SidebarAdapter.SidebarEntry;
import org.videolan.vlc.gui.video.VideoListAdapter;
-import org.videolan.vlc.gui.video.VideoGridFragment;
import org.videolan.vlc.interfaces.ISortable;
import org.videolan.vlc.widget.AudioMiniPlayer;
@@ -93,7 +91,6 @@ public class MainActivity extends SherlockFragmentActivity {
private SidebarAdapter mSidebarAdapter;
private AudioMiniPlayer mAudioPlayer;
private AudioServiceController mAudioController;
- private ThumbnailerManager mThumbnailerManager;
private View mInfoLayout;
private ProgressBar mInfoProgress;
@@ -281,10 +278,6 @@ public class MainActivity extends SherlockFragmentActivity {
/* Reload the latest preferences */
reloadPreferences();
-
- /* Load the thumbnailer */
- mThumbnailerManager = new ThumbnailerManager(this,
- getWindowManager().getDefaultDisplay());
}
private void changeMenuOffset() {
@@ -379,8 +372,6 @@ public class MainActivity extends SherlockFragmentActivity {
mScanNeeded = MediaLibrary.getInstance(this).isWorking();
/* Stop scanning for files */
MediaLibrary.getInstance(this).stop();
- /* Stop the thumbnailer */
- mThumbnailerManager.stop();
/* Save the tab status in pref */
SharedPreferences.Editor editor = getSharedPreferences("MainActivity", MODE_PRIVATE).edit();
editor.putString("fragment", mCurrentFragment);
@@ -397,8 +388,6 @@ public class MainActivity extends SherlockFragmentActivity {
try {
unregisterReceiver(messageReceiver);
} catch (IllegalArgumentException e) {}
- if (mThumbnailerManager != null)
- mThumbnailerManager.clearJobs();
}
@Override
@@ -442,10 +431,6 @@ public class MainActivity extends SherlockFragmentActivity {
}
mSidebarAdapter.unlockSemaphore();
- /* Start the thumbnailer */
- if (id.equals("video"))
- mThumbnailerManager.start((VideoGridFragment)fragment);
-
return fragment;
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index 49a0c08..593fa43 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -52,6 +52,7 @@ import android.content.res.Configuration;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.support.v4.app.FragmentActivity;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ContextMenu;
@@ -105,6 +106,11 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
mVideoAdapter = new VideoListAdapter(getActivity(), this);
mMediaLibrary = MediaLibrary.getInstance(getActivity());
setListAdapter(mVideoAdapter);
+
+ /* Load the thumbnailer */
+ FragmentActivity activity = getActivity();
+ if (activity != null)
+ mThumbnailerManager = new ThumbnailerManager(activity, activity.getWindowManager().getDefaultDisplay());
}
@Override
@@ -142,6 +148,10 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
public void onPause() {
super.onPause();
mMediaLibrary.removeUpdateHandler(mHandler);
+
+ /* Stop the thumbnailer */
+ if (mThumbnailerManager != null)
+ mThumbnailerManager.stop();
}
@Override
@@ -156,6 +166,10 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
mMediaLibrary.addUpdateHandler(mHandler);
updateViewMode();
mAnimator.animate();
+
+ /* Start the thumbnailer */
+ if (mThumbnailerManager != null)
+ mThumbnailerManager.start(this);
}
@Override
@@ -167,6 +181,8 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
@Override
public void onDestroy() {
super.onDestroy();
+ if (mThumbnailerManager != null)
+ mThumbnailerManager.clearJobs();
mBarrier.reset();
mVideoAdapter.clear();
}
@@ -427,8 +443,4 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
intent.setAction(ACTION_SCAN_STOP);
context.getApplicationContext().sendBroadcast(intent);
}
-
- public void setThumbnailerManager(ThumbnailerManager thumbnailerManager) {
- mThumbnailerManager = thumbnailerManager;
- }
}
More information about the Android
mailing list