Search in sources :

Example 1 with DBDaoImpl

use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.

the class PlayHistoryLoader method getPlayHistory.

// /**
// * 添加歌曲到歌单
// */
// private static void resetQueue(Context context, List<Music> musics) {
// DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
// dbDaoImpl.insertSongs(musics);
// for (int i = 0; i < musics.size(); i++) {
// dbDaoImpl.insertSongToPlaylist(DBData.PLAY_QUEUE, musics.get(i).getId());
// }
// dbDaoImpl.closeDB();
// }
/**
 * 获取播放队列
 */
public static Observable<List<Music>> getPlayHistory(Context context) {
    return Observable.create(subscriber -> {
        String sql = "select *,count(name) as num,max(music_playlist.date_added) as time " + "from music inner join music_playlist where music.mid = music_playlist.mid  and music_playlist.pid=1 " + "GROUP BY music.name ORDER BY time DESC";
        try {
            DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
            Cursor cursor = dbDaoImpl.makeCursor(sql);
            List<Music> results = dbDaoImpl.getSongsForCursor(cursor);
            dbDaoImpl.closeDB();
            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) Cursor(android.database.Cursor)

Example 2 with DBDaoImpl

use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.

the class PlayHistoryLoader method clearLove.

/**
 * 清除歌单
 */
public static void clearLove(Context context) {
    DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
    dbDaoImpl.clearHistory();
    dbDaoImpl.closeDB();
}
Also used : DBDaoImpl(com.cyl.musiclake.data.source.db.DBDaoImpl)

Example 3 with DBDaoImpl

use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.

the class PlayQueueLoader method getPlayQueue.

// /**
// * 添加歌曲到歌单
// */
// private static void resetQueue(Context context, List<Music> musics) {
// DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
// dbDaoImpl.insertSongs(musics);
// for (int i = 0; i < musics.size(); i++) {
// dbDaoImpl.insertSongToPlaylist(DBData.PLAY_QUEUE, musics.get(i).getId());
// }
// dbDaoImpl.closeDB();
// }
/**
 * 获取播放队列
 */
public static List<Music> getPlayQueue(Context context) {
    DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
    String sql = "select * from music inner join music_playlist " + "where music.mid = music_playlist.mid " + "and music_playlist.pid=0 ORDER BY music_playlist.date_added DESC";
    Cursor cursor = dbDaoImpl.makeCursor(sql);
    List<Music> results = dbDaoImpl.getSongsForCursor(cursor);
    dbDaoImpl.closeDB();
    return results;
}
Also used : DBDaoImpl(com.cyl.musiclake.data.source.db.DBDaoImpl) Music(com.cyl.musiclake.bean.Music) Cursor(android.database.Cursor)

Example 4 with DBDaoImpl

use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.

the class PlayQueueLoader method clearQueue.

/**
 * 清除歌单
 */
public static void clearQueue(Context context) {
    DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
    dbDaoImpl.clearPlayQueue();
    dbDaoImpl.closeDB();
}
Also used : DBDaoImpl(com.cyl.musiclake.data.source.db.DBDaoImpl)

Example 5 with DBDaoImpl

use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.

the class PlaylistLoader method createPlaylist.

/**
 * 新增歌单
 *
 * @param context
 * @param name
 * @return
 */
public static long createPlaylist(Context context, String name) {
    long pid = -1;
    DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
    pid = dbDaoImpl.addPlayList(name);
    dbDaoImpl.closeDB();
    return pid;
}
Also used : DBDaoImpl(com.cyl.musiclake.data.source.db.DBDaoImpl)

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