Back to project page MusicPlayer.
The source code is released under:
MIT License
If you think the Android project MusicPlayer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.dsvoronin.musicplayer; /* w w w .j ava2s . c o m*/ import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.List; /** * Created by dsvoronin on 27/02/14. */ abstract class AbstractSongPicker implements SongPicker { static final int INVALID_INDEX = -1; protected int mCurrentIndex = INVALID_INDEX; protected List<Playable> mTracks = new ArrayList<Playable>(); @Override public void refresh(@NotNull List<Playable> tracks) { mTracks.clear(); mTracks.addAll(tracks); mCurrentIndex = 0; } @Override public Playable pickSong() { if (mCurrentIndex == INVALID_INDEX) { return null; } Playable playable = mTracks.get(mCurrentIndex); if (mCurrentIndex < mTracks.size() - 1) { mCurrentIndex = mCurrentIndex + 1; } else { mCurrentIndex = 0; } return playable; } }