use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlayHistoryLoader method getPlayHistory.
// /**
// * 添加歌曲到歌单
// */
// private static void resetQueue(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();
// }
/**
* 获取播放队列
*/
public static Observable<List<Music>> getPlayHistory(Context context) {
return Observable.create(subscriber -> {
String sql = "select *,count(name) as num,max(music_playlist.date_added) as time " + "from music inner join music_playlist where music.mid = music_playlist.mid and music_playlist.pid=1 " + "GROUP BY music.name ORDER BY time DESC";
try {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
Cursor cursor = dbDaoImpl.makeCursor(sql);
List<Music> results = dbDaoImpl.getSongsForCursor(cursor);
dbDaoImpl.closeDB();
subscriber.onNext(results);
subscriber.onComplete();
} catch (Exception e) {
subscriber.onError(e);
}
});
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlayHistoryLoader method clearLove.
/**
* 清除歌单
*/
public static void clearLove(Context context) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
dbDaoImpl.clearHistory();
dbDaoImpl.closeDB();
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlayQueueLoader method getPlayQueue.
// /**
// * 添加歌曲到歌单
// */
// private static void resetQueue(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();
// }
/**
* 获取播放队列
*/
public static List<Music> getPlayQueue(Context context) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
String sql = "select * from music inner join music_playlist " + "where music.mid = music_playlist.mid " + "and music_playlist.pid=0 ORDER BY music_playlist.date_added DESC";
Cursor cursor = dbDaoImpl.makeCursor(sql);
List<Music> results = dbDaoImpl.getSongsForCursor(cursor);
dbDaoImpl.closeDB();
return results;
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlayQueueLoader method clearQueue.
/**
* 清除歌单
*/
public static void clearQueue(Context context) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
dbDaoImpl.clearPlayQueue();
dbDaoImpl.closeDB();
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlaylistLoader method createPlaylist.
/**
* 新增歌单
*
* @param context
* @param name
* @return
*/
public static long createPlaylist(Context context, String name) {
long pid = -1;
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
pid = dbDaoImpl.addPlayList(name);
dbDaoImpl.closeDB();
return pid;
}