[Android] final ints for repeat type

Geoffrey Métais git at videolan.org
Mon Aug 31 12:36:01 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Aug 31 11:56:14 2015 +0200| [2ac37c48a530ca54ca3714b79178ff17306caf20] | committer: Geoffrey Métais

final ints for repeat type

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

 .../src/org/videolan/vlc/PlaybackService.java      |   28 +++++++++-----------
 .../org/videolan/vlc/gui/audio/AudioPlayer.java    |   18 ++++++-------
 .../vlc/gui/video/VideoPlayerActivity.java         |    8 +++---
 .../gui/tv/audioplayer/AudioPlayerActivity.java    |   14 +++++-----
 4 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 6cc5330..cc77e5c 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -146,8 +146,12 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
     private int mNextIndex; // Set to -1 if no next media
 
     // Playback management
+
+    public static final int REPEAT_NONE = 0;
+    public static final int REPEAT_ONE = 1;
+    public static final int REPEAT_ALL = 2;
     private boolean mShuffling = false;
-    private RepeatType mRepeating = RepeatType.None;
+    private int mRepeating = REPEAT_NONE;
     private Random mRandom = null; // Used in shuffling process
 
     private boolean mHasAudioFocus = false;
@@ -180,12 +184,6 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
         return mp;
     }
 
-    public static enum RepeatType {
-        None,
-        Once,
-        All
-    }
-
     private static boolean readPhoneState() {
         return !AndroidUtil.isFroyoOrLater();
     }
@@ -1030,7 +1028,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
             mShuffling &= size > 2;
 
             // Repeating once doesn't change the index
-            if (mRepeating == RepeatType.Once) {
+            if (mRepeating == REPEAT_ONE) {
                 mPrevIndex = mNextIndex = mCurrentIndex;
             } else {
 
@@ -1040,7 +1038,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
                     // If we've played all songs already in shuffle, then either
                     // reshuffle or stop (depending on RepeatType).
                     if(mPrevious.size() + 1 == size) {
-                        if(mRepeating == RepeatType.None) {
+                        if(mRepeating == REPEAT_NONE) {
                             mNextIndex = -1;
                             return;
                         } else {
@@ -1062,7 +1060,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
                     if(mCurrentIndex + 1 < size)
                         mNextIndex = mCurrentIndex + 1;
                     else {
-                        if(mRepeating == RepeatType.None) {
+                        if(mRepeating == REPEAT_NONE) {
                             mNextIndex = -1;
                         } else {
                             mNextIndex = 0;
@@ -1178,8 +1176,8 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
     }
 
     @MainThread
-    public void setRepeatType(RepeatType t) {
-        mRepeating = t;
+    public void setRepeatType(int repeatType) {
+        mRepeating = repeatType;
         saveCurrentMedia();
         determinePrevAndNextIndices();
     }
@@ -1264,7 +1262,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
             mediaPathList.add(Uri.decode(locations[i]));
 
         mShuffling = prefs.getBoolean("shuffling", false);
-        mRepeating = RepeatType.values()[prefs.getInt("repeating", RepeatType.None.ordinal())];
+        mRepeating = prefs.getInt("repeating", REPEAT_NONE);
         int position = prefs.getInt("position_in_list", Math.max(0, mediaPathList.indexOf(currentMedia)));
         long time = prefs.getLong("position_in_song", -1);
         // load playlist
@@ -1281,7 +1279,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
         SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
         editor.putString("current_media", mMediaList.getMRL(Math.max(mCurrentIndex, 0)));
         editor.putBoolean("shuffling", mShuffling);
-        editor.putInt("repeating", mRepeating.ordinal());
+        editor.putInt("repeating", mRepeating);
         Util.commitPreferences(editor);
     }
 
@@ -1346,7 +1344,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
     }
 
     @MainThread
-    public RepeatType getRepeatType() {
+    public int getRepeatType() {
         return mRepeating;
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index e4eacbc..f2a495b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -364,16 +364,16 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
             mShuffle.setContentDescription(getResources().getString(R.string.shuffle));
         }
         switch(mService.getRepeatType()) {
-        case None:
+        case PlaybackService.REPEAT_NONE:
             mRepeat.setImageResource(Util.getResourceFromAttribute(act, R.attr.ic_repeat));
             mRepeat.setContentDescription(getResources().getString(R.string.repeat));
             break;
-        case Once:
+        case PlaybackService.REPEAT_ONE:
             mRepeat.setImageResource(Util.getResourceFromAttribute(act, R.attr.ic_repeat_one));
             mRepeat.setContentDescription(getResources().getString(R.string.repeat_single));
             break;
         default:
-        case All:
+        case PlaybackService.REPEAT_ALL:
             mRepeat.setImageResource(Util.getResourceFromAttribute(act, R.attr.ic_repeat_on));
             mRepeat.setContentDescription(getResources().getString(R.string.repeat_all));
             break;
@@ -516,15 +516,15 @@ public class AudioPlayer extends PlaybackServiceFragment implements PlaybackServ
             return;
 
         switch (mService.getRepeatType()) {
-            case None:
-                mService.setRepeatType(PlaybackService.RepeatType.All);
+            case PlaybackService.REPEAT_NONE:
+                mService.setRepeatType(PlaybackService.REPEAT_ALL);
                 break;
-            case All:
-                mService.setRepeatType(PlaybackService.RepeatType.Once);
+            case PlaybackService.REPEAT_ALL:
+                mService.setRepeatType(PlaybackService.REPEAT_ONE);
                 break;
             default:
-            case Once:
-                mService.setRepeatType(PlaybackService.RepeatType.None);
+            case PlaybackService.REPEAT_ONE:
+                mService.setRepeatType(PlaybackService.REPEAT_NONE);
                 break;
         }
         update();
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 1c81283..dcc94a4 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1431,7 +1431,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
     private void endReached() {
         if (mService == null)
             return;
-        if (mService.getRepeatType() == PlaybackService.RepeatType.Once){
+        if (mService.getRepeatType() == PlaybackService.REPEAT_ONE){
             seek(0);
             return;
         }
@@ -2068,11 +2068,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         public boolean onLongClick(View v) {
             if (mService == null)
                 return false;
-            if (mService.getRepeatType() == PlaybackService.RepeatType.Once) {
+            if (mService.getRepeatType() == PlaybackService.REPEAT_ONE) {
                 showInfo(getString(R.string.repeat));
-                mService.setRepeatType(PlaybackService.RepeatType.None);
+                mService.setRepeatType(PlaybackService.REPEAT_NONE);
             } else {
-                mService.setRepeatType(PlaybackService.RepeatType.Once);
+                mService.setRepeatType(PlaybackService.REPEAT_ONE);
                 showInfo(getString(R.string.repeat_single));
             }
             return true;
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
index 0af0a2c..6845685 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/audioplayer/AudioPlayerActivity.java
@@ -323,15 +323,15 @@ public class AudioPlayerActivity extends BaseTvActivity implements PlaybackServi
     private void updateRepeatMode() {
         if (mService == null)
             return;
-        PlaybackService.RepeatType type = mService.getRepeatType();
-        if (type == PlaybackService.RepeatType.None){
-            mService.setRepeatType(PlaybackService.RepeatType.All);
+        int type = mService.getRepeatType();
+        if (type == PlaybackService.REPEAT_NONE){
+            mService.setRepeatType(PlaybackService.REPEAT_ALL);
             mRepeat.setImageResource(R.drawable.ic_repeat_on);
-        } else if (type == PlaybackService.RepeatType.All) {
-            mService.setRepeatType(PlaybackService.RepeatType.Once);
+        } else if (type == PlaybackService.REPEAT_ALL) {
+            mService.setRepeatType(PlaybackService.REPEAT_ONE);
             mRepeat.setImageResource(R.drawable.ic_repeat_one);
-        } else if (type == PlaybackService.RepeatType.Once) {
-            mService.setRepeatType(PlaybackService.RepeatType.None);
+        } else if (type == PlaybackService.REPEAT_ONE) {
+            mService.setRepeatType(PlaybackService.REPEAT_NONE);
             mRepeat.setImageResource(R.drawable.ic_repeat);
         }
     }



More information about the Android mailing list