From 5224983c107235f23aa3797a17f6dea18833a217 Mon Sep 17 00:00:00 2001 From: tokugawa Date: Mon, 21 Apr 2014 13:10:18 -0400 Subject: [PATCH] Added back code I accidentally deleted. --- .../src/edu/uncc/scavenger/MainActivity.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/UNCCScavenger/src/edu/uncc/scavenger/MainActivity.java b/UNCCScavenger/src/edu/uncc/scavenger/MainActivity.java index 71527f4..c2e24eb 100644 --- a/UNCCScavenger/src/edu/uncc/scavenger/MainActivity.java +++ b/UNCCScavenger/src/edu/uncc/scavenger/MainActivity.java @@ -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 {