Pumped up RecyclerView

Overview

Maven Central Build Status Android Arsenal

##Description

This is an attempt to make RecyclerView easier to use.

Features built in:

  • ProgressBar while adapter hasn't been set
  • EmptyView if adapter is empty
  • SwipeRefreshLayout (Google's one)
  • Infinite scrolling, when you reach the X last item, load more of them.
  • Swipe To Dismiss or Swipe To Remove
  • Sticky headers (via Eowise, see sample)

##Integration

Just add it to you dependencies

    compile 'com.malinskiy:superrecyclerview:$version'

##Usage

  • Use directly SuperRecyclerView:
   <com.malinskiy.superrecyclerview.SuperRecyclerView
            android:id="@+id/list"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_empty="@layout/emptyview"
            app:layout_moreProgress="@layout/view_more_progress"
            app:mainLayoutId="@layout/layout_recyclerview_verticalscroll"
            app:recyclerClipToPadding="false"
            app:recyclerPadding="16dp"
            app:scrollbarStyle="insideInset"/>
  • Current Attributes supported:
    <attr name="layout_empty" format="reference"/>
    <attr name="layout_moreProgress" format="reference"/>
    <attr name="layout_progress" format="reference"/>
    <attr name="recyclerClipToPadding" format="boolean"/>
    <attr name="recyclerPadding" format="dimension"/>
    <attr name="recyclerPaddingTop" format="dimension"/>
    <attr name="recyclerPaddingBottom" format="dimension"/>
    <attr name="recyclerPaddingLeft" format="dimension"/>
    <attr name="recyclerPaddingRight" format="dimension"/>
    <attr name="scrollbarStyle">
        <flag name="insideOverlay" value="0x0"/>
        <flag name="insideInset" value="0x01000000"/>
        <flag name="outsideOverlay" value="0x02000000"/>
        <flag name="outsideInset" value="0x03000000"/>
    </attr>

    <attr name="mainLayoutId" format="reference"/>

##SuperRecyclerView Java Usage

    recycler.setRefreshListener(new SwipeRefreshLayout.OnRefreshListener {
      @Override
      public void onRefresh() {
          // Do your refresh
      });

    // when there is only 10 items to see in the recycler, this is triggered
    recycler.setupMoreListener(new OnMoreListener() {
      @Override
      public void onMoreAsked(int numberOfItems, int numberBeforeMore, int currentItemPos) {
        // Fetch more from Api or DB
      }}, 10);

    recycler.setupSwipeToDismiss(new SwipeDismissListViewTouchListener.DismissCallbacks() {
      @Override
      public boolean canDismiss(int position) {
        return true
      }

      @Override
      public void onDismiss(RecyclerView recyclerView, int[] reverseSortedPositions) {
        // Do your stuff like call an Api or update your db
      }});

##Scrollbars RecyclerView currently doesn't support setting scrollbars from code that's why I can't parse custom attributes. You have to use appropriate mainLayoutId attribute to have scrollbars visible.

Vertical scrollbars

<com.malinskiy.superrecyclerview.SuperRecyclerView
     app:mainLayoutId="@layout/layout_recyclerview_verticalscroll"
     app:scrollbarStyle="insideInset"
     .../>

Horizontal scrollbars

<com.malinskiy.superrecyclerview.SuperRecyclerView
     app:mainLayoutId="@layout/layout_recyclerview_horizontalscroll"
     app:scrollbarStyle="insideInset"
     .../>

##Swipe layout

  1. You should always assign android:id to @id/recyclerview_swipe. Note that it's a reference to an already defined id, so don't use @+id

  2. The SwipeLayout can only have 2 children that are instances of ViewGroup, e.g. LinearLayout, RelativeLayout, GridLayout

  3. The first child is the bottom view, the second child is the top view

  4. Your adapter should extend BaseSwipeAdapter class

  5. Do not setup swipe to dismiss and use swipe layout at the same time. If you do - a kitten will cry somewhere.

Item example:

<com.malinskiy.superrecyclerview.swipe.SwipeLayout
    android:id="@id/recyclerview_swipe"
    xmlns:swipe="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    swipe:horizontalSwipeOffset="16dp">

    <LinearLayout
        ...
    </LinearLayout>

    <LinearLayout
        ...
    </LinearLayout>

</com.malinskiy.superrecyclerview.swipe.SwipeLayout>

Custom attributes supported:

    <attr name="drag_edge" format="enum">
        <enum name="left" value="0"/>
        <enum name="right" value="1"/>
        <enum name="top" value="2"/>
        <enum name="bottom" value="3"/>
    </attr>
    <attr name="horizontalSwipeOffset" format="dimension"/>
    <attr name="verticalSwipeOffset" format="dimension"/>
    <attr name="show_mode" format="enum">
        <enum name="lay_down" value="0"/>
        <enum name="pull_out" value="1"/>
    </attr>

####Sample java

Proguard

-dontwarn com.malinskiy.superrecyclerview.SwipeDismissRecyclerViewTouchListener*

##Thanks Jake Warthon for implementation of SwipeToDismiss via NineOldAndroids

Eowise for implementation of sticky headers

Quentin Dommerc for inspiration

代码家 for swipe layout implementation

##License

Copyright (c) 2016 Anton Malinskiy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Come on, don't tell me you read that.
Comments
  • OnMoreListener gets triggerred when scrolling up

    OnMoreListener gets triggerred when scrolling up

    I am trying to user super recycler view to load a list of messages from the server and when I reach the end of pages and start scrolling up again a call is getting triggered to load more messages.

    opened by chaitanya79 7
  • Infinite more loading

    Infinite more loading

    Hi, I can't figure out how to specify when to load more items to the list. And how to stop this process. It starts loading more after short up swipe and never stops.

    opened by yarolegovich 4
  • How to remove circular progress bar at bottom of recyclerview

    How to remove circular progress bar at bottom of recyclerview

    I am using recycler view inside fragment after loading data the circular progress bar is still visible at bottom . I want after loading data the circular progress bar hides this is my fragment layout please help me

      <?xml version="1.0" encoding="utf-8"?>
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
        android:layout_height="match_parent">
    
    <com.malinskiy.superrecyclerview.SuperRecyclerView
      android:id="@+id/list"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      app:recyclerClipToPadding="false"
      app:recyclerPadding="16dp"
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
    />
    </RelativeLayout>
    
    opened by sachinrana028 3
  • NullPointerExecption in RecyclerView when calling stopScroll() method

    NullPointerExecption in RecyclerView when calling stopScroll() method

    Hi,

    So me and the team have been using this library for our project and after a while we runned into the situation stated in this StackOverflow Question: http://stackoverflow.com/a/26908738 Our app started crashing randomly giving this error:

    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView$LayoutManager.stopSmoothScroller()' on a null object reference
    

    Then we noticed it was happening mainly when returning back to a SuperRecyclerView that was empty but know needed to display some content. But the issue happen on other situations that required the initialization of the SuperRecyclerView.

    We solved it by applying the solution given in the SA Question in a forked version of this library, ending up replacing the RecyclerView variable for HotFixRecyclerView in the SuperRecyclerView class and layouts. Can you introduce this error handling in the library? Or do you have other suggestion on how to bypass this issue?

    Thanks, and great work with the library!

    opened by tiagomota 3
  • SwipeRefreshLayout not working in some situations

    SwipeRefreshLayout not working in some situations

    SwipeRefreshLayout is not working in some situations. Check this google's bug, already fixed but will be released in next support libs release. https://code.google.com/p/android/issues/detail?id=78191

    opened by alexfacciorusso 3
  • ItemAnimation has no effect

    ItemAnimation has no effect

    I'm trying to add ItemAnimations and there seem to be no effect. I tried .getRecyclerView.addItemAnimator() Even the default ItemAnimator has no effect

    opened by TinasheMzondiwa 3
  • Proguard setup

    Proguard setup

    I have minifyEnabled on my project and I get:

    Warning:com.malinskiy.superrecyclerview.SwipeDismissRecyclerViewTouchListener$1: can't find referenced class com.malinskiy.superrecyclerview.SwipeDismissRecyclerViewTouchListener
    Warning:com.malinskiy.superrecyclerview.SwipeDismissRecyclerViewTouchListener$DismissCallbacks: can't find referenced class com.malinskiy.superrecyclerview.SwipeDismissRecyclerViewTouchListener
    

    Can you show me a proguard setup to use this library?

    opened by danielgomezrico 2
  • set progress bar

    set progress bar

    Hi, is there a way to set a custom progress bar for the library?

    I wanted to use com.pnikosis.materialishprogress.ProgressWheel with SuperRecyclerView but didn't figure out how?

    Thanks

    opened by ghost 2
  • Item selector

    Item selector

    How can I use an item selector with SuperRecyclerView? I tried to set a background of my item view to '?android:activatedBackgroundIndicator' but nothing happens =(

    opened by Zeliret 2
  • enable / disable android attribute for layout_moreProgress

    enable / disable android attribute for layout_moreProgress

    For example if I need to remove or disable the features like swipe to refresh , more progress bar or any other attribute we need Attributes or at least programmatical way to do that

    Thanks

    opened by LOG-TAG 2
  • Disable refresh.

    Disable refresh.

    Hi,

    I'm using refresh feature only when failed to retrieve data from a network source and disabling it when data has been received. Calling setRefreshListener(null) should disable the listener instead of enabling it.

    opened by Wolftein 2
  • Bug when implementing ItemTouchHelper

    Bug when implementing ItemTouchHelper

    I am working on RecyclerView swipe to delete and my RecyclerView is in a fragment with Bottom Navigation and everything is going well but sometimes swipe stops and gets stuck motionless so I can't completely swipe the item nor it's recoverable.

    I have attached my custom ItemTouchHelper to the super recyclerview. In this custom ItemTouchHelper.Callback implementation, I have two separate functions for right-left swipe. When the swipe is stuck, onSwiped() is never called...

    opened by Harshal624 0
  • Reverse LayoutManager but More Progress still in BOTTOM

    Reverse LayoutManager but More Progress still in BOTTOM

    i set the true the reverse properties in layout manager

    layoutManager =new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.VERTICAL, true);

    but More Progress still in Bottom.

    im trying to create List Chat

    opened by blastering66 0
  • Bug in OnMoreListener

    Bug in OnMoreListener

    opened by ravi7874 3
Releases(v1.1.4)
Owner
Anton Malinskiy
Anton Malinskiy
A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView.

RecyclerViewSwipeDismiss A very easy-to-use and non-intrusive implement of Swipe to dismiss for RecyclerView. Preview How to use Add these lines to yo

xcodebuild 431 Nov 23, 2022
. Android library that integrate sticky section headers in your RecyclerView

recyclerview-stickyheaders Recyclerview-stickyheaders is an Android library that makes it easy to integrate section headers in your RecyclerView. Thes

null 968 Nov 10, 2022
An adapter which could be used to achieve a parallax effect on RecyclerView.

android-parallax-recycleview Integration Step 1. Add the JitPack repository to your build file repositories { maven { url "https://jitpack

Pedro Oliveira 1.6k Nov 17, 2022
An Android Animation library which easily add itemanimator to RecyclerView items.

RecyclerView Animators RecyclerView Animators is an Android library that allows developers to easily create RecyclerView with animations. Please feel

Daichi Furiya 11.2k Jan 5, 2023
Android library providing simple way to control divider items (ItemDecoration) of RecyclerView

RecyclerView-FlexibleDivider Android library providing simple way to control divider items of RecyclerView Release Note [Release Note] (https://github

Yoshihito Ikeda 2.4k Dec 18, 2022
A Fast Scroller for the RecyclerView world!

RecyclerViewFastScroller The RecyclerViewFastScroller is a widget that can be added to a layout and connected to a RecyclerView for fast scrolling. Th

Daniel Smith 1.1k Dec 19, 2022
Android library defining adapter classes of RecyclerView to manage multiple view types

RecyclerView-MultipleViewTypeAdapter RecyclerView adapter classes for managing multiple view types Release Note [Release Note] (https://github.com/yqr

Yoshihito Ikeda 414 Nov 21, 2022
*** WARNING: This library is no longer maintained *** An easy way to add a simple 'swipe-and-do-something' behavior to your `RecyclerView` items. Just like in Gmail or Inbox apps.

SwipeToAction An easy way to add a simple 'swipe-and-do-something' behavior to your RecyclerView items. Just like in Gmail or Inbox apps. Integration

Victor Calvello 223 Nov 16, 2022
RecyclerView extension library which provides advanced features. (ex. Google's Inbox app like swiping, Play Music app like drag and drop sorting)

Advanced RecyclerView This RecyclerView extension library provides Google's Inbox app like swiping, Play Music app like drag-and-drop sorting and expa

Haruki Hasegawa 5.2k Dec 23, 2022
ItemDecoration for RecyclerView using LinearLayoutManager for Android

RecyclerItemDecoration RecyclerItemDecoration allows you to draw divider between items in recyclerview with multiple ViewType without considering item

magiepooh 328 Dec 27, 2022
[UNMAINTAINED] Sticky Headers decorator for Android's RecyclerView

This project is no longer being maintained sticky-headers-recyclerview This decorator allows you to easily create section headers for RecyclerViews us

timehop 3.7k Dec 31, 2022
Pumped up RecyclerView

##Description This is an attempt to make RecyclerView easier to use. Features built in: ProgressBar while adapter hasn't been set EmptyView if adapter

Anton Malinskiy 2.6k Dec 21, 2022
Kotlin way of building RecyclerView Adapter 🧩. You do not have to write RecyclerView Adapters again and again and suffer from handling of different view types. Kiel will help you.

Kiel Kiel is a RecyclerView.Adapter with a minimalistic and convenient Kotlin DSL which provides utility on top of Android's normal RecyclerView.Adapt

ibrahim yilmaz 370 Jan 2, 2023
Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.

Carousel Recyclerview Create carousel effect in recyclerview with the CarouselRecyclerview in a simple way. Including in your project Gradle Add below

Jack and phantom 514 Jan 8, 2023
A RecyclerView that implements pullrefresh and loadingmore featrues.you can use it like a standard RecyclerView

XRecyclerView a RecyclerView that implements pullrefresh , loadingmore and header featrues.you can use it like a standard RecyclerView. you don't need

XRecyclerView 5.3k Dec 26, 2022
ANDROID. ChipsLayoutManager (SpanLayoutManager, FlowLayoutManager). A custom layout manager for RecyclerView which mimicric TextView span behaviour, flow layouts behaviour with support of amazing recyclerView features

ChipsLayoutManager This is ChipsLayoutManager - custom Recycler View's LayoutManager which moves item to the next line when no space left on the curre

Oleg Beloy 3.2k Dec 25, 2022
A RecyclerView that implements pullrefresh and loadingmore featrues.you can use it like a standard RecyclerView

XRecyclerView a RecyclerView that implements pullrefresh , loadingmore and header featrues.you can use it like a standard RecyclerView. you don't need

XRecyclerView 5.3k Dec 26, 2022
Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.

Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.

Jack and phantom 504 Dec 25, 2022
RecyclerView : SleepQualityTracker with RecyclerView app

RecyclerView - SleepQualityTracker with RecyclerView app SleepQualityTracker with RecyclerView This app builds on the SleepQualityTracker developed pr

Kevin 2 May 14, 2022