From f3582b1815a938e198094e3b25406d17d9ee73fe Mon Sep 17 00:00:00 2001 From: tokugawa Date: Sat, 26 Apr 2014 01:08:30 -0400 Subject: [PATCH] FoundActivity now loads Webview --- .../src/edu/uncc/scavenger/FoundActivity.java | 5 +-- .../src/edu/uncc/scavenger/MainActivity.java | 10 +---- .../edu/uncc/scavenger/SearchActivity.java | 45 ++++++++++++------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/UNCCScavenger/src/edu/uncc/scavenger/FoundActivity.java b/UNCCScavenger/src/edu/uncc/scavenger/FoundActivity.java index 60770b4..69a4e3a 100644 --- a/UNCCScavenger/src/edu/uncc/scavenger/FoundActivity.java +++ b/UNCCScavenger/src/edu/uncc/scavenger/FoundActivity.java @@ -39,7 +39,7 @@ public class FoundActivity extends Activity { tryMoreButton = (Button)findViewById(R.id.tryMoreButton); restLocation = (RestLocation)(getIntent().getSerializableExtra("restLocation")); - //moreInfoWebView.loadUrl(restLocation.getKey()); + moreInfoWebView.loadData(restLocation.getKey(), "text/html", "UTF-8"); tryMoreButton.setOnClickListener(new OnClickListener(){ @@ -50,9 +50,6 @@ public class FoundActivity extends Activity { finish(); } }); - - //TODO - //Add found location to database } @Override diff --git a/UNCCScavenger/src/edu/uncc/scavenger/MainActivity.java b/UNCCScavenger/src/edu/uncc/scavenger/MainActivity.java index aea6597..240b50b 100644 --- a/UNCCScavenger/src/edu/uncc/scavenger/MainActivity.java +++ b/UNCCScavenger/src/edu/uncc/scavenger/MainActivity.java @@ -12,6 +12,7 @@ import java.util.List; import android.app.Activity; import android.content.Intent; import android.os.Bundle; +import android.os.StrictMode; import android.util.Log; import android.view.Menu; import android.view.View; @@ -99,15 +100,6 @@ public class MainActivity extends Activity { } }.execute(); - new LocationClient.VerifyAsync(this) { - @Override - protected void onPostExecute(String result) { - super.onPostExecute(result); - key = result; - Toast.makeText(getApplicationContext(), key, Toast.LENGTH_SHORT).show(); - } - }.execute("1", "Belk Tower"); - } @Override diff --git a/UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java b/UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java index d8b7567..7a3c946 100644 --- a/UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java +++ b/UNCCScavenger/src/edu/uncc/scavenger/SearchActivity.java @@ -11,6 +11,7 @@ import java.net.URL; import java.util.List; import edu.uncc.scavenger.database.LocationDatabaseHelper; +import edu.uncc.scavenger.rest.LocationClient; import edu.uncc.scavenger.rest.RestLocation; import android.app.Activity; import android.app.AlertDialog; @@ -41,6 +42,7 @@ public class SearchActivity extends Activity { TextView locationText, riddleView; Intent intent; RestLocation restLocation; + String key; @Override protected void onCreate(Bundle savedInstanceState) { @@ -171,23 +173,32 @@ public class SearchActivity extends Activity { if (resultCode == RESULT_OK) { String contents = data.getStringExtra("SCAN_RESULT"); - if(contents.equals(restLocation.getName())) - { - //Add found to the database - /*List locations = LocationDatabaseHelper.getInstance(this).fetchAll(); - if (locations != null && locations.size() > 0) - { - locations.get(restLocation.getId()-1); - }*/ - intent = new Intent(SearchActivity.this, FoundActivity.class); - intent.putExtra("restLocation", restLocation); - startActivity(intent); - finish(); - } - else - { - Toast.makeText(SearchActivity.this, "Incorrect place found: "+contents, Toast.LENGTH_SHORT).show(); - } + new LocationClient.VerifyAsync(this) { + @Override + protected void onPostExecute(String result) { + super.onPostExecute(result); + key = result; + Toast.makeText(getApplicationContext(), key, Toast.LENGTH_SHORT).show(); + if(key!= null) + { + //Add found to the database + /*List locations = LocationDatabaseHelper.getInstance(this).fetchAll(); + if (locations != null && locations.size() > 0) + { + locations.get(restLocation.getId()-1); + }*/ + restLocation.setKey(key); + intent = new Intent(SearchActivity.this, FoundActivity.class); + intent.putExtra("restLocation", restLocation); + startActivity(intent); + finish(); + } + else + { + Toast.makeText(SearchActivity.this, "Incorrect place found", Toast.LENGTH_SHORT).show(); + } + } + }.execute(restLocation.getName(), contents); } else if (resultCode == RESULT_CANCELED) {