Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag & Drop in a GridLayoutManager #3

Closed
ruckus opened this issue Mar 3, 2015 · 4 comments
Closed

Drag & Drop in a GridLayoutManager #3

ruckus opened this issue Mar 3, 2015 · 4 comments

Comments

@ruckus
Copy link

ruckus commented Mar 3, 2015

Thanks for the fantastic library.

I'm trying to implement drag-and-drop with a GridLayoutManager.

In my Activity.onCreate I have declared the grid:

recyclerView.setLayoutManager(new GridLayoutManager(this, 2));

And I do get a grid of 2 columns. However, when I go into drag-and-drop mode I can only move within the column, I cannot move left or right.

I'm pretty sure I need to muck around in DragDropTouchListener.switchViewsIfNeeded but I'm not sure.

Any suggestions on how to tackle this? Thanks!

@ismoli
Copy link
Owner

ismoli commented Mar 5, 2015

I wasn't actually testing it with GridLayoutManager as this lib is more like example of what could be done, however first thing you should look at is that views are only move by Y axis, so you'd need to change this... that probably would be enough..

@ruckus
Copy link
Author

ruckus commented Mar 5, 2015

Thank you for the suggestion, that was what I needed. I successfully implemented X/Y axis dragging/dropping. You were right - I just needed to account for the X axis movement.

Here is a Gist to my listener.

https://gist.github.com/ruckus/a4f831d8dce785c91aed

If you would like me to fork your repo and provide a pull-request with this addition then just let me know.

Thanks again!

@ismoli
Copy link
Owner

ismoli commented Mar 6, 2015

Hi, great, yes, I believe community will benefit if you provide implementation for a GridLayout, thanks!

@ismoli ismoli closed this as completed Mar 6, 2015
@danksky
Copy link

danksky commented Jul 20, 2015

Hello, I'm very rookie when it comes to pulling off other projects' APIs and implementing some of their code into my own. I want to include features for my RecyclerView like bringing up a contextual action bar with ease upon long clicking a card, or swiping cards to archive them. I don't understand how I can implement your code to my own so that I can design a new function for, say, swiping, so that the swiped card does what { I } desire to do, but with the ease that your sample code shows. Please help or set me in the right direction?

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

No branches or pull requests

3 participants