[Android] Local broadcast for scan intents

Geoffrey Métais git at videolan.org
Fri Nov 6 16:30:35 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Nov  6 15:34:59 2015 +0100| [662fe5aaa953b277a2ee380f1c652909958a54d0] | committer: Geoffrey Métais

Local broadcast for scan intents

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=662fe5aaa953b277a2ee380f1c652909958a54d0
---

 vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java |    5 +++--
 vlc-android/src/org/videolan/vlc/util/Util.java                   |    5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

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 df5100e..b35ab4b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -35,6 +35,7 @@ import android.os.Message;
 import android.preference.PreferenceManager;
 import android.support.design.widget.Snackbar;
 import android.support.v4.app.FragmentActivity;
+import android.support.v4.content.LocalBroadcastManager;
 import android.support.v4.util.ArrayMap;
 import android.util.DisplayMetrics;
 import android.util.Log;
@@ -158,7 +159,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
         IntentFilter filter = new IntentFilter();
         filter.addAction(Util.ACTION_SCAN_START);
         filter.addAction(Util.ACTION_SCAN_STOP);
-        getActivity().registerReceiver(messageReceiverVideoListFragment, filter);
+        LocalBroadcastManager.getInstance(getActivity()).registerReceiver(messageReceiverVideoListFragment, filter);
         if (mMediaLibrary.isWorking()) {
             Util.actionScanStart();
         }
@@ -213,7 +214,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
 
     @Override
     public void onDestroyView() {
-        getActivity().unregisterReceiver(messageReceiverVideoListFragment);
+        LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(messageReceiverVideoListFragment);
         super.onDestroyView();
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/util/Util.java b/vlc-android/src/org/videolan/vlc/util/Util.java
index 1bc47f4..eb25809 100644
--- a/vlc-android/src/org/videolan/vlc/util/Util.java
+++ b/vlc-android/src/org/videolan/vlc/util/Util.java
@@ -36,6 +36,7 @@ import android.os.Build;
 import android.preference.PreferenceManager;
 import android.provider.MediaStore;
 import android.support.design.widget.Snackbar;
+import android.support.v4.content.LocalBroadcastManager;
 import android.text.TextUtils.TruncateAt;
 import android.util.DisplayMetrics;
 import android.util.TypedValue;
@@ -179,13 +180,13 @@ public class Util {
     public static void actionScanStart() {
         Intent intent = new Intent();
         intent.setAction(ACTION_SCAN_START);
-        VLCApplication.getAppContext().sendBroadcast(intent);
+        LocalBroadcastManager.getInstance(VLCApplication.getAppContext()).sendBroadcast(intent);
     }
 
     public static void actionScanStop() {
         Intent intent = new Intent();
         intent.setAction(ACTION_SCAN_STOP);
-        VLCApplication.getAppContext().sendBroadcast(intent);
+        LocalBroadcastManager.getInstance(VLCApplication.getAppContext()).sendBroadcast(intent);
     }
 
     private static class DialogCallback implements PlaybackService.Client.Callback {



More information about the Android mailing list