use MediaUtils.TYPE_SONG
This commit is contained in:
parent
6a97ef8015
commit
37e26c87be
@ -26,11 +26,6 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class PlayCountsHelper extends SQLiteOpenHelper {
|
public class PlayCountsHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
/**
|
|
||||||
* Value of 'type' field
|
|
||||||
*/
|
|
||||||
private static final int TYPE_SONG = 1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL constants and CREATE TABLE statements used by
|
* SQL constants and CREATE TABLE statements used by
|
||||||
* this java class
|
* this java class
|
||||||
@ -68,12 +63,11 @@ public class PlayCountsHelper extends SQLiteOpenHelper {
|
|||||||
* Counts this song object as 'played'
|
* Counts this song object as 'played'
|
||||||
*/
|
*/
|
||||||
public void countSong(Song song) {
|
public void countSong(Song song) {
|
||||||
int type = TYPE_SONG;
|
|
||||||
long id = Song.getId(song);
|
long id = Song.getId(song);
|
||||||
|
|
||||||
SQLiteDatabase dbh = this.getWritableDatabase();
|
SQLiteDatabase dbh = this.getWritableDatabase();
|
||||||
dbh.execSQL("INSERT OR IGNORE INTO "+TABLE_PLAYCOUNTS+" (type, type_id, playcount) VALUES ("+type+", "+id+", 0);"); // Creates row if not exists
|
dbh.execSQL("INSERT OR IGNORE INTO "+TABLE_PLAYCOUNTS+" (type, type_id, playcount) VALUES ("+MediaUtils.TYPE_SONG+", "+id+", 0);"); // Creates row if not exists
|
||||||
dbh.execSQL("UPDATE "+TABLE_PLAYCOUNTS+" SET playcount=playcount+1 WHERE type="+type+" AND type_id="+id+";");
|
dbh.execSQL("UPDATE "+TABLE_PLAYCOUNTS+" SET playcount=playcount+1 WHERE type="+MediaUtils.TYPE_SONG+" AND type_id="+id+";");
|
||||||
dbh.close();
|
dbh.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +77,7 @@ public class PlayCountsHelper extends SQLiteOpenHelper {
|
|||||||
public ArrayList<Long> getTopSongs() {
|
public ArrayList<Long> getTopSongs() {
|
||||||
ArrayList<Long> payload = new ArrayList<Long>();
|
ArrayList<Long> payload = new ArrayList<Long>();
|
||||||
SQLiteDatabase dbh = this.getReadableDatabase();
|
SQLiteDatabase dbh = this.getReadableDatabase();
|
||||||
Cursor c = dbh.rawQuery("SELECT type_id FROM "+TABLE_PLAYCOUNTS+" WHERE TYPE="+TYPE_SONG+" ORDER BY playcount DESC limit 4096", null);
|
Cursor c = dbh.rawQuery("SELECT type_id FROM "+TABLE_PLAYCOUNTS+" WHERE type="+MediaUtils.TYPE_SONG+" ORDER BY playcount DESC limit 4096", null);
|
||||||
|
|
||||||
while (c.moveToNext()) {
|
while (c.moveToNext()) {
|
||||||
payload.add(c.getLong(0));
|
payload.add(c.getLong(0));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user