[Android] Use constants for secondary activity launch

Geoffrey Métais git at videolan.org
Fri Apr 17 14:35:24 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Apr 17 11:07:49 2015 +0200| [9df750189ab002248227d2681f4a87f409c72feb] | committer: Geoffrey Métais

Use constants for secondary activity launch

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

 .../src/org/videolan/vlc/gui/MainActivity.java        |    4 ++--
 .../src/org/videolan/vlc/gui/SecondaryActivity.java   |   17 ++++++++++++-----
 .../org/videolan/vlc/gui/video/AdvOptionsDialog.java  |    3 ++-
 .../org/videolan/vlc/gui/video/VideoGridFragment.java |    4 ++--
 4 files changed, 18 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 054b01a..f20af7a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -553,7 +553,7 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
                 }
                 break;
             case R.id.ml_menu_equalizer:
-                showSecondaryFragment("equalizer");
+                showSecondaryFragment(SecondaryActivity.EQUALIZER);
                 break;
             // Refresh
             case R.id.ml_menu_refresh:
@@ -977,7 +977,7 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
             if (mFocusedPrior != 0)
                 requestFocusOnSearch();
         } else if (entry.type == SidebarEntry.TYPE_SECONDARY_FRAGMENT)
-            showSecondaryFragment("about");
+            showSecondaryFragment(SecondaryActivity.ABOUT);
         else if (entry.attributeID == R.attr.ic_menu_preferences)
             startActivityForResult(new Intent(this, PreferencesActivity.class), ACTIVITY_RESULT_PREFERENCES);
         mRootContainer.closeDrawer(mListView);
diff --git a/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.java b/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.java
index d1ddf7e..580db3a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.java
@@ -47,7 +47,14 @@ import java.util.List;
 public class SecondaryActivity  extends ActionBarActivity {
     public final static String TAG = "VLC/EqualizerFragment";
 
+    public static final String ALBUMS_SONGS = "albumsSongs";
+    public static final String EQUALIZER = "equalizer";
+    public static final String ABOUT = "about";
+    public static final String MEDIA_INFO = "mediaInfo";
+    public static final String VIDEO_GROUP_LIST = "videoGroupList";
+
     Fragment mFragment;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         /* Theme must be applied before super.onCreate */
@@ -104,19 +111,19 @@ public class SecondaryActivity  extends ActionBarActivity {
     }
 
     public void fetchSecondaryFragment(String id) {
-        if (id.equals("albumsSongs")) {
+        if (id.equals(ALBUMS_SONGS)) {
             ArrayList<MediaWrapper> mediaList = getIntent().getParcelableArrayListExtra("list");
             String filter = getIntent().getStringExtra("filter");
             mFragment = new AudioAlbumsSongsFragment();
             ((AudioAlbumsSongsFragment)mFragment).setMediaList(mediaList, filter);
-        } else if(id.equals("equalizer")) {
+        } else if(id.equals(EQUALIZER)) {
             mFragment = new EqualizerFragment();
-        } else if(id.equals("about")) {
+        } else if(id.equals(ABOUT)) {
             mFragment = new AboutFragment();
-        } else if(id.equals("mediaInfo")) {
+        } else if(id.equals(MEDIA_INFO)) {
             mFragment = new MediaInfoFragment();
             ((MediaInfoFragment)mFragment).setMediaLocation(getIntent().getStringExtra("param"));
-        } else if(id.equals("videoGroupList")) {
+        } else if(id.equals(VIDEO_GROUP_LIST)) {
             mFragment = new VideoGridFragment();
             ((VideoGridFragment)mFragment).setGroup(getIntent().getStringExtra("param"));
         }
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java b/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java
index 7626660..40d923e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java
@@ -49,6 +49,7 @@ import org.videolan.vlc.BuildConfig;
 import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
 import org.videolan.vlc.gui.MainActivity;
+import org.videolan.vlc.gui.SecondaryActivity;
 import org.videolan.vlc.gui.dialogs.AudioDelayDialog;
 import org.videolan.vlc.gui.dialogs.JumpToTimeDialog;
 import org.videolan.vlc.gui.dialogs.PickTimeFragment;
@@ -399,7 +400,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
                 ((VideoPlayerActivity)getActivity()).switchToAudioMode(true);
                 break;
             case R.id.opt_equalizer:
-                ((MainActivity)getActivity()).showSecondaryFragment("equalizer");
+                ((MainActivity)getActivity()).showSecondaryFragment(SecondaryActivity.EQUALIZER);
                 dismiss();
                 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 cd3d2a3..07f7783 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -284,7 +284,7 @@ public class VideoGridFragment extends BrowserFragment implements ISortable, IVi
             return;
         if (media instanceof MediaGroup) {
             MainActivity activity = (MainActivity)getActivity();
-            activity.showSecondaryFragment("videoGroupList", media.getTitle());
+            activity.showSecondaryFragment(SecondaryActivity.VIDEO_GROUP_LIST, media.getTitle());
         }
         else
             playVideo(media, false);
@@ -314,7 +314,7 @@ public class VideoGridFragment extends BrowserFragment implements ISortable, IVi
             case R.id.video_list_info:
                 Activity activity = getActivity();
                 if (activity instanceof MainActivity)
-                    ((MainActivity)activity).showSecondaryFragment("mediaInfo", media.getLocation());
+                    ((MainActivity)activity).showSecondaryFragment(SecondaryActivity.MEDIA_INFO, media.getLocation());
                 else {
                     Intent i = new Intent(activity, SecondaryActivity.class);
                     i.putExtra("fragment", "mediaInfo");



More information about the Android mailing list