diff --git a/library/src/main/java/com/mindsync/library/MindMapView.kt b/library/src/main/java/com/mindsync/library/MindMapView.kt index 68b9bae..e395030 100644 --- a/library/src/main/java/com/mindsync/library/MindMapView.kt +++ b/library/src/main/java/com/mindsync/library/MindMapView.kt @@ -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() diff --git a/library/src/main/java/com/mindsync/library/NodeMoveListener.kt b/library/src/main/java/com/mindsync/library/NodeMoveListener.kt new file mode 100644 index 0000000..1d4c207 --- /dev/null +++ b/library/src/main/java/com/mindsync/library/NodeMoveListener.kt @@ -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<*>, + ) +} \ No newline at end of file diff --git a/library/src/main/java/com/mindsync/library/NodeView.kt b/library/src/main/java/com/mindsync/library/NodeView.kt index c9ef4a0..0a13ad8 100644 --- a/library/src/main/java/com/mindsync/library/NodeView.kt +++ b/library/src/main/java/com/mindsync/library/NodeView.kt @@ -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) @@ -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) } }