askerov/DynamicGrid

startEditMode() vs startEditMode(int)

fhur opened this issue · 11 comments

fhur commented

I fail to find any differences betweenstartEditMode() and startEditMode(int).

startEditMode(int) starts a drag operation from the position indicated by the param.

fhur commented

Could you explain what exactly that means? I thought it meant that if you (for example) long pressed on an item in the grid view, you could start dragging it right away, but It does not seem to work that way.
Also it makes all items draggable.

That is how it works for me. If I long press an item edit mode starts and it becomes draggable immediately.

If you call startEditMode() all items will become active (will vibrate) and you'll need to pick an item to start dragging. If you call startEditMode(int x) then you can start dragging item x right away. For example:
Grid positions (for 3x3 grid):
0 1 2
3 4 5
6 7 8
startEditMode(5) will allow you to start dragging item 5 (last in the second row) immediately.

fhur commented

For some reason I just can't get this to work. This is the code I'm using:

    @Override
    public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
        myCustomGrid.startEditMode(position);
        return true;
    }

When I long press it just 'enables' edit mode, but it does not allow dragging right away.

That's weird, I have exactly the same onItemLongClick listener in my project and it works.
Do you have different items in your Adapter (so there are no 2 equal items)?

fhur commented

Different items in my adapter? Not sure what you mean but I don't think so, I just extended AbstractDynamicGridAdapter

For instance if you have 2 strings with same content as items of your adapter (like "hello", "hello") it won't work. Some discussion about this issue is in #25. Not sure if it is relevant to your problem, but probably worth checking.

fhur commented

Ok after struggling for some days I decided to dig in into the sources. It turns out that the long press + drag is only possible when you have called setOnDragListener. @denisk20 do you know if this behavior is documented? if not, I will fork and add some documentation to prevent this from happening in the future.

By the way @denisk20, thanks a lot for the heads up referring to issue #25, it wasn't my case but nevertheless good to know.

@fernando You're very right regarding setOnDragListener, there is an
issue #27 which I have forgotten about. It would be great indeed if someone
had documented it.
On Oct 24, 2014 7:42 PM, "Fernando" notifications@github.com wrote:

Ok after struggling for some days I decided to dig in into the sources. It
turns out that the long press + drag is only possible when you have called
setOnDragListener. @denisk20 https://github.com/denisk20 do you know if
this behavior is documented? if not, I will fork and add some documentation
to prevent this from happening in the future.


Reply to this email directly or view it on GitHub
#42 (comment).

fhur commented

Given that this is the same issue as #27 I'm going to close it.