Commit 75b8a813 authored by Edward Wang's avatar Edward Wang
Browse files

AudioService: re-use Random

parent 2bf89d8a
......@@ -133,6 +133,7 @@ public class AudioService extends Service {
// Playback management
private boolean mShuffling = false;
private RepeatType mRepeating = RepeatType.None;
private Random mRandom = null; // Used in shuffling process
// RemoteControlClient-related
/**
......@@ -828,10 +829,11 @@ public class AudioService extends Service {
mPrevious.clear();
}
}
if(mRandom == null) mRandom = new Random();
// Find a new index not in mPrevious.
do
{
mNextIndex = new Random().nextInt(size);
mNextIndex = mRandom.nextInt(size);
}
while(mNextIndex == mCurrentIndex || mPrevious.contains(mNextIndex));
......
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