mirror of
				https://github.com/bspeice/itcs4180
				synced 2025-11-03 18:00:37 -05:00 
			
		
		
		
	Merge remote-tracking branch 'origin/master'
This commit is contained in:
		@ -78,6 +78,7 @@ public class MainActivity extends Activity {
 | 
			
		||||
		 }
 | 
			
		||||
 		
 | 
			
		||||
		// And kick off contacting to server to see if there are any new ones
 | 
			
		||||
		locationList = (ListView)findViewById(R.id.listLocations);
 | 
			
		||||
		new LocationClient.LocationsDownloader(this) {
 | 
			
		||||
			@Override
 | 
			
		||||
			protected void onPostExecute(List<RestLocation> result) {
 | 
			
		||||
 | 
			
		||||
@ -138,7 +138,7 @@ public class SearchActivity extends Activity {
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			new ImageDownloader().execute(restLocation.getRiddleImageURL());
 | 
			
		||||
			new ImageDownloader().execute(restLocation.getRiddleImageUrl());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -34,7 +34,8 @@ public class LocationDatabaseHelper extends SQLiteOpenHelper {
 | 
			
		||||
	private static final String KEY_RIDDLE = "RIDDLE";
 | 
			
		||||
	private static final String KEY_LOCATION_LONG = "LOCATION_LONG";
 | 
			
		||||
	private static final String KEY_LOCATION_LAT = "LOCATION_LAT";
 | 
			
		||||
	private static final String KEY_KEY = "KEYs";
 | 
			
		||||
	private static final String KEY_VALIDATION_KEY = "VALIDATION_KEY";
 | 
			
		||||
	private static final String KEY_RIDDLE_IMAGE_URL = "RIDDLE_IMAGE_URL";
 | 
			
		||||
	
 | 
			
		||||
	private LocationDatabaseHelper(Context ctx) {
 | 
			
		||||
		super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
 | 
			
		||||
@ -54,7 +55,8 @@ public class LocationDatabaseHelper extends SQLiteOpenHelper {
 | 
			
		||||
				KEY_RIDDLE + " VARCHAR(1024)," +
 | 
			
		||||
				KEY_LOCATION_LONG + " REAL," +
 | 
			
		||||
				KEY_LOCATION_LAT + " REAL," +
 | 
			
		||||
				KEY_KEY + " VARCHAR(255)" +
 | 
			
		||||
				KEY_VALIDATION_KEY + " VARCHAR(255)," +
 | 
			
		||||
				KEY_RIDDLE_IMAGE_URL + " VARCHAR(255)" +
 | 
			
		||||
				");";
 | 
			
		||||
	@Override
 | 
			
		||||
	public void onCreate(SQLiteDatabase db) {
 | 
			
		||||
@ -85,7 +87,7 @@ public class LocationDatabaseHelper extends SQLiteOpenHelper {
 | 
			
		||||
		ArrayList<RestLocation> results = new ArrayList<RestLocation>();
 | 
			
		||||
		SQLiteDatabase db = helper.getReadableDatabase();
 | 
			
		||||
		Cursor c = db.query(TABLE_NAME, new String[]{KEY_ID, KEY_NAME, KEY_RIDDLE, KEY_LOCATION_LONG,
 | 
			
		||||
											KEY_LOCATION_LAT, KEY_KEY},
 | 
			
		||||
											KEY_LOCATION_LAT, KEY_VALIDATION_KEY, KEY_RIDDLE_IMAGE_URL},
 | 
			
		||||
				null, null, null, null, null);
 | 
			
		||||
		
 | 
			
		||||
		if (c != null && c.getCount() > 0) {
 | 
			
		||||
@ -108,8 +110,9 @@ public class LocationDatabaseHelper extends SQLiteOpenHelper {
 | 
			
		||||
		values.put(KEY_RIDDLE, loc.getRiddle());
 | 
			
		||||
		values.put(KEY_LOCATION_LONG, loc.getLocationLong());
 | 
			
		||||
		values.put(KEY_LOCATION_LAT, loc.getLocationLat());
 | 
			
		||||
		values.put(KEY_KEY, loc.getKey());
 | 
			
		||||
		helper.getWritableDatabase().insert(TABLE_NAME, null, values);
 | 
			
		||||
		values.put(KEY_VALIDATION_KEY, loc.getKey());
 | 
			
		||||
		values.put(KEY_RIDDLE_IMAGE_URL, loc.getRiddleImageUrl());
 | 
			
		||||
		helper.getWritableDatabase().insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void persistAll(List<RestLocation> locs) {
 | 
			
		||||
 | 
			
		||||
@ -11,7 +11,12 @@ import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.FieldNamingPolicy;
 | 
			
		||||
import com.google.gson.Gson;
 | 
			
		||||
import com.google.gson.GsonBuilder;
 | 
			
		||||
 | 
			
		||||
import retrofit.RestAdapter;
 | 
			
		||||
import retrofit.converter.GsonConverter;
 | 
			
		||||
import android.content.Context;
 | 
			
		||||
import android.os.AsyncTask;
 | 
			
		||||
import edu.uncc.scavenger.R;
 | 
			
		||||
@ -20,7 +25,10 @@ public class LocationClient {
 | 
			
		||||
 | 
			
		||||
	private static LocationService getAdapter(Context ctx) {
 | 
			
		||||
		String endpoint = ctx.getString(R.string.endpoint);
 | 
			
		||||
		Gson gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
 | 
			
		||||
				.create();
 | 
			
		||||
		RestAdapter ra = new RestAdapter.Builder().setEndpoint(endpoint)
 | 
			
		||||
				.setConverter(new GsonConverter(gson))
 | 
			
		||||
				.build();
 | 
			
		||||
		return ra.create(LocationService.class);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,7 @@ public class RestLocation implements Serializable{
 | 
			
		||||
	private String riddle;
 | 
			
		||||
	private double locationLong;
 | 
			
		||||
	private double locationLat;
 | 
			
		||||
	private String riddleImageURL;
 | 
			
		||||
	private String riddleImageUrl;
 | 
			
		||||
	private String key;
 | 
			
		||||
	
 | 
			
		||||
	public int getId() {
 | 
			
		||||
@ -57,11 +57,11 @@ public class RestLocation implements Serializable{
 | 
			
		||||
	public void setKey(String key) {
 | 
			
		||||
		this.key = key;
 | 
			
		||||
	}
 | 
			
		||||
	public String getRiddleImageURL() {
 | 
			
		||||
		return riddleImageURL;
 | 
			
		||||
	public String getRiddleImageUrl() {
 | 
			
		||||
		return riddleImageUrl;
 | 
			
		||||
	}
 | 
			
		||||
	public void setRiddleImageURL(String riddleImageURL) {
 | 
			
		||||
		this.riddleImageURL = riddleImageURL;
 | 
			
		||||
	public void setRiddleImageUrl(String riddleImageUrl) {
 | 
			
		||||
		this.riddleImageUrl = riddleImageUrl;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public Location getLocation() {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user