Don't set location if user isn't logged in
parent
289743142c
commit
6f8841a7f8
|
@ -265,19 +265,25 @@ public class LocationService extends Service implements GoogleApiClient.Connecti
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChanged(Location location) {
|
public void onLocationChanged(Location location) {
|
||||||
|
|
||||||
JSONObject mLocationView = new JSONObject();
|
// Make sure we're logged in...
|
||||||
try {
|
if (mUserID!=null && mUserSK!=null) {
|
||||||
mLocationView.put("usr", mUserID);
|
JSONObject mLocationView = new JSONObject();
|
||||||
mLocationView.put("tok", mUserSK);
|
try {
|
||||||
mLocationView.put("lat", String.valueOf(location.getLatitude()));
|
mLocationView.put("usr", mUserID);
|
||||||
mLocationView.put("lon", String.valueOf(location.getLongitude()));
|
mLocationView.put("tok", mUserSK);
|
||||||
mLocationView.put("dir", String.valueOf(location.getBearing()));
|
mLocationView.put("lat", String.valueOf(location.getLatitude()));
|
||||||
mLocationView.put("spd", String.valueOf(location.getSpeed()));
|
mLocationView.put("lon", String.valueOf(location.getLongitude()));
|
||||||
} catch (JSONException e) {
|
mLocationView.put("dir", String.valueOf(location.getBearing()));
|
||||||
Log.e(TAG, "Failed to put JSON data");
|
mLocationView.put("spd", String.valueOf(location.getSpeed()));
|
||||||
|
} catch (JSONException e) {
|
||||||
|
Log.e(TAG, "Failed to put JSON data");
|
||||||
|
}
|
||||||
|
socket.emit("set", mLocationView);
|
||||||
|
Log.v(TAG, "Location set: " + mLocationView.toString());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Log.v(TAG, "Can't set location because user isn't logged in.");
|
||||||
}
|
}
|
||||||
socket.emit("set", mLocationView);
|
|
||||||
Log.v(TAG, "Location updated: " + mLocationView.toString());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue