From c4a37992431d6b075ec55a3e23d4e424c79e51db Mon Sep 17 00:00:00 2001 From: tokugawa Date: Mon, 21 Apr 2014 14:51:10 -0400 Subject: [PATCH] Fixed contexts. --- .../src/edu/uncc/scavenger/CompassActivity.java | 4 ++-- .../src/edu/uncc/scavenger/FoundActivity.java | 2 +- .../src/edu/uncc/scavenger/MainActivity.java | 3 ++- .../src/edu/uncc/scavenger/SearchActivity.java | 12 ++++++------ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/UNCCScavenger/src/edu/uncc/scavenger/CompassActivity.java b/UNCCScavenger/src/edu/uncc/scavenger/CompassActivity.java index 5e7007e..7e8a29c 100644 --- a/UNCCScavenger/src/edu/uncc/scavenger/CompassActivity.java +++ b/UNCCScavenger/src/edu/uncc/scavenger/CompassActivity.java @@ -60,7 +60,7 @@ public class CompassActivity extends Activity implements SensorEventListener compassRoseView = (ImageView)findViewById(R.id.compassRoseView); searchImageView = (ImageView)findViewById(R.id.searchImageView); searchImageView.setVisibility(View.INVISIBLE); - Bitmap b = BitmapAccess.loadBitmap(getApplicationContext(), restLocation.getName()); + Bitmap b = BitmapAccess.loadBitmap(this, restLocation.getName()); if(b != null) { searchImageView.setImageBitmap(b); @@ -94,7 +94,7 @@ public class CompassActivity extends Activity implements SensorEventListener } }); - Toast.makeText(getApplicationContext(), ""+searchLocation.getLatitude()+", "+searchLocation.getLongitude(), Toast.LENGTH_SHORT).show(); + Toast.makeText(this, ""+searchLocation.getLatitude()+", "+searchLocation.getLongitude(), Toast.LENGTH_SHORT).show(); } @Override diff --git a/UNCCScavenger/src/edu/uncc/scavenger/FoundActivity.java b/UNCCScavenger/src/edu/uncc/scavenger/FoundActivity.java index 9a7b156..286c167 100644 --- a/UNCCScavenger/src/edu/uncc/scavenger/FoundActivity.java +++ b/UNCCScavenger/src/edu/uncc/scavenger/FoundActivity.java @@ -46,7 +46,7 @@ public class FoundActivity extends Activity { @Override public void onClick(View v) { - intent = new Intent(getApplicationContext(), MainActivity.class); + intent = new Intent(FoundActivity.this, MainActivity.class); startActivity(intent); finish(); } diff --git a/UNCCScavenger/src/edu/uncc/scavenger/MainActivity.java b/UNCCScavenger/src/edu/uncc/scavenger/MainActivity.java index 8dbc5cb..c817bfc 100644 --- a/UNCCScavenger/src/edu/uncc/scavenger/MainActivity.java +++ b/UNCCScavenger/src/edu/uncc/scavenger/MainActivity.java @@ -64,7 +64,7 @@ public class MainActivity extends Activity { @Override public void onItemClick(AdapterView parent, View view,int position, long id) { - Intent intent = new Intent(getApplicationContext(), SearchActivity.class); + Intent intent = new Intent(MainActivity.this, SearchActivity.class); intent.putExtra("restLocation", locations.get(position)); startActivity(intent); } @@ -94,6 +94,7 @@ public class MainActivity extends Activity { // And we're even kind enough to update the database LocationDatabaseHelper.getInstance(MainActivity.this).persistAll(result); + locations = LocationDatabaseHelper.getInstance(getBaseContext()).fetchAll(); } }.execute(); diff --git a/UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java b/UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java index f209123..2740583 100644 --- a/UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java +++ b/UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java @@ -101,7 +101,7 @@ public class SearchActivity extends Activity { if(lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) { - intent = new Intent(getApplicationContext(), CompassActivity.class); + intent = new Intent(SearchActivity.this, CompassActivity.class); intent.putExtra("restLocation", restLocation); startActivity(intent); } @@ -131,7 +131,7 @@ public class SearchActivity extends Activity { }); Toast.makeText(getApplicationContext(), restLocation.getRiddleImageUrl(), Toast.LENGTH_SHORT).show(); - Bitmap locationPicture = BitmapAccess.loadBitmap(getApplicationContext(), restLocation.getName()); + Bitmap locationPicture = BitmapAccess.loadBitmap(this, restLocation.getName()); if(locationPicture != null) { locationImage.setImageBitmap(locationPicture); @@ -171,18 +171,18 @@ public class SearchActivity extends Activity { String contents = data.getStringExtra("SCAN_RESULT"); if(contents.equals(restLocation.getName())) { - intent = new Intent(getApplicationContext(), FoundActivity.class); + intent = new Intent(SearchActivity.this, FoundActivity.class); startActivity(intent); finish(); } else { - Toast.makeText(getApplicationContext(), "Incorrect place found: "+contents, Toast.LENGTH_SHORT).show(); + Toast.makeText(SearchActivity.this, "Incorrect place found: "+contents, Toast.LENGTH_SHORT).show(); } } else if (resultCode == RESULT_CANCELED) { - Toast.makeText(getApplicationContext(), "Error scanning code", Toast.LENGTH_SHORT).show(); + Toast.makeText(SearchActivity.this, "Error scanning code", Toast.LENGTH_SHORT).show(); } } } @@ -209,7 +209,7 @@ public class SearchActivity extends Activity { if(result!=null) { locationImage.setImageBitmap(result); - BitmapAccess.saveBitmap(getApplicationContext(), result, restLocation.getName()); + BitmapAccess.saveBitmap(SearchActivity.this, result, restLocation.getName()); } } }