Skip to content

Unbound Drag & Drop enhances your Android apps by enabling drag and drop across multiple RecyclerViews, unlike the default single RecyclerView restriction. This feature allows users to seamlessly move items between different RecyclerViews, offering a more flexible and intuitive user experience.

License

Notifications You must be signed in to change notification settings

AdrianKuta/Unbound-Drag-Drop

Repository files navigation

Unbound Drag & Drop

Maven Central Version License: MIT

Unbound.Drag.Drop.webm

Unbound Drag & Drop is a versatile and user-friendly feature designed to enhance your Android applications by enabling drag and drop functionality across multiple RecyclerViews. Unlike the default behavior, which restricts drag and drop actions within a single RecyclerView, Unbound Drag & Drop allows users to seamlessly move items between different RecyclerViews, providing a more flexible and intuitive user experience.

Features

  • Multi-RecyclerView Drag and Drop: Easily drag and drop items between multiple RecyclerViews.
  • Customizable and Extensible: Adapt the feature to fit your specific needs with customizable options and extensible components.
  • Smooth and Intuitive User Experience: Enhance the interactivity of your app with a user-friendly drag and drop interface.
  • Easy Integration: Quickly integrate Unbound Drag & Drop into your existing Android projects with minimal setup.

Installation

To include Unbound Drag & Drop in your project, add the following dependency to your build.gradle file:

implementation("dev.adriankuta:unbound-drag-drop:0.1.0")

Usage

Setup

Step 1: Implement the Callback

Create a class that extends DragDropHelper.Callback to handle drag and drop events.

class MyDragDropCallback : DragDropHelper.Callback() {
    override fun onMove(
        recyclerView: RecyclerView,
        viewHolder: RecyclerView.ViewHolder,
        targetRecyclerView: RecyclerView,
        targetViewHolder: RecyclerView.ViewHolder?
    ): Boolean {
        // Handle the move logic here
        return true
    }

    override fun onMoved(
        recyclerView: RecyclerView,
        viewHolder: RecyclerView.ViewHolder,
        targetRecyclerView: RecyclerView,
        targetViewHolder: RecyclerView.ViewHolder?
    ) {
        // Handle post-move logic here
    }
}

Step 2: Attach DragDropHelper to RecyclerView

In your Activity or Fragment, attach DragDropHelper to your RecyclerView.

val recyclerView: RecyclerView = findViewById(R.id.recycler_view)
val dragDropHelper = DragDropHelper(MyDragDropCallback())
dragDropHelper.attachToRecyclerView(recyclerView)

Step 3: Enable long click

Dragging is enabled only for views with long click enabled. To allow dragging and dropping of RecyclerView items, you need to set isLongClickable to true for each RecyclerView item.

viewHolder.itemView.isLongClickable = true

See example in app module.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss any changes.

About

Unbound Drag & Drop enhances your Android apps by enabling drag and drop across multiple RecyclerViews, unlike the default single RecyclerView restriction. This feature allows users to seamlessly move items between different RecyclerViews, offering a more flexible and intuitive user experience.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages