Socket
Book a DemoInstallSign in
Socket

com.github.brnunes:swipeablerecyclerview

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.github.brnunes:swipeablerecyclerview

Implementation of an Android CardView list in a RecyclerView that allows dismissing elements by swiping them to the left or right

1.0.2
Source
mavenMaven
Version published
Maintainers
1
Source

Android SwipeableRecyclerView

Based on romannurik`s Android-SwipeToDismiss.

Sample project implementation of a list of CardViews in a RecyclerView with a TouchListener that allows dismissing of elements by swiping the elements to the left or right.

Output sample

####How to use

  • Add these Gradle dependencies to your app's module:

    dependencies {
        ...
        
        // already includes 'com.android.support:recyclerview-v7:23.1.1'
        compile 'com.github.brnunes:swipeablerecyclerview:1.0.2'
    
        // only necessary if you are using CardView
        compile 'com.android.support:cardview-v7:23.1.1'
    }
    

The RecyclerView and CardView widgets are part of the v7 Support Libraries.

  • Instantiate a SwipeableRecyclerViewTouchListener passing as parameters the RecyclerView and a SwipeableRecyclerViewTouchListener.SwipeListener that will receive the callbacks.

  • Add the instantiated SwipeableRecyclerViewTouchListener as a RecyclerView.OnItemTouchListener.

    SwipeableRecyclerViewTouchListener swipeTouchListener =
            new SwipeableRecyclerViewTouchListener(mRecyclerView,
                    new SwipeableRecyclerViewTouchListener.SwipeListener() {
                        @Override
                        public boolean canSwipeLeft(int position) {
                            return true;
                        }
    
                        @Override
                        public boolean canSwipeRight(int position) {
                            return true;
                        }
    
                        @Override
                        public void onDismissedBySwipeLeft(RecyclerView recyclerView, int[] reverseSortedPositions) {
                            for (int position : reverseSortedPositions) {
                                mItems.remove(position);
                                mAdapter.notifyItemRemoved(position);
                            }
                            mAdapter.notifyDataSetChanged();
                        }
    
                        @Override
                        public void onDismissedBySwipeRight(RecyclerView recyclerView, int[] reverseSortedPositions) {
                            for (int position : reverseSortedPositions) {
                                mItems.remove(position);
                                mAdapter.notifyItemRemoved(position);
                            }
                            mAdapter.notifyDataSetChanged();
                        }
                    });
    
    mRecyclerView.addOnItemTouchListener(swipeTouchListener);
    

FAQs

Package last updated on 18 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.