X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;ds=sidebyside;f=src%2Fro%2Fieval%2Funical%2FUtils.java;h=3b53b479a90cce7964136bcbaeb759055f1a6f5c;hb=539deec9aa94ea7b7736b7597d9470a18204d7f8;hp=e8423478c84b112f02aa1195ce560f3633f5283c;hpb=57ca40519eadfe1757e8f21875c1fdf7fe380542;p=unical.git diff --git a/src/ro/ieval/unical/Utils.java b/src/ro/ieval/unical/Utils.java index e842347..3b53b47 100644 --- a/src/ro/ieval/unical/Utils.java +++ b/src/ro/ieval/unical/Utils.java @@ -8,6 +8,7 @@ import android.app.PendingIntent; import android.content.ContentValues; import android.content.Context; import android.content.Intent; +import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.view.View; @@ -40,10 +41,25 @@ final class Utils { public static void deleteAlarm(final Application application, final long time) throws SQLException{ final SQLiteDatabase db = application.alarmOpenHelper.getWritableDatabase(); - db.delete(AlarmOpenHelper.TABLE, AlarmOpenHelper.TIME + " = " + time, new String[]{}); + db.delete(AlarmOpenHelper.TABLE, AlarmOpenHelper.TIME + " = " + time, new String[0]); unsetAlarm(application, time); } + public static Long[] getAlarmsByEvent(final Application application, final long eventId) throws SQLException{ + final SQLiteDatabase db = application.alarmOpenHelper.getWritableDatabase(); + db.delete(AlarmOpenHelper.TABLE, AlarmOpenHelper.TIME + " < " + System.currentTimeMillis(), new String[0]); + final Cursor cursor = db.query(AlarmOpenHelper.TABLE, new String[]{AlarmOpenHelper.TIME}, AlarmOpenHelper.EVENT + " = " + eventId, new String[0], null, null, null); + if(cursor.moveToFirst()){ + final Long[] ret = new Long[cursor.getCount()]; + for(int i=0;i