Handle the RSVP search list not connecting to the Internet

master
bspeice 2013-12-08 20:39:11 -05:00
parent 2f44e21d16
commit a5bd595a48
1 changed files with 59 additions and 58 deletions

View File

@ -1,5 +1,6 @@
package com.uncc.gameday.activities;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@ -31,6 +32,7 @@ public class Search extends MenuActivity {
private class fetchAttendeesThread extends Thread {
Context c;
public fetchAttendeesThread(Context c) {
this.c = c;
}
@ -45,13 +47,13 @@ public class Search extends MenuActivity {
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());
Toast.makeText(c, R.string.internet_down_error,
Toast.LENGTH_SHORT).show();
Log.e("Search", e.getMessage());
}
//sorts RSVPList alphabetically by last name
if(rsvpList != null)
{
// sorts RSVPList alphabetically by last name
if (rsvpList != null) {
Collections.sort(rsvpList, new Comparator<Attendee>() {
@Override
public int compare(Attendee a1, Attendee a2) {
@ -60,21 +62,20 @@ public class Search extends MenuActivity {
return compareName.compareTo(thisName);
}
});
} else {
rsvpList = new ArrayList<Attendee>();
}
runOnUiThread(new Runnable() {
@Override
public void run() {
ListView listView = (ListView)findViewById(R.id.RSVPListView);
ArrayAdapter<Attendee> adapter =
new ArrayAdapter<Attendee>(c,android.R.layout.simple_list_item_1, rsvpList);
ListView listView = (ListView) findViewById(R.id.RSVPListView);
ArrayAdapter<Attendee> adapter = new ArrayAdapter<Attendee>(
c, android.R.layout.simple_list_item_1, rsvpList);
listView.setAdapter(adapter);
}
});
}
}
}
}