Permalink
Browse files

Added server method called getCapsules which accepts all the new crit…

…eria and will give it to the server
  • Loading branch information...
1 parent 3c89186 commit 5d96f7d95813c476adc9c6455d0b0ee1bf67c2d6 @calebgomer calebgomer committed Mar 11, 2012
View
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
View
@@ -103,14 +103,6 @@
android:layout_height="wrap_content"
android:minWidth="200dip"
android:text="Submit" />
-
- <!--
- <RatingBar
- android:id="@+id/capsule_my_rating_bar"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:numStars="5" />
- -->
</LinearLayout>
</LinearLayout>
</ScrollView>
@@ -97,7 +97,7 @@ private void setCapsuleInfo(String capsuleId) {
TAB);
title.setText(treasureInfo[0]);
description.setText(treasureInfo[3]);
- leftOn.setText("Left on " + treasureInfo[4]);
+ leftOn.setText("Left on " + treasureInfo[4].split(" ")[0]);
rating
.setRating(Float.parseFloat(Server.getRating(capsuleId)));
}
@@ -175,13 +175,13 @@ public boolean onTouch(View v, MotionEvent event) {
@Override
public void onClick(View v) {
+ submitLayout.setVisibility(View.GONE);
Server.addRating(getSharedPreferences("profile", 0)
.getString("player_id", "0"), capsuleId, Float
.toString(ratingBar.getRating()));
refresh();
Toast.makeText(getApplicationContext(),
- "Rating Submitted", Toast.LENGTH_SHORT).show();
- submitLayout.setVisibility(View.GONE);
+ "Rating Submitted", Toast.LENGTH_SHORT).show();
}
});
cancelButton.setOnClickListener(new OnClickListener() {
@@ -221,7 +221,9 @@ protected void requestLocationUpdates() {
protected void retrieveCapsules(GeoPoint userLoc) {
String lat = Double.toString(userLoc.getLatitudeE6() / 1e6);
String lng = Double.toString(userLoc.getLongitudeE6() / 1e6);
- String retrieve = Server.getTreasure(lat, lng);
+ // String retrieve = Server.getTreasure(lat, lng);
+ String retrieve = Server
+ .getCapsule(lat, lng, "1", "", "", "");
if (lastRetrieve != retrieve || lastRetrieve == null) {
lastRetrieve = retrieve;
parseAndDrawCapsules(retrieve);
@@ -323,23 +325,23 @@ public void onLocationChanged(Location location) {
} else if (location != null && location.hasAccuracy()) {
// if accuracy is bad, will let user know it is still
// looking
- switch (numNotifiedAboutPoorLocation) {
- case 0:
- Toast.makeText(CapsuleMapActivity.this,
- "Waiting for a better GPS position...",
- Toast.LENGTH_LONG).show();
- break;
- case 1:
- Toast.makeText(CapsuleMapActivity.this,
- "Still waiting for a better GPS position...",
- Toast.LENGTH_LONG).show();
- break;
- default:
- if (numNotifiedAboutPoorLocation % 10 == 0)
- Toast.makeText(CapsuleMapActivity.this,
- "Still waiting...", Toast.LENGTH_LONG).show();
- break;
- }
+ // switch (numNotifiedAboutPoorLocation) {
+ // case 0:
+ // Toast.makeText(CapsuleMapActivity.this,
+ // "Waiting for a better GPS position...",
+ // Toast.LENGTH_LONG).show();
+ // break;
+ // case 1:
+ // Toast.makeText(CapsuleMapActivity.this,
+ // "Still waiting for a better GPS position...",
+ // Toast.LENGTH_LONG).show();
+ // break;
+ // default:
+ // if (numNotifiedAboutPoorLocation % 10 == 0)
+ // Toast.makeText(CapsuleMapActivity.this,
+ // "Still waiting...", Toast.LENGTH_LONG).show();
+ // break;
+ // }
numNotifiedAboutPoorLocation++;
} else {
// if gps has no accuracy, will resposition on last known
@@ -411,7 +413,9 @@ private void centerMap(boolean forceRefresh) {
mapController.animateTo(userLocation);
PreferenceManager
.getDefaultSharedPreferences(getApplicationContext())
- .edit().putBoolean("follow_user", true);
+ .edit().putBoolean("follow_user", true).commit();
+ Log.d("debug", userLocation.getLatitudeE6() + " "
+ + userLocation.getLongitudeE6());
// mapController.setZoom(20);
}
}
@@ -26,7 +26,7 @@
public class Server {
// Get Capsule
- private static final String GETCAPS = "http://www.cis.gvsu.edu/~scrippsj/socNet/functions/getCapsule.php?";
+ private static final String GETCAPSULE = "http://www.cis.gvsu.edu/~scrippsj/socNet/functions/getCapsule.php?";
// Create Capsule
private static final String NEWCAPSULE = "http://www.cis.gvsu.edu/~scrippsj/socNet/functions/setCapsule.php?";
// Get User
@@ -86,12 +86,12 @@ public static String authenticate(String id, String password) {
}
public static String getCapsule(String id) {
- String command = GETCAPS + "id=" + id;
+ String command = GETCAPSULE + "id=" + id;
return get(command);
}
public static String getTreasure(String lat, String lng) {
- String command = GETCAPS + "lat=" + lat + "&long=" + lng
+ String command = GETCAPSULE + "lat=" + lat + "&long=" + lng
+ "&radius=4";
return get(command);
}
@@ -145,7 +145,33 @@ public static String uploadTreasure(String path) {
;
return get(command);
}
+
+ /****************************************************************
+ * @param latitude float value of latitude (not E6)
+ * @param longitude float value of longitude (not E6)
+ * @param radiusCode 1 for inner radius, 2 for outer radius
+ * @param startDate yyyy/mm/dd date to start filtering by
+ * @param endDate yyyy/mm/dd date to end filtering by
+ * @param minRating minimum rating to return, integers 1 to 5
+ * @return String the capsules returned by the query
+ ***************************************************************/
+ public static String getCapsule(String latitude,
+ String longitude, String radiusCode, String startDate,
+ String endDate, String minRating) {
+ String request = GETCAPSULE;
+ String result;
+ request += "lat=" + latitude + "&long=" + longitude
+ + "&radiusCode=" + radiusCode + "&dateStart=" + startDate
+ + "&dateEnd=" + endDate + "&minRate=" + minRating;
+ result = get(request);
+ return result;
+ }
+ /****************************************************************
+ * Basic server post code
+ * @param command
+ * @return String
+ ***************************************************************/
private static String get(String command) {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(command);

0 comments on commit 5d96f7d

Please sign in to comment.