Search in sources :

Example 6 with DBDaoImpl

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

Example 7 with DBDaoImpl

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

Example 8 with DBDaoImpl

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

Example 9 with DBDaoImpl

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

Example 10 with DBDaoImpl

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

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