Commit 8faa09da authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf
Browse files

VideoGridFragment: don't overuse context

Just to send a broadcast, use the VLCApplication context
parent c7c63062
...@@ -81,7 +81,7 @@ public class MediaLibrary { ...@@ -81,7 +81,7 @@ public class MediaLibrary {
public void loadMediaItems(Context context) { public void loadMediaItems(Context context) {
if (mLoadingThread == null || mLoadingThread.getState() == State.TERMINATED) { if (mLoadingThread == null || mLoadingThread.getState() == State.TERMINATED) {
isStopping = false; isStopping = false;
VideoGridFragment.actionScanStart(context.getApplicationContext()); VideoGridFragment.actionScanStart();
mLoadingThread = new Thread(new GetMediaItemsRunnable(context.getApplicationContext())); mLoadingThread = new Thread(new GetMediaItemsRunnable(context.getApplicationContext()));
mLoadingThread.start(); mLoadingThread.start();
} }
......
...@@ -35,6 +35,7 @@ import org.videolan.vlc.MediaLibrary; ...@@ -35,6 +35,7 @@ import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.R; import org.videolan.vlc.R;
import org.videolan.vlc.Thumbnailer; import org.videolan.vlc.Thumbnailer;
import org.videolan.vlc.Util; import org.videolan.vlc.Util;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.VlcRunnable; import org.videolan.vlc.VlcRunnable;
import org.videolan.vlc.WeakHandler; import org.videolan.vlc.WeakHandler;
import org.videolan.vlc.gui.CommonDialogs; import org.videolan.vlc.gui.CommonDialogs;
...@@ -153,7 +154,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable ...@@ -153,7 +154,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
getActivity().registerReceiver(messageReceiverVideoListFragment, filter); getActivity().registerReceiver(messageReceiverVideoListFragment, filter);
Log.i(TAG,"mMediaLibrary.isWorking() " + Boolean.toString(mMediaLibrary.isWorking())); Log.i(TAG,"mMediaLibrary.isWorking() " + Boolean.toString(mMediaLibrary.isWorking()));
if (mMediaLibrary.isWorking()) { if (mMediaLibrary.isWorking()) {
actionScanStart(getActivity().getApplicationContext()); actionScanStart();
} }
mAnimator = new VideoGridAnimator(getGridView()); mAnimator = new VideoGridAnimator(getGridView());
...@@ -479,19 +480,15 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable ...@@ -479,19 +480,15 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
} }
}; };
public static void actionScanStart(Context context) { public static void actionScanStart() {
if (context == null)
return;
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(ACTION_SCAN_START); intent.setAction(ACTION_SCAN_START);
context.getApplicationContext().sendBroadcast(intent); VLCApplication.getAppContext().sendBroadcast(intent);
} }
public static void actionScanStop(Context context) { public static void actionScanStop() {
if (context == null)
return;
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(ACTION_SCAN_STOP); intent.setAction(ACTION_SCAN_STOP);
context.getApplicationContext().sendBroadcast(intent); VLCApplication.getAppContext().sendBroadcast(intent);
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment