use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class ArtistSongLoader method getSongsForArtistDB.
public static Observable<List<Music>> getSongsForArtistDB(final Context context, final Cursor cursor) {
return Observable.create(subscriber -> {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
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 AlbumLoader method getAlbumFormDB.
private static Observable<List<Album>> getAlbumFormDB(Context context, Cursor cursor) {
return Observable.create(subscriber -> {
try {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
List<Album> results = dbDaoImpl.getAlbumsForCursor(cursor);
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 AlbumLoader method getAllAlbums.
/**
* 获取所有专辑
*
* @param context
* @return
*/
public static Observable<List<Album>> getAllAlbums(Context context) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
String sql = "SELECT music.album_id,music.album,music.artist_id,music.artist,count(music.name) as num FROM music WHERE music.is_online=0 GROUP BY music.album";
Cursor cursor = dbDaoImpl.makeCursor(sql);
return getAlbumFormDB(context, cursor);
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class AlbumSongLoader method getSongsForAlbum.
/**
* 获取专辑所有歌曲
*
* @param context
* @return
*/
public static Observable<List<Music>> getSongsForAlbum(Context context, String albumName) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
String sql = "SELECT * FROM music where music.is_online=0 and album = '" + albumName + "'";
Cursor cursor = dbDaoImpl.makeCursor(sql);
return getSongsForAlbumDB(context, cursor);
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class ArtistAlbumLoader method getAlbumsForArtist.
public static Observable<List<Album>> getAlbumsForArtist(final Context context, final String artistName) {
return Observable.create(subscriber -> {
try {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
String sql = "SELECT * FROM music WHERE music.artist='" + artistName + "' GROUP BY album";
Cursor cursor = dbDaoImpl.makeCursor(sql);
List<Album> results = dbDaoImpl.getAlbumsForCursor(cursor);
dbDaoImpl.closeDB();
subscriber.onNext(results);
subscriber.onComplete();
} catch (Exception e) {
e.printStackTrace();
subscriber.onError(e);
}
});
}