use of android.content.ContentValues in project remusic by aa112901.
the class DownFileStore method update.
public synchronized void update(DownloadDBEntity entity) {
final SQLiteDatabase database = mMusicDatabase.getWritableDatabase();
database.beginTransaction();
try {
ContentValues values = new ContentValues(6);
values.put(DownFileStoreColumns.TOOL_SIZE, entity.getTotalSize());
values.put(DownFileStoreColumns.FILE_LENGTH, entity.getCompletedSize());
values.put(DownFileStoreColumns.URL, entity.getUrl());
values.put(DownFileStoreColumns.DIR, entity.getSaveDirPath());
values.put(DownFileStoreColumns.FILE_NAME, entity.getFileName());
values.put(DownFileStoreColumns.DOWNSTATUS, entity.getDownloadStatus());
database.update(DownFileStoreColumns.NAME, values, DownFileStoreColumns.ID + " = ?", new String[] { entity.getDownloadId() });
database.setTransactionSuccessful();
} finally {
database.endTransaction();
}
}
use of android.content.ContentValues in project remusic by aa112901.
the class MusicPlaybackState method Insert.
public synchronized void Insert(MusicTrack track) {
final SQLiteDatabase database = mMusicDatabase.getWritableDatabase();
database.beginTransaction();
try {
ContentValues values = new ContentValues(2);
values.put(PlaybackQueueColumns.TRACK_ID, track.mId);
values.put(PlaybackQueueColumns.SOURCE_POSITION, track.mSourcePosition);
database.insert(PlaybackQueueColumns.NAME, null, values);
database.setTransactionSuccessful();
} finally {
database.endTransaction();
}
}
use of android.content.ContentValues in project remusic by aa112901.
the class PlaylistsManager method insertLists.
public synchronized void insertLists(Context context, long playlistid, ArrayList<MusicInfo> musicInfos) {
final SQLiteDatabase database = mMusicDatabase.getWritableDatabase();
database.beginTransaction();
int len = musicInfos.size();
try {
for (int i = 0; i < len; i++) {
MusicInfo info = musicInfos.get(i);
ContentValues values = new ContentValues(11);
values.put(PlaylistsColumns.PLAYLIST_ID, playlistid);
values.put(PlaylistsColumns.TRACK_ID, info.songId);
values.put(PlaylistsColumns.TRACK_ORDER, getPlaylist(playlistid).size());
values.put(PlaylistsColumns.TRACK_NAME, info.musicName);
values.put(PlaylistsColumns.ALBUM_ID, info.albumId);
values.put(PlaylistsColumns.ALBUM_NAME, info.albumName);
values.put(PlaylistsColumns.ALBUM_ART, info.albumData);
values.put(PlaylistsColumns.ARTIST_NAME, info.artist);
values.put(PlaylistsColumns.ARTIST_ID, info.artistId);
values.put(PlaylistsColumns.PATH, info.data);
values.put(PlaylistsColumns.IS_LOCAL, info.islocal);
database.insertWithOnConflict(PlaylistsColumns.NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
}
database.setTransactionSuccessful();
} catch (Exception e) {
e.printStackTrace();
} finally {
database.endTransaction();
}
PlaylistInfo playlistInfo = PlaylistInfo.getInstance(context);
String albumart = null;
for (int i = len - 1; i >= 0; i--) {
MusicInfo info = musicInfos.get(i);
albumart = info.albumData;
if (info.islocal) {
String art = MusicUtils.getAlbumdata(MainApplication.context, info.songId);
if (art != null) {
break;
} else {
albumart = null;
}
} else if (!albumart.isEmpty()) {
break;
}
}
if (albumart != null) {
playlistInfo.update(playlistid, getPlaylist(playlistid).size(), albumart);
} else {
playlistInfo.update(playlistid, getPlaylist(playlistid).size());
}
}
use of android.content.ContentValues in project remusic by aa112901.
the class MusicPlayer method createPlaylist.
public static final long createPlaylist(final Context context, final String name) {
if (name != null && name.length() > 0) {
final ContentResolver resolver = context.getContentResolver();
final String[] projection = new String[] { MediaStore.Audio.PlaylistsColumns.NAME };
final String selection = MediaStore.Audio.PlaylistsColumns.NAME + " = '" + name + "'";
Cursor cursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, projection, selection, null, null);
if (cursor.getCount() <= 0) {
final ContentValues values = new ContentValues(1);
values.put(MediaStore.Audio.PlaylistsColumns.NAME, name);
final Uri uri = resolver.insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, values);
return Long.parseLong(uri.getLastPathSegment());
}
if (cursor != null) {
cursor.close();
cursor = null;
}
return -1;
}
return -1;
}
use of android.content.ContentValues in project remusic by aa112901.
the class PlaylistsManager method update.
public synchronized void update(long playlistid, long[] ids, int[] order) {
final SQLiteDatabase database = mMusicDatabase.getWritableDatabase();
database.beginTransaction();
try {
for (int i = 0; i < order.length; i++) {
ContentValues values = new ContentValues(1);
values.put(PlaylistsColumns.TRACK_ORDER, order[i]);
database.update(PlaylistsColumns.NAME, values, PlaylistsColumns.PLAYLIST_ID + " = ?" + " AND " + PlaylistsColumns.TRACK_ID + " = ?", new String[] { playlistid + "", ids[i] + "" });
}
database.setTransactionSuccessful();
} finally {
database.endTransaction();
}
}
Aggregations