use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class SongLoader method removeSong.
/**
* 删除歌曲
*/
public static void removeSong(Context context, Music music) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
dbDaoImpl.deleteSongForId(music.getId());
dbDaoImpl.closeDB();
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class SongLoader method getSongsForDB.
public static List<Music> getSongsForDB(Context context) {
DBDaoImpl dbDaoImpl = new DBDaoImpl(context);
String sql = "select * from " + DBData.MUSIC_TABLE;
Cursor cursor = dbDaoImpl.makeCursor(sql);
return dbDaoImpl.getSongsForCursor(cursor);
}
use of com.cyl.musiclake.data.source.db.DBDaoImpl in project MusicLake by caiyonglong.
the class SongLoader method getSongsForDB.
/**
* Android 扫描获取到的数据
*
* @param context
* @param cursor
* @return
*/
public static Observable<List<Music>> getSongsForDB(Context context, final Cursor cursor) {
DBDaoImpl dbDao = new DBDaoImpl(context);
if ((cursor != null) && (cursor.moveToFirst())) {
do {
long id = cursor.getLong(0);
String title = cursor.getString(1);
String artist = cursor.getString(2);
String album = cursor.getString(3);
int duration = cursor.getInt(4);
int trackNumber = cursor.getInt(5);
String artistId = cursor.getString(6);
long albumId = cursor.getLong(7);
String path = cursor.getString(8);
String coverUri = CoverLoader.getInstance().getCoverUri(context, albumId);
Music music = dbDao.getMusicInfo(id + "");
if (music != null) {
if (coverUri != null) {
music.setCoverUri(coverUri);
updateMusic(dbDao, music);
}
} else {
music = new Music(id, albumId, artistId, title, artist, album, duration, trackNumber, path);
dbDao.insertSong(music);
}
} while (cursor.moveToNext());
}
if (cursor != null) {
cursor.close();
}
String sql = "select * from " + DBData.MUSIC_TABLE + " where " + DBData.IS_ONLINE + "=0";
Cursor mCursor = dbDao.makeCursor(sql);
return getSongsForCursor(context, mCursor);
}