Commit 2ac37c48 authored by Geoffrey Métais's avatar Geoffrey Métais

final ints for repeat type

parent e57efe51
......@@ -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;
}
......
......@@ -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();
......
......@@ -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;
......
......@@ -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);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment