use of com.cyl.musiclake.bean.Playlist in project MusicLake by caiyonglong.
the class PlaylistLoader method getPlaylist.
/**
* 获取全部歌单
*
* @param context
* @return
*/
public static List<Playlist> getPlaylist(Context context) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
String sql = "SELECT *" + " , " + "(SELECT count(" + DBData.MTP_TABLE + ".mid ) FROM " + DBData.MTP_TABLE + " WHERE " + DBData.MTP_TABLE + ".pid = " + DBData.PLAYLIST_TABLE + ".pid) AS num FROM " + DBData.PLAYLIST_TABLE + " where " + DBData.PLAYLIST_TABLE + "." + DBData.PLAYLIST_DATE + " is not null ";
LogUtil.d(TAG, sql + "----");
Cursor cursor = dbDaoImpl.makeCursor(sql);
List<Playlist> results = dbDaoImpl.getAllPlaylistForCursor(cursor);
dbDaoImpl.closeDB();
return results;
}
use of com.cyl.musiclake.bean.Playlist in project MusicLake by caiyonglong.
the class AddPlaylistDialog method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Music music = getArguments().getParcelable("music");
if (music.getType() == Music.Type.LOCAL) {
return new MaterialDialog.Builder(getActivity()).title("增加到歌单").content("暂不支持添加本地歌曲到在线歌单").build();
}
final List<Playlist> playlists = PlaylistLoader.getPlaylist(getActivity());
final CharSequence[] chars = new CharSequence[playlists.size() + 1];
chars[0] = "新建歌单";
for (int i = 0; i < playlists.size(); i++) {
chars[i + 1] = playlists.get(i).getName();
}
return new MaterialDialog.Builder(getActivity()).title("增加到歌单").items(chars).itemsCallback((dialog, itemView, which, text) -> {
if (which == 0) {
CreatePlaylistDialog createDialog = CreatePlaylistDialog.newInstance(music);
createDialog.show(getFragmentManager(), TAG_CREATE);
} else {
Log.d("addDialog", which + "----" + playlists.get(which - 1).getId() + "------" + music.getId());
result = PlaylistLoader.addToPlaylist(getActivity(), playlists.get(which - 1).getId(), music.getId());
if (result) {
RxBus.getInstance().post(new Playlist());
ToastUtils.show(getActivity(), "添加成功");
} else {
ToastUtils.show(getActivity(), "歌单中已有此音乐,请勿重复添加");
}
dialog.dismiss();
}
}).build();
}
Aggregations