Fixed marker drag now updates database

This commit is contained in:
2014-09-02 19:24:51 -04:00
parent c09a043d00
commit 5b7ba832f9

View File

@@ -358,15 +358,23 @@ public class LocationInformationFragment extends Fragment implements LatLngListe
if (mMap != null)
mMap.moveCamera(CameraUpdateFactory.newLatLng(point));
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(point.latitude).append(",").append(point.longitude);
sb.append(location.latitude).append(",").append(location.longitude);
info.put(RingerDatabase.KEY_LOCATION, sb.toString());
mListener.onInfoContentChanged(info);
}
} else
Log.d(TAG, "onLocationSelected() Location was null");
}
/**
@@ -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);
}
}