DragSortRecycler icon indicating copy to clipboard operation
DragSortRecycler copied to clipboard

Drag and Drop with long click and Contextual Action Bar

Open ferrannp opened this issue 10 years ago • 1 comments

Is it possible with this library? I'll explain:

I have a list with some items that you can click on it (radio buttons) (so onItemClickListener and all that stuff will not work). When I long click any element inside my list row, I launch a Contextual Action Bar (when item selected).

My idea is to launch a drag action too (like startDraging(position). Something like:

    holder.radioButton.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {

            if (!isCAB()) { //No Contextual Action Bar
               getListView().setItemChecked(position, true); //Launch ActionMode
               getListView().startDrag(position); //HERE (launch drag too)
            }else {
                selectCABitem(checkedItems, position);
            }
            return true;
        }
    });

What I would do then is have a drag listener, if we drag an item to another position (even if we don't drop it yet), the contextual action bar will disappear, on the other hand, if we drop the element in the same position, then the CAB stays and you can continue selecting items. This is the default behaviour of Google Keep for example.

I think what is really needed is the ability to say "startDrag(position)" and having that listener... I was not really lucky for now with that libraries out there.

Looking at this library, the only way for launching a drag action is to give a id handler (like imageview)?

Thanks for your time!

ferrannp avatar Jan 07 '15 01:01 ferrannp

Hi, OK I think I know what you want, a way to progmatically start the drag operation? This should be possible, but won't you need to take your finger off the list item before the drag has finished? What is the overall functionally you're trying to achieve? Long press on the item then...

Thanks

emileb avatar Jan 10 '15 19:01 emileb