From d03ce1427d830fe3f5227d8eb8d887ac9aa296c7 Mon Sep 17 00:00:00 2001 From: agk512 Date: Sat, 7 Dec 2013 01:17:45 -0500 Subject: [PATCH] Some search changes, plus Auto alert test Added alerts every 30 minutes starting at 9am to 930pm on 12-7-13. Will have on phone today to ensure that automated alerts show properly. Having no luck with search function, will try again tomorrow. --- bin/AndroidManifest.xml | 1 + res/layout/activity_search_rsvp.xml | 17 ++- src/com/uncc/gameday/activities/Search.java | 107 ++++++++++-------- src/com/uncc/gameday/alerts/AlertService.java | 59 ++++++++++ 4 files changed, 132 insertions(+), 52 deletions(-) diff --git a/bin/AndroidManifest.xml b/bin/AndroidManifest.xml index 0fdca33..a377483 100644 --- a/bin/AndroidManifest.xml +++ b/bin/AndroidManifest.xml @@ -40,6 +40,7 @@ + diff --git a/res/layout/activity_search_rsvp.xml b/res/layout/activity_search_rsvp.xml index f1fef79..8d07cf2 100644 --- a/res/layout/activity_search_rsvp.xml +++ b/res/layout/activity_search_rsvp.xml @@ -26,14 +26,23 @@ + android:textStyle="italic" /> + + + + \ No newline at end of file diff --git a/src/com/uncc/gameday/activities/Search.java b/src/com/uncc/gameday/activities/Search.java index b03ce8f..efc7634 100644 --- a/src/com/uncc/gameday/activities/Search.java +++ b/src/com/uncc/gameday/activities/Search.java @@ -8,6 +8,7 @@ import retrofit.RetrofitError; import android.content.Context; import android.os.Bundle; +import android.os.Looper; import android.util.Log; import android.widget.ArrayAdapter; import android.widget.ListView; @@ -17,53 +18,63 @@ import com.uncc.gameday.registration.Attendee; import com.uncc.gameday.registration.RegistrationClient; public class Search extends MenuActivity { - - List rsvpList; - boolean listFetched = false; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_search_rsvp); - new fetchAttendeesThread(this).start(); - } - - private class fetchAttendeesThread extends Thread { - Context c; - public fetchAttendeesThread(Context c) { - this.c = c; - } - - public void run() { - try { - RegistrationClient client = new RegistrationClient(this.c); - rsvpList = client.listAttendees(); - listFetched = true; - } catch (RetrofitError e) { - Toast.makeText(c, R.string.internet_down_error, Toast.LENGTH_SHORT).show(); - Log.e("Search", e.getLocalizedMessage()); - } - - //sorts RSVPList alphabetically by last name - Collections.sort(rsvpList, new Comparator() { - @Override - public int compare(Attendee a1, Attendee a2) { - String compareName = a1.getLastName(); - String thisName = a2.getLastName(); - return compareName.compareTo(thisName); - } - }); + + List rsvpList; + boolean listFetched = false; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_search_rsvp); + new fetchAttendeesThread(this).start(); + } + + private class fetchAttendeesThread extends Thread { + Context c; + public fetchAttendeesThread(Context c) { + this.c = c; + } + + public void run() { + + if (Looper.myLooper() == null) { + Looper.prepare(); + } + try { + RegistrationClient client = new RegistrationClient(this.c); + rsvpList = client.listAttendees(); + listFetched = true; + } catch (RetrofitError e) { + Toast.makeText(c, R.string.internet_down_error, Toast.LENGTH_SHORT).show(); + Log.e("Search", e.getLocalizedMessage()); + } + + //sorts RSVPList alphabetically by last name + if(rsvpList != null) + { + Collections.sort(rsvpList, new Comparator() { + @Override + public int compare(Attendee a1, Attendee a2) { + String compareName = a1.getLastName(); + String thisName = a2.getLastName(); + return compareName.compareTo(thisName); + } + }); + } + + runOnUiThread(new Runnable() { + @Override + public void run() { + ListView listView = (ListView)findViewById(R.id.RSVPListView); + ArrayAdapter adapter = + new ArrayAdapter(c,android.R.layout.simple_list_item_1, rsvpList); + listView.setAdapter(adapter); + } + }); + + - //function to display RSVPList onto listView - runOnUiThread(new Runnable() { - @Override - public void run() { - ListView listView = (ListView)findViewById(R.id.searchView1); - ArrayAdapter adapter = - new ArrayAdapter(c,android.R.layout.simple_list_item_1, rsvpList); - listView.setAdapter(adapter); - } - }); - } -} + + } } +} \ No newline at end of file diff --git a/src/com/uncc/gameday/alerts/AlertService.java b/src/com/uncc/gameday/alerts/AlertService.java index ea84d46..a417571 100644 --- a/src/com/uncc/gameday/alerts/AlertService.java +++ b/src/com/uncc/gameday/alerts/AlertService.java @@ -80,6 +80,38 @@ public class AlertService extends IntentService { Alert b2 = new Alert(date2, "TOWING ENFORCED: DON'T FORGET TO MOVE YOUR CAR OFF GAMEDAY PARKING LOTS", 0, AlertType.getValue(AlertType.TIMED)); + + + //VERY dirty code - just for the sake of testing + //alert every 30 minutes staring at 9am to 930pm on 12-7-13 + Alert c1 = new Alert(new GregorianCalendar(2013, 11, 7, 9, 0).getTimeInMillis(), "Auto Alert 9:00a", 0, AlertType.getValue(AlertType.TIMED)); + Alert c2 = new Alert(new GregorianCalendar(2013, 11, 7, 9, 30).getTimeInMillis(), "Auto Alert 9:30a", 0, AlertType.getValue(AlertType.TIMED)); + Alert c3 = new Alert(new GregorianCalendar(2013, 11, 7, 10, 0).getTimeInMillis(), "Auto Alert 10:00a", 0, AlertType.getValue(AlertType.TIMED)); + Alert c4 = new Alert(new GregorianCalendar(2013, 11, 7, 10, 30).getTimeInMillis(), "Auto Alert 10:30a", 0, AlertType.getValue(AlertType.TIMED)); + Alert c5 = new Alert(new GregorianCalendar(2013, 11, 7, 11, 0).getTimeInMillis(), "Auto Alert 11:00a", 0, AlertType.getValue(AlertType.TIMED)); + Alert c6 = new Alert(new GregorianCalendar(2013, 11, 7, 11, 30).getTimeInMillis(), "Auto Alert 11:30a", 0, AlertType.getValue(AlertType.TIMED)); + Alert c7 = new Alert(new GregorianCalendar(2013, 11, 7, 12, 0).getTimeInMillis(), "Auto Alert 12:00p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c8 = new Alert(new GregorianCalendar(2013, 11, 7, 12, 30).getTimeInMillis(), "Auto Alert 12:30p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c9 = new Alert(new GregorianCalendar(2013, 11, 7, 13, 0).getTimeInMillis(), "Auto Alert 1:00p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c10 = new Alert(new GregorianCalendar(2013, 11, 7, 13, 30).getTimeInMillis(), "Auto Alert 1:30p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c11 = new Alert(new GregorianCalendar(2013, 11, 7, 14, 0).getTimeInMillis(), "Auto Alert 2:00p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c12= new Alert(new GregorianCalendar(2013, 11, 7, 14, 30).getTimeInMillis(), "Auto Alert 2:30p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c13 = new Alert(new GregorianCalendar(2013, 11, 7, 15, 0).getTimeInMillis(), "Auto Alert 3:00p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c14 = new Alert(new GregorianCalendar(2013, 11, 7, 15, 30).getTimeInMillis(), "Auto Alert 3:30p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c15 = new Alert(new GregorianCalendar(2013, 11, 7, 16, 0).getTimeInMillis(), "Auto Alert 4:00p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c16 = new Alert(new GregorianCalendar(2013, 11, 7, 16, 30).getTimeInMillis(), "Auto Alert 4:30p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c17 = new Alert(new GregorianCalendar(2013, 11, 7, 17, 0).getTimeInMillis(), "Auto Alert 5:00p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c18 = new Alert(new GregorianCalendar(2013, 11, 7, 17, 30).getTimeInMillis(), "Auto Alert 5:30p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c19 = new Alert(new GregorianCalendar(2013, 11, 7, 18, 0).getTimeInMillis(), "Auto Alert 6:00p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c20 = new Alert(new GregorianCalendar(2013, 11, 7, 18, 30).getTimeInMillis(), "Auto Alert 6:30p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c21 = new Alert(new GregorianCalendar(2013, 11, 7, 19, 0).getTimeInMillis(), "Auto Alert 7:00p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c22 = new Alert(new GregorianCalendar(2013, 11, 7, 19, 30).getTimeInMillis(), "Auto Alert 7:30p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c23 = new Alert(new GregorianCalendar(2013, 11, 7, 20, 0).getTimeInMillis(), "Auto Alert 8:00p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c24 = new Alert(new GregorianCalendar(2013, 11, 7, 20, 30).getTimeInMillis(), "Auto Alert 8:30p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c25 = new Alert(new GregorianCalendar(2013, 11, 7, 21, 0).getTimeInMillis(), "Auto Alert 9:00p", 0, AlertType.getValue(AlertType.TIMED)); + Alert c26 = new Alert(new GregorianCalendar(2013, 11, 7, 21, 30).getTimeInMillis(), "Auto Alert 9:30p", 0, AlertType.getValue(AlertType.TIMED)); + + AlertDB db = new AlertDB(this); db.persist(a1); @@ -87,6 +119,33 @@ public class AlertService extends IntentService { db.persist(a3); db.persist(b1); db.persist(b2); + db.persist(c1); + db.persist(c2); + db.persist(c3); + db.persist(c4); + db.persist(c5); + db.persist(c6); + db.persist(c7); + db.persist(c8); + db.persist(c9); + db.persist(c10); + db.persist(c11); + db.persist(c12); + db.persist(c13); + db.persist(c14); + db.persist(c15); + db.persist(c16); + db.persist(c17); + db.persist(c18); + db.persist(c19); + db.persist(c20); + db.persist(c21); + db.persist(c22); + db.persist(c23); + db.persist(c24); + db.persist(c25); + db.persist(c26); + }