1
0
mirror of https://github.com/bspeice/itcs4180 synced 2024-12-04 13:18:16 -05:00

Added back code I accidentally deleted.

This commit is contained in:
tokugawa 2014-04-21 13:10:18 -04:00
parent 6e2ad36f09
commit 5224983c10

View File

@ -37,6 +37,8 @@ public class MainActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
locationList = (ListView)findViewById(R.id.listLocations);
/*Test Code for mock location
RestLocation location = new RestLocation();
location.setId(1);
@ -52,6 +54,29 @@ public class MainActivity extends Activity {
finish();
/*End Test Code*/
// Get our list of events loaded
locationList = (ListView)findViewById(R.id.listLocations);
locations = LocationDatabaseHelper.getInstance(this).fetchAll();
if (locations != null && locations.size() > 0) {
LocationAdapter mLocationAdapter = new LocationAdapter(locations);
locationList.setAdapter(mLocationAdapter);
locationList.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view,int position, long id) {
Intent intent = new Intent(getApplicationContext(), SearchActivity.class);
intent.putExtra("restLocation", locations.get(position));
startActivity(intent);
}
});
}
else {
// We don't yet have any locations...
((TextView)findViewById(R.id.txtNoLocations)).setVisibility(View.VISIBLE);
((ListView)findViewById(R.id.listLocations)).setVisibility(View.GONE);
Log.d("NoLocation", "NoLocations");
}
// And kick off contacting to server to see if there are any new ones
new LocationClient.LocationsDownloader(this) {
@Override
@ -126,7 +151,6 @@ public class MainActivity extends Activity {
return v;
}
}
static class Holder {