From 37e26c87be484fd8c042ba3aa9b20b501eddbd96 Mon Sep 17 00:00:00 2001 From: Adrian Ulrich Date: Wed, 16 Apr 2014 21:59:40 +0200 Subject: [PATCH] use MediaUtils.TYPE_SONG --- .../android/vanilla/PlayCountsHelper.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/ch/blinkenlights/android/vanilla/PlayCountsHelper.java b/src/ch/blinkenlights/android/vanilla/PlayCountsHelper.java index f2715d4e..10b6e251 100644 --- a/src/ch/blinkenlights/android/vanilla/PlayCountsHelper.java +++ b/src/ch/blinkenlights/android/vanilla/PlayCountsHelper.java @@ -26,11 +26,6 @@ import java.util.ArrayList; public class PlayCountsHelper extends SQLiteOpenHelper { - /** - * Value of 'type' field - */ - private static final int TYPE_SONG = 1; - /** * SQL constants and CREATE TABLE statements used by * this java class @@ -68,12 +63,11 @@ public class PlayCountsHelper extends SQLiteOpenHelper { * Counts this song object as 'played' */ public void countSong(Song song) { - int type = TYPE_SONG; long id = Song.getId(song); 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("UPDATE "+TABLE_PLAYCOUNTS+" SET playcount=playcount+1 WHERE type="+type+" AND type_id="+id+";"); + 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="+MediaUtils.TYPE_SONG+" AND type_id="+id+";"); dbh.close(); } @@ -83,7 +77,7 @@ public class PlayCountsHelper extends SQLiteOpenHelper { public ArrayList getTopSongs() { ArrayList payload = new ArrayList(); 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()) { payload.add(c.getLong(0));