mirror of
https://github.com/bspeice/itcs4180
synced 2024-12-04 13:18:16 -05:00
Test code added.
This commit is contained in:
parent
7ce4b9e0bf
commit
720cb7ee38
@ -23,19 +23,11 @@
|
|||||||
android:text="@string/default_text"
|
android:text="@string/default_text"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||||
|
|
||||||
<ImageView
|
<WebView
|
||||||
android:id="@+id/foundImageView"
|
android:id="@+id/moreInfoWebView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_weight="1" />
|
||||||
android:src="@drawable/map" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/seeMoreButton"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:text="@string/see_more_text" />
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/tryMoreButton"
|
android:id="@+id/tryMoreButton"
|
||||||
|
@ -99,7 +99,7 @@ public class CompassActivity extends Activity implements SensorEventListener
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Toast.makeText(this, ""+searchLocation.getLatitude()+", "+searchLocation.getLongitude(), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(this, ""+searchLocation.getLatitude()+", "+searchLocation.getLongitude(), Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,6 +7,7 @@ package edu.uncc.scavenger;
|
|||||||
* FoundActivity.java
|
* FoundActivity.java
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import edu.uncc.scavenger.rest.RestLocation;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -15,33 +16,31 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
import android.webkit.WebView;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class FoundActivity extends Activity {
|
public class FoundActivity extends Activity {
|
||||||
|
|
||||||
TextView numberFoundText;
|
TextView numberFoundText;
|
||||||
Button seeMoreButton, tryMoreButton;
|
Button tryMoreButton;
|
||||||
|
WebView moreInfoWebView;
|
||||||
Intent intent;
|
Intent intent;
|
||||||
|
RestLocation restLocation;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_found);
|
setContentView(R.layout.activity_found);
|
||||||
|
|
||||||
|
|
||||||
numberFoundText = (TextView)findViewById(R.id.numberFoundText);
|
numberFoundText = (TextView)findViewById(R.id.numberFoundText);
|
||||||
seeMoreButton = (Button)findViewById(R.id.seeMoreButton);
|
moreInfoWebView = (WebView)findViewById(R.id.moreInfoWebView);
|
||||||
tryMoreButton = (Button)findViewById(R.id.tryMoreButton);
|
tryMoreButton = (Button)findViewById(R.id.tryMoreButton);
|
||||||
|
|
||||||
seeMoreButton.setOnClickListener(new OnClickListener(){
|
restLocation = (RestLocation)(getIntent().getSerializableExtra("restLocation"));
|
||||||
|
//moreInfoWebView.loadUrl(restLocation.getKey());
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
//TODO
|
|
||||||
//Get more information address and open web browser
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
tryMoreButton.setOnClickListener(new OnClickListener(){
|
tryMoreButton.setOnClickListener(new OnClickListener(){
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,6 +31,7 @@ public class MainActivity extends Activity {
|
|||||||
|
|
||||||
ListView locationList;
|
ListView locationList;
|
||||||
List<RestLocation> locations;
|
List<RestLocation> locations;
|
||||||
|
static String key;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -98,7 +99,15 @@ public class MainActivity extends Activity {
|
|||||||
}
|
}
|
||||||
}.execute();
|
}.execute();
|
||||||
|
|
||||||
//Toast.makeText(getApplicationContext(), ""+locations.get(0).getRiddleImageUrl(), 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();
|
||||||
|
}
|
||||||
|
}.execute("1", "Belk Tower");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,7 +8,9 @@ package edu.uncc.scavenger;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import edu.uncc.scavenger.database.LocationDatabaseHelper;
|
||||||
import edu.uncc.scavenger.rest.RestLocation;
|
import edu.uncc.scavenger.rest.RestLocation;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@ -52,7 +54,7 @@ public class SearchActivity extends Activity {
|
|||||||
riddleView = (TextView)findViewById(R.id.riddleView);
|
riddleView = (TextView)findViewById(R.id.riddleView);
|
||||||
|
|
||||||
restLocation = (RestLocation)(getIntent().getSerializableExtra("restLocation"));
|
restLocation = (RestLocation)(getIntent().getSerializableExtra("restLocation"));
|
||||||
Log.d("restLocation", restLocation.getName());
|
//Log.d("restLocation", restLocation.getName());
|
||||||
|
|
||||||
locationText.setText(restLocation.getName());
|
locationText.setText(restLocation.getName());
|
||||||
riddleView.setText(restLocation.getRiddle());
|
riddleView.setText(restLocation.getRiddle());
|
||||||
@ -130,7 +132,7 @@ public class SearchActivity extends Activity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Toast.makeText(getApplicationContext(), restLocation.getRiddleImageUrl(), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(getApplicationContext(), restLocation.getRiddleImageUrl(), Toast.LENGTH_SHORT).show();
|
||||||
Bitmap locationPicture = BitmapAccess.loadBitmap(this, restLocation.getName());
|
Bitmap locationPicture = BitmapAccess.loadBitmap(this, restLocation.getName());
|
||||||
if(locationPicture != null)
|
if(locationPicture != null)
|
||||||
{
|
{
|
||||||
@ -171,7 +173,14 @@ public class SearchActivity extends Activity {
|
|||||||
String contents = data.getStringExtra("SCAN_RESULT");
|
String contents = data.getStringExtra("SCAN_RESULT");
|
||||||
if(contents.equals(restLocation.getName()))
|
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 = new Intent(SearchActivity.this, FoundActivity.class);
|
||||||
|
intent.putExtra("restLocation", restLocation);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,11 @@ import com.google.gson.Gson;
|
|||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
|
||||||
import retrofit.RestAdapter;
|
import retrofit.RestAdapter;
|
||||||
|
import retrofit.RetrofitError;
|
||||||
import retrofit.converter.GsonConverter;
|
import retrofit.converter.GsonConverter;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.util.Log;
|
||||||
import edu.uncc.scavenger.R;
|
import edu.uncc.scavenger.R;
|
||||||
|
|
||||||
public class LocationClient {
|
public class LocationClient {
|
||||||
@ -38,7 +40,14 @@ public class LocationClient {
|
|||||||
Map<String, String> keys = new HashMap<String, String>();
|
Map<String, String> keys = new HashMap<String, String>();
|
||||||
keys.put("key", key);
|
keys.put("key", key);
|
||||||
keys.put("id", String.valueOf(id));
|
keys.put("id", String.valueOf(id));
|
||||||
return client.getResult(keys);
|
try
|
||||||
|
{
|
||||||
|
return client.getResult(keys);
|
||||||
|
}
|
||||||
|
catch(RetrofitError e)
|
||||||
|
{
|
||||||
|
return "Verification failed";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LocationsDownloader extends
|
public static class LocationsDownloader extends
|
||||||
@ -54,4 +63,19 @@ public class LocationClient {
|
|||||||
return getAdapter(ctx).listLocations();
|
return getAdapter(ctx).listLocations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class VerifyAsync extends AsyncTask<String, Void, String>
|
||||||
|
{
|
||||||
|
private Context ctx;
|
||||||
|
|
||||||
|
public VerifyAsync(Context ctx)
|
||||||
|
{
|
||||||
|
this.ctx = ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String doInBackground(String... params) {
|
||||||
|
return LocationClient.validateLocation(ctx, Integer.parseInt(params[0]), params[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user