AlertDB being re-commited to Git

This commit is contained in:
agk512
2013-11-21 14:03:23 -05:00
parent c6e0587f1d
commit a06aa20207
7 changed files with 342 additions and 223 deletions

View File

@ -1,39 +1,61 @@
package com.uncc.gameday.alerts;
import java.util.Date;
import java.util.List;
import android.app.IntentService;
import android.content.Intent;
import android.content.SharedPreferences;
// TODO: Auto-generated Javadoc
/**
* The Class AlertService.
*/
public class AlertService extends IntentService {
/** The Constant name. */
private static final String name = "AlertService";
SharedPreferences prefs = null;
/**
* Instantiates a new alert service.
*/
public AlertService() {
super(name);
}
/* (non-Javadoc)
* @see android.app.IntentService#onHandleIntent(android.content.Intent)
*/
@Override
protected void onHandleIntent(Intent intent) {
// Go fetch all the alerts!
new AlertFetcher().fetchAlerts(this);
List<Alert> alerts = new AlertDB().fetchUnread();
//new AlertFetcher().fetchAlerts(this);
//if first application run, create and store
//timed alerts into database
prefs = getSharedPreferences("com.uncc.gameday", MODE_PRIVATE);
if(prefs.getBoolean("firstrun", true)){
onFirstRun();
prefs.edit().putBoolean("firstrun", false).commit();
}
List<Alert> alerts = new AlertDB(this).fetchAll();
// And then display all of them!
for (Alert a: alerts) {
a.displayNotification(this);
}
}
//Creates timed alerts and adds them to AlertDB
//Only runs on first application startup
protected void onFirstRun()
{
@SuppressWarnings("deprecation")
Alert a1 = new Alert(new Date(2003, 10, 10), "This is a test1", 0, AlertType.getValue(AlertType.ORGANIZATION));
@SuppressWarnings("deprecation")
Alert b = new Alert(new Date(2003, 10, 10), "This is a test2", 0, AlertType.getValue(AlertType.GAMEDAY));
@SuppressWarnings("deprecation")
Alert c = new Alert(new Date(2003, 10, 10), "This is a test3", 0, AlertType.getValue(AlertType.TIMED));
AlertDB db = new AlertDB(this);
db.persist(a1);
db.persist(b);
db.persist(c);
}
}