use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class ArtistLoader method getAllArtists.
/**
* 获取所有艺术家
*
* @param context
* @return
*/
public static Observable<List<Artist>> getAllArtists(Context context) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
String sql = "SELECT music.artist_id,music.artist,count(music.name) as num FROM music where music.is_online=0 GROUP BY music.artist";
Cursor cursor = dbDaoImpl.makeCursor(sql);
return getArtistsForDB(context, cursor);
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class ArtistLoader method getArtistsForDB.
private static Observable<List<Artist>> getArtistsForDB(Context context, Cursor cursor) {
return Observable.create(subscriber -> {
try {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
List<Artist> results = dbDaoImpl.getArtistsForCursor(cursor);
dbDaoImpl.closeDB();
subscriber.onNext(results);
subscriber.onComplete();
} catch (Exception e) {
e.printStackTrace();
subscriber.onError(e);
}
});
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlayHistoryLoader method clearPlayHistory.
/**
* 清除歌单
*/
public static void clearPlayHistory(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 PlayHistoryLoader method updatePlayHistory.
/**
* 添加歌曲到歌单
*/
public static void updatePlayHistory(Context context, List<Music> musics) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
dbDaoImpl.clearPlayQueue();
for (int i = 0; i < musics.size(); i++) {
dbDaoImpl.insertSongToPlaylist(DBData.HISTORY, musics.get(i).getId());
}
dbDaoImpl.closeDB();
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class PlayHistoryLoader method addSongToHistory.
/**
* 添加歌曲到歌单
*/
public static void addSongToHistory(Context context, Music music) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
dbDaoImpl.insertSong(music);
dbDaoImpl.insertSongToPlaylist(DBData.HISTORY, music.getId());
dbDaoImpl.closeDB();
}