Skip to content

Difficulty restoring node tree display #1

@billthefarmer

Description

@billthefarmer

Thank you for this, it is very interesting. I have built an app using the library, but I am having difficulty with saving and restoring the tree with device rotation. Saving the tree is not a problem, restoring it into the tree seems to work OK, but I can't get the MindMapView to display the nodes correctly on restoration. If I do not call animateTreeChange() on restore the nodes are displayed in the top left corner with the lines drawn to that position. If I call animateTreeChange() on restore I can see the nodes and lines being animated, but the nodes are not drawn. How can I get the nodes displayed correctly?
This is in Java as I haven't learnt enough Kotlin to work out what's happening.

        tree = new Tree<>(this);
        if (savedInstanceState != null)
        {
            List<String> list = savedInstanceState.getStringArrayList(NODES);
            if (list != null)
            {
                for (String id: list)
                {
                    if (id == tree.getRootNode().getId())
                        continue;

                    Bundle bundle = savedInstanceState.getBundle(id);
                    if (bundle == null)
                        continue;

                    String parentId = bundle.getString(PARENT);
                    String content = bundle.getString(CONTENT);
                    tree.addNode(id, parentId, content);
                }
            }
        }

        mindMapView.setTree(tree);
        mindMapView.initialize();
        mindMapView.animateTreeChange();
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions