emileb / dragsortrecycler Goto Github PK
View Code? Open in Web Editor NEWEasily add drag and drop capability to your RecyclerView
License: Apache License 2.0
Easily add drag and drop capability to your RecyclerView
License: Apache License 2.0
The getItemId in the sample code should not return position. If items are added or removed it will break the RecyclerView.
As stated in the README, the library does currently not support horizontal drag and drop. It would be a great addition to enable that feature.
Thank you for this very nice looking library!
Why not upload the library to maven, so we can use with gradle.
Hello,
I have implemented your DragSort Recycler in my RecyclerView. I am also trying to implement the SwipeRefreshLayout on the recyclerview..
The problem I am facing is when I long press and drag the view in downward motion, the SwipeRefreshLayout's setOnRefreshListener gets called preventing me from sorting the view items. I am able to move items in the upward motion.
Any suggestions on this would be very helpful
If the viewhandle is not visible, dragging should not happen. Also it would be nice if there could be a limit to where one could drag to. Working on that now though.
if (handleView == null)
{
Log.e(TAG, "The view ID " + viewHandleId + " was not found in the RecycleView item");
return false;
}
if(handleView.getVisibility()!=View.VISIBLE) {
return false;
}
At the moment, you are only allowed to drag items with a handler. A common and useful design pattern is also to be able to drag and drop items on long press on the item. Could it be possible to add this feature to your lib ? Thanks.
On random occasions items are "stuck" where you drop them as what seems like an image of the item in the "faded" situation it is (with alpha) when it's dragged.
If you scroll after the drop when it happens the RecyclerView and DragSort keeps working as intended but the "image" of the item that was dropped is kept on the same place on the screen.
Did anyone else experience this behavior or have any idea why it happens?
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!
Is there any reason you set the minSdkVersion to 15? I think you can lower it at least to 11.
Arno
Your lib works fine unless I call adapter,setHasStableIds(true), in which case my list completely screws up (duplicated items, missing items etc...).
So this is fine for me, I don't call it.
But I am curious about why you call it in you demo activity testdragsortrecycler ?
Is it important. Do I miss something if i don't call it? How to fix the problem if I have to call it?
The DragSortRecylcer is intercepting all touch events. I have a click listener defined for the itemView that will never be invoked (which seems to be the recommended way to handle click events for RecyclerView). That will probably require some changes to your code in order to distinguish between a click event and a drag event. Any idea on how to handle this?
Could you please recommend on the web a nice drag handler bitmap to put on the left of the item?
Hi,
Whenever I drag and drop. The list is back to original position. FYI I use recyclerview adapter with cursor adapter support. But I am not so sure if the adapter is the cause of the problem
I have encountered this issue while playing testing it in a demo project. The details are as below:
My UI Layout:
Steps that I used to reproduce:
BTW thanks for your time in making this.
I had try couple of hours till now. Still cant integrate with HashMap<String, String>. Can you show me an example ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.