Handy library to integrate pagination, which allow no data layout, refresh layout, recycler view in one view and easy way to bind pagination in app.

Overview

Pagination View

Handy library to integrate pagination, which allow no data layout, refresh layout, recycler view in one view and easy way to bind pagination in app.

Features

The Pagination View is combination of Refresh Layout, No Data Layout Container, And Recycler View which enable all funcnality in single view by using this view, You can do the following things:

  1. Support for Refresh Callbacks
  2. Support for No Data Layout
  3. Support for RecyclerView

We are using Paginate Library which enables the following features.

  • Pagination(infinite scrolling) by using PaginationBinder
  • Custom loading view
  • Custom Span Spacing for loading view
  • Custom loading trigger threshold

Demo - Pagination View

Pagination View & Custom Loading

Pagination View & Custom Loading

Pagination View & Refresh Layout

Pagination View & Refresh Layout

Pagination View & No Data Layout

Pagination View & No Data Layout

Usage

Add to Project

add the below to your app's build.gradle:

    implementation 'com.dhiwise.paginationView - TODO UPDATE'

Step 1: Create PaginationView in XML

<com.dhiwise.paginationview.pagination.view.PaginationView
            android:id="@+id/paginationView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:image="@drawable/ic_no_data_found"
            app:listLayoutManager="linear"
            app:title="@string/msg_no_data_found"
            app:itemSpacing="12dp"
            />

Attributes

Attribute Name Default Allowed Values Description
title - string no data layout title
message No data found... string no data layout message
titleTextColor BLACK color no data layout title text color
messageTextColor BLACK color no data layout message text color
titleTextSize - dimension no data layout title text size
messageTextSize - dimension no data layout message text size
noDataVewBg WHITE color no data layout background color
customNoDataVew empty_view_layout xml reference layout custom no data layout : Note that the custom layout must having views like imgNoData => ImageView and lblNoDataFound,lblMsgNoDataFound => TextView
imageUrl - string internet url of no data found image
image - drawable drawable image of no data layout
listLayoutManager linear enum(linear,grid,staggered) recycler view layout manager
spanCount 2 integer span count of grid or staggered layout manager
itemSpacing - dimension to provide spacing between list item

Step 2: Implement PageBindingCallback interface in your Fragment or Activity And override the interface methods

public class YourActivity : AppCompatActivity(),
    PageBindingCallback {

   private var paginationBinder: PaginationBinder? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_layout)
    }

    override fun onLoadNext(
        newPageToLoad: Int,
        currentLoadedItemCnt: Int,
        pageElementCount: Int
    ) {
        //TODO handle load next page
    }

    override fun onNoDataFound() {
        //TODO handle on No data loaded
    }

    override fun onAllItemLoaded() {
        //TODO handle on data loaded
    }

    override fun getPaginationView(): PaginationView {
        return paginationView //the pagination view object
    }
}

Step 3: Setup adapter and bind the PageBindingCallback

    paginationView.adapter = recyclerListViewAdapter

    paginationBinder =
         PaginationBinder.buildWith(pageElementCount, this)
                    .setOnRefresh {
                      //TODO handle the refresh callback
                    }
                    .build()

How to manage the page loading or refresh layout loading ?

    //update the list and then call notify dataset change
    paginationView.adapter?.notifyDataSetChanged()

    //call onLoadFinish of paginationBinder and pass the latest list element size count
    paginationBinder?.onLoadFinish(updatedListSize)

How do I manage no data layout ?

    //When onLoadNext function called and at that time if you get empty list size from api or your dataset then just pass the empty list size
    paginationBinder.onLoadFinish(listSize)

    //directly you want to show no data layout just pass zero
    paginationBinder.onLoadFinish(0)

    //you can do the same thing by using paginationView just call isNothingToLoad method with true as boolean argument.
    paginationView.isNothingToLoad(true)

How do I implement custom no data layout ?

To modify no data layout you can implement the custom no data layout xml file in PaginationView, or you can also set the layout xml file in setNoDataLayoutRes method of PaginationOption which you can implement it when we are building the PaginationBinder object.

using PaginationView

    paginationView.setNoDataLayoutRes(R.layout.your_no_data_layout)

using PaginationOption

    paginationBinder = PaginationBinder.buildWith(pageElementCount, this)
         .setNoDataLayoutRes(R.layout.your_no_data_layout)
         .build()

How do I implement custom loading view ?

To add custom loading view you can use setCustomLoadingItemHelper method of PaginationOption which you can implement it when we are building the PaginationBinder object.

    paginationBinder = PaginationBinder.buildWith(pageElementCount, this)
         .setCustomLoadingItemHelper(object :
                   CustomLoadingItemHelper(R.layout.your_loading_item) {
                   override fun onItemBind(layout: View) {
                       //manage your layout views here for showing custom message at loading time
                       //or anything you want
                   }
               })
         .build()

How to manage span for loading view when recycler layout manager is type of staggered or grid ?

First of all don't manage span for full width of custom loading view it will automatically managed, but if you want to manage span for the special condition then implement the following.

    paginationBinder = PaginationBinder.buildWith(pageElementCount, this)
         .setOnLoadingItemSpanCountCallback {
                    val spanSize = 1 // your span size of LoadingView
                    spanSize
                }
         .build()
You might also like...
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.

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

[] Super fast and easy way to create header for Android RecyclerView

DEPRECATED I created this library back in the day when I thought RecyclerView was all new and difficult. Writing an adapter that could inflate multipl

ANDROID. ChipsLayoutManager (SpanLayoutManager, FlowLayoutManager). A custom layout manager for RecyclerView which mimicric TextView span behaviour, flow layouts behaviour with support of amazing recyclerView features
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

A Common RecyclerView.Adapter  implementation which supports all kind of items and has useful data operating APIs such as remove,add,etc.
A Common RecyclerView.Adapter implementation which supports all kind of items and has useful data operating APIs such as remove,add,etc.

##PowerfulRecyclerViewAdapter A Common RecyclerView.Adapter implementation which supports any kind of items and has useful data operating APIs such as

A customizable and easy-to-use Timeline View library for Android
A customizable and easy-to-use Timeline View library for Android

TimelineView A customizable and easy-to-use Timeline View library for Android Can be used as a standalone view or as a RecyclerView decorator Setup 1.

A flexible view for providing a limited rect window into a large data set,just like a two-dimensional RecyclerView.  It different from RecyclerView is that it's two-dimensional(just like a Panel) and it pin the itemView of first row and first column in their original location. Android library providing simple way to control divider items (ItemDecoration) of RecyclerView
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

RecyclerView extension library which provides advanced features. (ex. Google's Inbox app like swiping, Play Music app like drag and drop sorting)
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

RecyclerView with DiffUtil is a way to improve the performance of your app
RecyclerView with DiffUtil is a way to improve the performance of your app

RecylerViewSamples RecyclerView with DiffUtil is a way to improve the performanc

Owner
DhiWise
The ultimate open-source hub of Node.js code generation
DhiWise
Custom Layout Manager for Recycler View

Circular Layout Manager Overview A library for Android which essentially contains a Custom Layout Manager for Recycler View which lays out its child v

Kapilesh Iyer 181 Dec 2, 2022
Examples of custom recycler view items. Automatically detecting a dominant color of an image using Picasso and Palette libraries

custom-image-list-item Examples of custom RecyclerView items using Data Binding Features: Loading images urls with the help of a Picasso library Autom

Alina Stepanova 2 Sep 12, 2022
A couple of sticky header decorations for android's recycler view.

DEPRECATION NOTICE This library has not been touched in a very long time and many things have changed in the android ecosystem since then. Updating an

Eduardo Barrenechea 879 Nov 26, 2022
A couple of sticky header decorations for android's recycler view.

DEPRECATION NOTICE This library has not been touched in a very long time and many things have changed in the android ecosystem since then. Updating an

Eduardo Barrenechea 879 Nov 26, 2022
A custom recycler view with shimmer views to indicate that views are loading.

ShimmerRecyclerView Intro A custom recycler view with shimmer views to indicate that views are loading. The recycler view has a built-in adapter to co

Harish Sridharan 3.8k Dec 31, 2022
Medium sample for frogo-recycler-view

mediumstory-frogo-recycler-view Tutorial how to use frogo-recycler-view lib Medium sample for frogo-recycler-view Medium Story Here frogo-recycler-vie

Muhammad Faisal Amir 5 Sep 12, 2021
Simple lib to create a endless recycler view scroll

Endless RecyclerView A simple lib to create an infinite list in a RecyclerView. When you reach the end of the list, a callback is triggered, where you

Jaison Klemer 4 Sep 2, 2022
Android Development by using Kotlin, this App uses the concept of API, Recycler Methods and Databases.

Bookstore App by using Kotlin This Project is made using Kotlin, and it uses main concepts of API, Databases, Fragments and many more. This Applicatio

Abeye Tewodros 4 Nov 23, 2022
Android pagination library (updated 01.05.2018)

NoPaginate Android pagination library, based on @MarkoMilos repository Paginate Loading Item Error Item Gradle implementation 'ru.alexbykov:nopaginate

Alexey Bykov 183 Nov 22, 2022
Just another one easy-to-use adapter for RecyclerView :rocket:

Elementary RecyclerView Adapter Another one easy-to-use adapter for RecyclerView ?? Features: DSL-like methods for building adapters similar to Jetpac

Roman Andrushchenko 29 Jan 6, 2023