use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlayQueueLoader method addSongToQueue.
/**
* 添加歌曲到歌单
*/
private static void addSongToQueue(Context context, List<Music> musics) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
dbDaoImpl.insertSongs(musics);
for (int i = 0; i < musics.size(); i++) {
dbDaoImpl.insertSongToPlaylist(DBData.PLAY_QUEUE, musics.get(i).getId());
}
dbDaoImpl.closeDB();
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlayQueueLoader method updateQueue.
/**
* 添加歌曲到歌单
*/
public static void updateQueue(Context context, List<Music> musics) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
dbDaoImpl.insertSongs(musics);
dbDaoImpl.clearPlayQueue();
for (int i = 0; i < musics.size(); i++) {
dbDaoImpl.insertSongToPlaylist(DBData.PLAY_QUEUE, musics.get(i).getId());
}
dbDaoImpl.closeDB();
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlaylistLoader method getMusicForPlaylist.
/**
* 扫描歌单歌曲
*/
public static Observable<List<Music>> getMusicForPlaylist(Context context, String playlist_id) {
return Observable.create(subscriber -> {
String sql = "select * from " + DBData.MUSIC_TABLE + " , " + DBData.MTP_TABLE + " where " + DBData.MUSIC_TABLE + ".mid = " + DBData.MTP_TABLE + ".mid " + "and " + DBData.MTP_TABLE + ".pid=" + playlist_id + " ORDER BY music_playlist.date_added DESC";
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
if (playlist_id.equals("1")) {
sql = "SELECT DISTINCT music.mid, music.name, music.filename, music.path, music.lrc_path, music.duration, music.size, music.artist_id, music.artist, music.album, music.album_id, music.cover, music.coverBig, music.coverSmall, music.type, music.is_love, music.is_online, music.prefix, music.years, ( SELECT music_playlist.date_added FROM music_playlist WHERE music_playlist.pid = 0 AND music_playlist.mid = music.mid ORDER BY music_playlist.date_added DESC ) AS time, ( SELECT Count(music_playlist.mid) FROM music_playlist WHERE music_playlist.pid = 0 AND music_playlist.mid = music.mid ) AS num FROM music_playlist, music WHERE music_playlist.mid = music.mid AND music_playlist.pid = 1 ORDER BY time DESC";
} else if (playlist_id.equals("0")) {
sql = "SELECT DISTINCT music.mid, music.name, music.filename, music.path, music.lrc_path, music.duration, music.size, music.artist_id, music.artist, music.album, music.album_id, music.cover, music.coverBig, music.coverSmall, music.type, music.is_love, music.is_online, music.prefix, music.years, ( SELECT music_playlist.date_added FROM music_playlist WHERE music_playlist.pid = 0 AND music_playlist.mid = music.mid ORDER BY music_playlist.date_added DESC ) AS time, ( SELECT Count(music_playlist.mid) FROM music_playlist WHERE music_playlist.pid = 0 AND music_playlist.mid = music.mid ) AS num FROM music_playlist, music WHERE music_playlist.mid = music.mid AND music_playlist.pid = 0 ORDER BY time DESC";
}
Cursor cursor = dbDaoImpl.makeCursor(sql);
List<Music> results = dbDaoImpl.getSongsForCursor(cursor);
dbDaoImpl.closeDB();
subscriber.onNext(results);
subscriber.onComplete();
});
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl 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.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlaylistLoader method addToPlaylist.
/**
* 添加歌曲到歌单
*/
public static boolean addToPlaylist(Context context, String pid, String mid) {
boolean result = false;
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
if (!dbDaoImpl.hasSongPlaylist(pid, mid)) {
dbDaoImpl.insertSongToPlaylist(pid, mid);
result = true;
}
dbDaoImpl.closeDB();
return result;
}