Skip to content
Set of plugable extenstions for Android RecyclerView
Branch: master
Clone or download
ismoli Merge pull request #7 from bryant1410/master
Fix broken headings in Markdown files
Latest commit 9e134dc Apr 17, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app readme updates Jan 5, 2015
core init Jan 5, 2015
.gitignore init Jan 5, 2015
DynamicRecyclerView.iml init Jan 5, 2015
LICENSE.md Create LICENSE.md Dec 30, 2014
README.md Fix broken Markdown headings Apr 16, 2017
build.gradle init Jan 5, 2015
gradle.properties init Jan 5, 2015
gradlew init Jan 5, 2015
gradlew.bat init Jan 5, 2015
settings.gradle

README.md

DynamicRecyclerView

Set of light and non-invasive extensions for Android RecyclerView widget. Does not use custom RecyclerView or LayoutManager. With this extensions you can create RecyclerView with following features:

Drag and drop reordering.

  • Implemented using RecyclerView.OnItemTouchListener
  • Support for custom "Drag frame" drawable
  • ~350 LOC
Usage:
    dragDropTouchListener = new DragDropTouchListener(recyclerView, this) {
        @Override
        protected void onItemSwitch(RecyclerView recyclerView, int from, int to) {
            adapter.swapPositions(from, to);
            adapter.notifyItemChanged(to);
            adapter.notifyItemChanged(from);
 
         @Override
         protected void onItemDrop(RecyclerView recyclerView, int position) {
        }
   };
   }
   
    recyclerView.addOnItemTouchListener(dragDropTouchListener);

Swipe to dismiss items

This is port of Roman Nurik's SwipeToDismiss for ListView

  • Implemented using RecyclerView.OnItemTouchListener
  • Configurable swipe directions: only left, only right, both, none
  • ~320 LOC
Usage:
 swipeToDismissTouchListener = new SwipeToDismissTouchListener(recyclerView, new SwipeToDismissTouchListener.DismissCallbacks() {
            @Override
           public SwipeToDismissTouchListener.SwipeDirection canDismiss(int position) {
               return SwipeToDismissTouchListener.SwipeDirection.RIGHT;
           }
            @Override
           public void onDismiss(RecyclerView view, List<SwipeToDismissTouchListener.PendingDismissData> dismissData) {
              for (SwipeToDismissTouchListener.PendingDismissData data : dismissData) {
                  adapter.removeItem(data.position);
                  adapter.notifyItemRemoved(data.position);
              }
           }
   });
  recyclerView.addOnItemTouchListener(swipeToDismissTouchListener);

Select/activate items

  • Small RecyclerViewAdapter extension that can keep a state of selected/activated items
Usage

Use as normal RecyclerView.Adapter

ItemTouchListenerAdapter

As RecyclerView does not have standard way to add click listeners to the items, this RecyclerView.OnItemTouchListener intercepts touch events and translates them to simple onItemClick() and onItemLongClick() callbacks.

Usage
    recyclerView.addOnItemTouchListener(new ItemTouchListenerAdapter(recyclerView, this));

Sample

Sample app code is included, please see DemoActivity.

For full featured demo of real app see /du:/ tasks app on Google Play Store

You can’t perform that action at this time.