Search in sources :

Example 16 with DBDaoImpl

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();
    });
}
Also used : DBDaoImpl(com.cyl.musiclake.data.source.db.DBDaoImpl) Music(com.cyl.musiclake.bean.Music)

Example 17 with DBDaoImpl

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);
        }
    });
}
Also used : DBDaoImpl(com.cyl.musiclake.data.source.db.DBDaoImpl) Album(com.cyl.musiclake.bean.Album)

Example 18 with DBDaoImpl

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);
}
Also used : DBDaoImpl(com.cyl.musiclake.data.source.db.DBDaoImpl) Cursor(android.database.Cursor)

Example 19 with DBDaoImpl

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);
}
Also used : DBDaoImpl(com.cyl.musiclake.data.source.db.DBDaoImpl) Cursor(android.database.Cursor)

Example 20 with DBDaoImpl

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);
        }
    });
}
Also used : DBDaoImpl(com.cyl.musiclake.data.source.db.DBDaoImpl) Album(com.cyl.musiclake.bean.Album) Cursor(android.database.Cursor)

Aggregations

DBDaoImpl (com.cyl.musiclake.data.source.db.DBDaoImpl)33 Cursor (android.database.Cursor)13 Music (com.cyl.musiclake.bean.Music)9 Album (com.cyl.musiclake.bean.Album)2 Artist (com.cyl.musiclake.bean.Artist)1 Playlist (com.cyl.musiclake.bean.Playlist)1 ArrayList (java.util.ArrayList)1