Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Moving canceled #338

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Moving canceled #338

wants to merge 2 commits into from

Conversation

ochkarik05
Copy link

I use the library for tree data structure. Before I start dragging item in tree-view, I must collapse selected view if it has some children.
Then I have to expand it again after dropping.

Example:

listView.setOnItemLongClickListener(
        new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(final AdapterView<?> parent, final View view,
                                           final int position, final long id) {
                myAdapter.setCollapsed(position);
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        listView.startDragging(position);
                    }
                }, 50);
                return true;
            }
        }
);

listView.setOnItemMovedListener(new OnItemMovedListener() {
    @Override
    public void onItemMoved(int to, int from) {
        myAdapter.setExpanded(from);
    }

});

listView.setOnItemMovingCanceledListener(new OnItemMovingCanceledListener() {
    @Override
    public void onItemMovingCanceled(int originalPosition) {
        myAdapter.setExpanded(originalPosition);
    }
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant