Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed annotation dragging behavior #25

Merged
merged 1 commit into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public T create(S options) {
T t = options.build(currentId, this);
annotations.put(t.getId(), t);
currentId++;
updateSource();
internalUpdateSource();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RomanBapst What is the reason you changed updateSource() to internalUpdateSource() here? It undoes the improvements from #12.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the drag event of an annotation was stopped when there was a state update
of any annotion. This made it impossible to drag an annotation while updating
anything else on the map.

return t;
}

Expand All @@ -155,7 +155,7 @@ public List<T> create(List<S> optionsList) {
annotations.put(annotation.getId(), annotation);
currentId++;
}
updateSource();
internalUpdateSource();
return annotationList;
}

Expand All @@ -167,7 +167,8 @@ public List<T> create(List<S> optionsList) {
@UiThread
public void delete(T annotation) {
annotations.remove(annotation.getId());
updateSource();
draggableAnnotationController.onAnnotationUpdated(annotation);
internalUpdateSource();
}

/**
Expand All @@ -179,8 +180,9 @@ public void delete(T annotation) {
public void delete(List<T> annotationList) {
for (T annotation : annotationList) {
annotations.remove(annotation.getId());
draggableAnnotationController.onAnnotationUpdated(annotation);
}
updateSource();
internalUpdateSource();
}

/**
Expand All @@ -201,7 +203,8 @@ public void deleteAll() {
public void update(T annotation) {
if (annotations.containsValue(annotation)) {
annotations.put(annotation.getId(), annotation);
updateSource();
draggableAnnotationController.onAnnotationUpdated(annotation);
internalUpdateSource();
} else {
Logger.e(TAG, "Can't update annotation: "
+ annotation.toString()
Expand All @@ -218,8 +221,9 @@ public void update(T annotation) {
public void update(List<T> annotationList) {
for (T annotation : annotationList) {
annotations.put(annotation.getId(), annotation);
draggableAnnotationController.onAnnotationUpdated(annotation);
}
updateSource();
internalUpdateSource();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ void removeAnnotationManager(AnnotationManager annotationManager) {
}
}

void onAnnotationUpdated(Annotation annotation) {
if (annotation == draggedAnnotation) {
stopDragging(draggedAnnotation, draggedAnnotationManager);
}
}

void onSourceUpdated() {
stopDragging(draggedAnnotation, draggedAnnotationManager);
}
Expand Down
Loading