Skip to content

Commit

Permalink
refactor(#328): 선택된 노드가 다른 노드에 부착되는 함수 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
hegleB committed Mar 28, 2024
1 parent 2b010fe commit 35fc001
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions AOS/app/src/main/java/boostcamp/and07/mindsync/ui/view/NodeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class NodeView(
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
if (mindMapContainer.isMoving) {
stopNodeMovement()
updateTreeIfNodeAttached(event)
}
attachedNode = null
lineView.updateTree(tree)
Expand All @@ -80,6 +81,17 @@ class NodeView(
private fun stopNodeMovement() {
mindMapContainer.isMoving = false
}

private fun updateTreeIfNodeAttached(event: MotionEvent) {
mindMapContainer.selectNode?.let { selectedNode ->
findIncludedNode(event.x, event.y)
attachNode(selectedNode)
attachedNode?.let { attachedNode ->
mindMapContainer.update(tree, selectedNode, attachedNode)
}
}
}

private fun attachNode(selectedNode: Node) {
attachedNode?.let { attachedNode ->
tree.doPreorderTraversal { node ->
Expand Down

0 comments on commit 35fc001

Please sign in to comment.