Commit 579b575b authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf
Browse files

Don't overuse applicationContext for MainActivity

Just to send a broadcast, use the VLCApplication context
parent 8faa09da
......@@ -220,7 +220,7 @@ public class MediaLibrary {
final MediaDatabase DBManager = MediaDatabase.getInstance(VLCApplication.getAppContext());
// show progressbar in footer
MainActivity.showProgressBar(mContext);
MainActivity.showProgressBar();
List<File> mediaDirs = DBManager.getMediaDirs();
if (mediaDirs.size() == 0) {
......@@ -303,7 +303,7 @@ public class MediaLibrary {
// Process the stacked items
for (File file : mediaToScan) {
String fileURI = LibVLC.PathToURI(file.getPath());
MainActivity.sendTextInfo(mContext, file.getName(), count,
MainActivity.sendTextInfo(file.getName(), count,
mediaToScan.size());
count++;
if (existingMedias.containsKey(fileURI)) {
......@@ -353,10 +353,10 @@ public class MediaLibrary {
}
// hide progressbar in footer
MainActivity.clearTextInfo(mContext);
MainActivity.hideProgressBar(mContext);
MainActivity.clearTextInfo();
MainActivity.hideProgressBar();
VideoGridFragment.actionScanStop(mContext);
VideoGridFragment.actionScanStop();
if (mRestart) {
Log.d(TAG, "Restarting scan");
......
......@@ -135,8 +135,8 @@ public class Thumbnailer implements Runnable {
boolean interrupted = false;
while (mItems.size() == 0) {
try {
MainActivity.hideProgressBar(mContext);
MainActivity.clearTextInfo(mContext);
MainActivity.hideProgressBar();
MainActivity.clearTextInfo();
totalCount = 0;
notEmpty.await();
} catch (InterruptedException e) {
......@@ -153,9 +153,9 @@ public class Thumbnailer implements Runnable {
Media item = mItems.poll();
lock.unlock();
MainActivity.showProgressBar(mContext);
MainActivity.showProgressBar();
MainActivity.sendTextInfo(mContext, String.format("%s %s", mPrefix, item.getFileName()), count, total);
MainActivity.sendTextInfo(String.format("%s %s", mPrefix, item.getFileName()), count, total);
count++;
int width = (int) (120 * mDensity);
......@@ -192,8 +192,8 @@ public class Thumbnailer implements Runnable {
}
}
/* cleanup */
MainActivity.hideProgressBar(mContext);
MainActivity.clearTextInfo(mContext);
MainActivity.hideProgressBar();
MainActivity.clearTextInfo();
mVideoGridFragment = null;
Log.d(TAG, "Thumbnailer stopped");
}
......
......@@ -32,6 +32,7 @@ import org.videolan.vlc.MediaDatabase;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.R;
import org.videolan.vlc.Util;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.VLCCallbackTask;
import org.videolan.vlc.WeakHandler;
import org.videolan.vlc.gui.SidebarAdapter.SidebarEntry;
......@@ -782,35 +783,29 @@ public class MainActivity extends ActionBarActivity {
}
};
public static void showProgressBar(Context context) {
if (context == null)
return;
public static void showProgressBar() {
Intent intent = new Intent();
intent.setAction(ACTION_SHOW_PROGRESSBAR);
context.getApplicationContext().sendBroadcast(intent);
VLCApplication.getAppContext().sendBroadcast(intent);
}
public static void hideProgressBar(Context context) {
if (context == null)
return;
public static void hideProgressBar() {
Intent intent = new Intent();
intent.setAction(ACTION_HIDE_PROGRESSBAR);
context.getApplicationContext().sendBroadcast(intent);
VLCApplication.getAppContext().sendBroadcast(intent);
}
public static void sendTextInfo(Context context, String info, int progress, int max) {
if (context == null)
return;
public static void sendTextInfo(String info, int progress, int max) {
Intent intent = new Intent();
intent.setAction(ACTION_SHOW_TEXTINFO);
intent.putExtra("info", info);
intent.putExtra("progress", progress);
intent.putExtra("max", max);
context.getApplicationContext().sendBroadcast(intent);
VLCApplication.getAppContext().sendBroadcast(intent);
}
public static void clearTextInfo(Context context) {
sendTextInfo(context, null, 0, 100);
public static void clearTextInfo() {
sendTextInfo(null, 0, 100);
}
private void onOpenMRL() {
......
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