return false;
}
+
+ /**
+ * @return Gets the list of song ids from the adapter
+ */
+ public long[] getSongIds() {
+ long[] ret = new long[getCount()];
+ for (int i = 0; i < getCount(); i++) {
+ ret[i] = getItem(i).mSongId;
+ }
+
+ return ret;
+ }
}
*/
public void playAll(int position) {
int internalPosition = mAdapter.getInternalPosition(position);
- Cursor cursor = SongLoader.makeSongCursor(getActivity(), null);
- final long[] list = MusicUtils.getSongListForCursor(cursor);
- MusicUtils.playAll(getActivity(), list, internalPosition, -1, Config.IdType.NA, false);
- cursor.close();
- cursor = null;
+ final long[] list = mAdapter.getUnderlyingAdapter().getSongIds();
+ if (list != null) {
+ MusicUtils.playAll(getActivity(), list, internalPosition, -1, Config.IdType.NA, false);
+ }
}
/**
}
/**
+ * @return Gets the list of song ids from the adapter, or null if none
+ */
+ protected long[] getSongIdsFromAdapter() {
+ if (mAdapter != null) {
+ final SongAdapter adapter = mAdapter.getUnderlyingAdapter();
+ if (adapter != null) {
+ return adapter.getSongIds();
+ }
+ }
+
+ return null;
+ }
+
+ /**
* Restarts the loader.
*/
public void refresh() {
import com.cyngn.eleven.Config.SmartPlaylistType;
import com.cyngn.eleven.Config;
import com.cyngn.eleven.R;
+import com.cyngn.eleven.adapters.SongAdapter;
import com.cyngn.eleven.menu.ConfirmDialog;
import com.cyngn.eleven.model.Playlist;
import com.cyngn.eleven.utils.MusicUtils;
}
public void playAll(int position, boolean shuffle) {
- MusicUtils.playSmartPlaylist(getActivity(), position,
- getSmartPlaylistType(), shuffle);
+ // we grab the song ids from the adapter instead of querying the cursor because the user
+ // expects what they see to be what they play. The counter argument of updating the list
+ // could be made, but refreshing the smart playlists so often will be annoying and
+ // confusing for the user so this is an intermediate compromise. An example is the top
+ // tracks list is based on the # of times you play a song, but near the beginning each
+ // song being played will change the list and the compromise is to update only when you
+ // enter the page.
+ long[] songIds = getSongIdsFromAdapter();
+ if (songIds != null) {
+ MusicUtils.playAll(getActivity(), songIds, position, getSmartPlaylistType().mId,
+ Config.IdType.Playlist, shuffle);
+ }
}
protected abstract SmartPlaylistType getSmartPlaylistType();