Skip to content

Commit

Permalink
feat: NodeMoveListener 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
hegleB committed Apr 19, 2024
1 parent b730584 commit 87a10cb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/src/main/java/com/mindsync/library/MindMapView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ class MindMapView @JvmOverloads constructor(
nodeView.listener = nodeClickListener
}

fun setNodeMoveListener(nodeMoveListener: NodeMoveListener) {
nodeView.moveListener = nodeMoveListener
}

private fun updateNodeAndLine() {
nodeView.update()
lineView.update()
Expand Down
12 changes: 12 additions & 0 deletions library/src/main/java/com/mindsync/library/NodeMoveListener.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.mindsync.library

import com.mindsync.library.data.NodeData
import com.mindsync.library.data.Tree

interface NodeMoveListener {
fun onMoveListener(
tree: Tree<*>,
target: NodeData<*>,
parent: NodeData<*>,
)
}
3 changes: 3 additions & 0 deletions library/src/main/java/com/mindsync/library/NodeView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class NodeView @JvmOverloads constructor(
private val rightLayoutManager = MindMapRightLayoutManager()
private val mindMapAnimator = MindMapAnimator()
var listener: NodeClickListener? = null
var moveListener: NodeMoveListener? = null
override fun onDraw(canvas: Canvas) {
super.onDraw(canvas)
drawAttachedNode(canvas)
Expand Down Expand Up @@ -105,8 +106,10 @@ class NodeView @JvmOverloads constructor(
mindMapManager.getTree().doPreorderTraversal { node ->
if (node.id == attachedNode.id) {
mindMapManager.getTree().attachNode(selectedNode.id, attachedNode.id)

}
}
this.moveListener?.onMoveListener(mindMapManager.getTree(), selectedNode, attachedNode)
}
}

Expand Down

0 comments on commit 87a10cb

Please sign in to comment.