use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlaylistLoader method removeSong.
/**
* 移除歌曲到歌单
*/
public static void removeSong(Context context, String pid, String mid) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
dbDaoImpl.removeSongPlaylist(pid, mid);
dbDaoImpl.closeDB();
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlaylistLoader method deletePlaylist.
/**
* 删除歌单
*/
public static void deletePlaylist(Context context, String playlist_id) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
dbDaoImpl.deletePlaylist(playlist_id);
dbDaoImpl.closeDB();
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class SongLoader method insertSongs.
/**
* 本地歌曲
* 添加歌曲
*/
private static void insertSongs(Context context, List<Music> musics) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
dbDaoImpl.insertSongs(musics);
dbDaoImpl.closeDB();
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class SongLoader method getMusicInfo.
public static Observable<Music> getMusicInfo(final Context context, Music music) {
return Observable.create(subscriber -> {
try {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
String sql = "select * from " + DBData.MUSIC_TABLE + " where " + DBData.MUSIC_ID + " = '" + music.getId() + "'";
Cursor cursor = dbDaoImpl.makeCursor(sql);
List<Music> results = dbDaoImpl.getSongsForCursor(cursor);
if (results.size() != 0) {
subscriber.onNext(results.get(0));
} else {
subscriber.onNext(music);
}
dbDaoImpl.closeDB();
subscriber.onComplete();
} catch (Exception e) {
subscriber.onError(e);
}
});
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class SongLoader method getSongsForCursor.
/**
* cursor 获取音乐集合
*
* @param context
* @param cursor
* @return
*/
private static Observable<List<Music>> getSongsForCursor(Context context, final Cursor cursor) {
return Observable.create(subscriber -> {
try {
DBDaoImpl dbDao = new DBDaoImpl(context);
List<Music> results = dbDao.getSongsForCursor(cursor);
cursor.close();
subscriber.onNext(results);
subscriber.onComplete();
} catch (Exception e) {
subscriber.onError(e);
}
});
}