[Android] Remove context paramter from MediaLibrary.getInstance

Jean-Baptiste Kempf git at videolan.org
Sun Jul 6 08:24:11 CEST 2014


vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Sun Jul  6 08:08:37 2014 +0200| [7cca700505e143ba0b9f3612871091818ba0ff0b] | committer: Jean-Baptiste Kempf

Remove context paramter from MediaLibrary.getInstance

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

 vlc-android/src/org/videolan/vlc/MediaLibrary.java           |    2 +-
 vlc-android/src/org/videolan/vlc/gui/MainActivity.java       |   10 +++++-----
 vlc-android/src/org/videolan/vlc/gui/SearchFragment.java     |    3 +--
 .../org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java |    2 +-
 .../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java |    4 ++--
 .../src/org/videolan/vlc/gui/video/MediaInfoFragment.java    |    2 +-
 .../src/org/videolan/vlc/gui/video/VideoGridFragment.java    |    2 +-
 7 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index c0d0f18..d58f92e 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -98,7 +98,7 @@ public class MediaLibrary {
         return false;
     }
 
-    public static MediaLibrary getInstance(Context context) {
+    public static MediaLibrary getInstance() {
         if (mInstance == null)
             mInstance = new MediaLibrary();
         return mInstance;
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index ae7d44d..a781d2a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -331,7 +331,7 @@ public class MainActivity extends ActionBarActivity {
 
         /* Load media items from database and storage */
         if (mScanNeeded)
-            MediaLibrary.getInstance(this).loadMediaItems();
+            MediaLibrary.getInstance().loadMediaItems();
     }
 
     @Override
@@ -398,9 +398,9 @@ public class MainActivity extends ActionBarActivity {
         super.onPause();
 
         /* Check for an ongoing scan that needs to be resumed during onResume */
-        mScanNeeded = MediaLibrary.getInstance(this).isWorking();
+        mScanNeeded = MediaLibrary.getInstance().isWorking();
         /* Stop scanning for files */
-        MediaLibrary.getInstance(this).stop();
+        MediaLibrary.getInstance().stop();
         /* Save the tab status in pref */
         SharedPreferences.Editor editor = getSharedPreferences("MainActivity", MODE_PRIVATE).edit();
         editor.putString("fragment", mCurrentFragment);
@@ -639,7 +639,7 @@ public class MainActivity extends ActionBarActivity {
                 else if(mCurrentFragment != null && mCurrentFragment.equals("history"))
                     ((HistoryFragment) getFragment(mCurrentFragment)).refresh();
                 else
-                    MediaLibrary.getInstance(this).loadMediaItems(this, true);
+                    MediaLibrary.getInstance().loadMediaItems(this, true);
                 break;
             // Restore last playlist
             case R.id.ml_menu_last_playlist:
@@ -681,7 +681,7 @@ public class MainActivity extends ActionBarActivity {
         super.onActivityResult(requestCode, resultCode, data);
         if (requestCode == ACTIVITY_RESULT_PREFERENCES) {
             if (resultCode == PreferencesActivity.RESULT_RESCAN)
-                MediaLibrary.getInstance(this).loadMediaItems(this, true);
+                MediaLibrary.getInstance().loadMediaItems(this, true);
             else if (resultCode == PreferencesActivity.RESULT_RESTART) {
                 Intent intent = getIntent();
                 finish();
diff --git a/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java b/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java
index 056e590..9eea300 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java
@@ -20,7 +20,6 @@
 
 package org.videolan.vlc.gui;
 
-import java.lang.Override;
 import java.util.ArrayList;
 import java.util.Locale;
 
@@ -105,7 +104,7 @@ public class SearchFragment extends ListFragment {
         // set result adapter to the list
         mResultAdapter.clear();
         String[] keys = key.toString().split("\\s+");
-        ArrayList<Media> allItems = MediaLibrary.getInstance(getActivity()).getMediaItems();
+        ArrayList<Media> allItems = MediaLibrary.getInstance().getMediaItems();
         int results = 0;
         for (int i = 0; i < allItems.size(); i++) {
             Media item = allItems.get(i);
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index a16d273..79d9f0d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -101,7 +101,7 @@ public class AudioAlbumsSongsFragment extends Fragment {
         mSongsAdapter.setContextPopupMenuListener(mContextPopupMenuListener);
 
         mAudioController = AudioServiceController.getInstance();
-        mMediaLibrary = MediaLibrary.getInstance(getActivity());
+        mMediaLibrary = MediaLibrary.getInstance();
     }
 
     @Override
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index ec5d8ab..db7648f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -97,7 +97,7 @@ public class AudioBrowserFragment extends Fragment {
 
         mAudioController = AudioServiceController.getInstance();
 
-        mMediaLibrary = MediaLibrary.getInstance(getActivity());
+        mMediaLibrary = MediaLibrary.getInstance();
 
         mSongsAdapter = new AudioBrowserListAdapter(getActivity(), AudioBrowserListAdapter.ITEM_WITH_COVER);
         mArtistsAdapter = new AudioBrowserListAdapter(getActivity(), AudioBrowserListAdapter.ITEM_WITH_COVER);
@@ -375,7 +375,7 @@ public class AudioBrowserFragment extends Fragment {
     };
 
     private void updateLists() {
-        List<Media> audioList = MediaLibrary.getInstance(getActivity()).getAudioItems();
+        List<Media> audioList = MediaLibrary.getInstance().getAudioItems();
 
         if (audioList.isEmpty())
             mEmptyView.setVisibility(View.VISIBLE);
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
index 13846b9..20cb5ed 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
@@ -101,7 +101,7 @@ public class MediaInfoFragment extends ListFragment {
     public void setMediaLocation(String MRL) {
         if (MRL == null)
             return;
-        mItem = MediaLibrary.getInstance(getActivity()).getMediaItem(MRL);
+        mItem = MediaLibrary.getInstance().getMediaItem(MRL);
     }
 
     Runnable mLoadImage = new Runnable() {
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 4f7d464..8e2c394 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -118,7 +118,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
         mAudioController = AudioServiceController.getInstance();
 
         mVideoAdapter = new VideoListAdapter(getActivity(), this);
-        mMediaLibrary = MediaLibrary.getInstance(getActivity());
+        mMediaLibrary = MediaLibrary.getInstance();
         setListAdapter(mVideoAdapter);
 
         /* Load the thumbnailer */



More information about the Android mailing list