Further Alert cleanup >AGK

This commit is contained in:
agk512 2013-12-02 03:36:25 -05:00
parent ca881b99bd
commit 21eb59dc0a

View File

@ -1,6 +1,6 @@
package com.uncc.gameday.alerts; package com.uncc.gameday.alerts;
import java.util.Date; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import android.app.IntentService; import android.app.IntentService;
import android.content.Intent; import android.content.Intent;
@ -32,6 +32,8 @@ public class AlertService extends IntentService {
*/ */
@Override @Override
protected void onHandleIntent(Intent intent) { protected void onHandleIntent(Intent intent) {
// Go fetch all the alerts! // Go fetch all the alerts!
new AlertFetcher().fetchAlerts(this); new AlertFetcher().fetchAlerts(this);
@ -43,14 +45,12 @@ public class AlertService extends IntentService {
prefs.edit().putBoolean("firstrun", false).commit(); prefs.edit().putBoolean("firstrun", false).commit();
} }
List<Alert> alerts = new AlertDB(this).fetchAll(); List<Alert> alerts = new AlertDB(this).fetchUnread();
// And then display all of them! // And then display all of them!
for (Alert a: alerts) { for (Alert a: alerts) {
a.displayNotification(this); a.displayNotification(this);
} }
} }
/** /**
@ -59,17 +59,36 @@ public class AlertService extends IntentService {
*/ */
protected void onFirstRun() protected void onFirstRun()
{ {
@SuppressWarnings("deprecation") //Sets date as (YYYY, MM, DD)
Alert a1 = new Alert(new Date(2003, 10, 10), "This is a test1", 0, AlertType.getValue(AlertType.ORGANIZATION)); //month runs from 0-11
@SuppressWarnings("deprecation") //10 = November
Alert b = new Alert(new Date(2003, 10, 10), "This is a test2", 0, AlertType.getValue(AlertType.GAMEDAY)); //11 = December (max)
@SuppressWarnings("deprecation") GregorianCalendar cal = new GregorianCalendar(2013, 10, 30);
Alert c = new Alert(new Date(2003, 10, 10), "This is a test3", 0, AlertType.getValue(AlertType.TIMED)); long date1 = cal.getTimeInMillis();
GregorianCalendar cal2 = new GregorianCalendar(2013, 11, 3);
long date2 = cal2.getTimeInMillis();
Alert a1 = new Alert(date1, "UNCC GAME DAY on Saturday, 12/7/13. UNCC VS. NC State", 0, AlertType.getValue(AlertType.TIMED));
Alert a2 = new Alert(date1, "Don't forget to purchase your ticket! UNCC Gameday 12/7/13 @ 1pm", 0, AlertType.getValue(AlertType.TIMED));
Alert a3 = new Alert(date1, "Don't forget to purchase your parking pass! Deadline is 12/6/13 by 5pm", 0, AlertType.getValue(AlertType.TIMED));
Alert b1 = new Alert(date2, "Will you be there? UNCC GAME DAY Saturday, 12/7/13", 0, AlertType.getValue(AlertType.TIMED));
Alert b2 = new Alert(date2, "TOWING ENFORCED: DON'T FORGET TO MOVE YOUR CAR OFF GAMEDAY PARKING LOTS", 0, AlertType.getValue(AlertType.TIMED));
AlertDB db = new AlertDB(this); AlertDB db = new AlertDB(this);
db.persist(a1); db.persist(a1);
db.persist(b); db.persist(a2);
db.persist(c); db.persist(a3);
db.persist(b1);
db.persist(b2);
} }
} }