[Android] Refactor call to start search activity

Geoffrey Métais git at videolan.org
Tue Nov 8 13:47:08 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Nov  8 12:05:17 2016 +0100| [1b228825150b9831038db9a119f57dd54381a7cd] | committer: Geoffrey Métais

Refactor call to start search activity

> https://code.videolan.org/videolan/vlc-android/commit/1b228825150b9831038db9a119f57dd54381a7cd
---

 vlc-android/src/org/videolan/vlc/gui/MainActivity.java              | 6 ++++--
 .../src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java        | 5 +----
 vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java   | 5 +----
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index e96b5fa..19933da 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -21,6 +21,7 @@
 package org.videolan.vlc.gui;
 
 import android.annotation.TargetApi;
+import android.app.SearchManager;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -766,8 +767,9 @@ public class MainActivity extends AudioPlayerContainerActivity implements Device
             MenuItemCompat.collapseActionView(mMenu.findItem(R.id.ml_menu_filter));
     }
 
-    public String getQuery() {
-        return mSearchView.getQuery().toString();
+    public void openSearchActivity() {
+        startActivity(new Intent(Intent.ACTION_SEARCH, null, this, SearchActivity.class)
+                        .putExtra(SearchManager.QUERY, mSearchView.getQuery().toString()));
     }
 
     public void restoreCurrentList() {
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 1f71de8..c740d12 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -21,7 +21,6 @@
 package org.videolan.vlc.gui.audio;
 
 import android.annotation.TargetApi;
-import android.app.SearchManager;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Build;
@@ -60,7 +59,6 @@ import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.gui.MainActivity;
 import org.videolan.vlc.gui.MediaInfoDialog;
-import org.videolan.vlc.gui.SearchActivity;
 import org.videolan.vlc.gui.SecondaryActivity;
 import org.videolan.vlc.gui.browser.MediaBrowserFragment;
 import org.videolan.vlc.gui.dialogs.SavePlaylistDialog;
@@ -494,8 +492,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements Device
     public void onClick(View v) {
         switch (v.getId()) {
             case R.id.searchButton:
-                startActivity(new Intent(Intent.ACTION_SEARCH, null, getContext(), SearchActivity.class)
-                        .putExtra(SearchManager.QUERY, ((MainActivity)getActivity()).getQuery()));
+                 ((MainActivity)getActivity()).openSearchActivity();
                 break;
         }
     }
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 b2f3fa2..02e02ef 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -20,7 +20,6 @@
 
 package org.videolan.vlc.gui.video;
 
-import android.app.SearchManager;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -57,7 +56,6 @@ import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.gui.MainActivity;
 import org.videolan.vlc.gui.MediaInfoDialog;
-import org.videolan.vlc.gui.SearchActivity;
 import org.videolan.vlc.gui.browser.MediaBrowserFragment;
 import org.videolan.vlc.gui.helpers.UiTools;
 import org.videolan.vlc.gui.view.AutoFitRecyclerView;
@@ -556,8 +554,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
     public void onClick(View v) {
         switch (v.getId()) {
             case R.id.searchButton:
-                startActivity(new Intent(Intent.ACTION_SEARCH, null, getContext(), SearchActivity.class)
-                            .putExtra(SearchManager.QUERY, ((MainActivity)getActivity()).getQuery()));
+                ((MainActivity)getActivity()).openSearchActivity();
                 break;
         }
     }



More information about the Android mailing list