diff --git a/LocationRinger/src/org/RickBarrette/android/LocationRinger/ui/fragments/LocationInformationFragment.java b/LocationRinger/src/org/RickBarrette/android/LocationRinger/ui/fragments/LocationInformationFragment.java index 1108ca0..0de71b4 100644 --- a/LocationRinger/src/org/RickBarrette/android/LocationRinger/ui/fragments/LocationInformationFragment.java +++ b/LocationRinger/src/org/RickBarrette/android/LocationRinger/ui/fragments/LocationInformationFragment.java @@ -358,17 +358,25 @@ public class LocationInformationFragment extends Fragment implements LatLngListe if (mMap != null) mMap.moveCamera(CameraUpdateFactory.newLatLng(point)); - if (mListener != null) { - final ContentValues info = new ContentValues(); - final StringBuilder sb = new StringBuilder(); - sb.append(point.latitude).append(",").append(point.longitude); - info.put(RingerDatabase.KEY_LOCATION, sb.toString()); - mListener.onInfoContentChanged(info); - } + updateLocation(point); } else Log.d(TAG, "onLocationSelected() Location was null"); } + /** + * Updates the location used in the database and notifies maintainer + * @param location + */ + private void updateLocation(LatLng location) { + if (mListener != null) { + final ContentValues info = new ContentValues(); + final StringBuilder sb = new StringBuilder(); + sb.append(location.latitude).append(",").append(location.longitude); + info.put(RingerDatabase.KEY_LOCATION, sb.toString()); + mListener.onInfoContentChanged(info); + } + } + /** * Updates the marker and the circle * @param point @@ -381,18 +389,36 @@ public class LocationInformationFragment extends Fragment implements LatLngListe mMarker.setPosition(point); } + /** + * Called at the start of a marker's drag cycle + * @param marker + */ @Override public void onMarkerDragStart(Marker marker) { - updateOverlay(marker.getPosition()); + final LatLng location = marker.getPosition(); + updateOverlay(location); + updateLocation(location); } + /** + * Called when a marker is being dragged + * @param marker + */ @Override public void onMarkerDrag(Marker marker) { - updateOverlay(marker.getPosition()); + final LatLng location = marker.getPosition(); + updateOverlay(location); + updateLocation(location); } + /** + * Called at the end of a marker's drag cycle + * @param marker + */ @Override public void onMarkerDragEnd(Marker marker) { - updateOverlay(marker.getPosition()); + final LatLng location = marker.getPosition(); + updateOverlay(location); + updateLocation(location); } } \ No newline at end of file