Git Product home page Git Product logo

paginator's Introduction

paginator

The simplest way to make your recycler view paginable.

It will automatically detect if content loading is complete or not. You don't need to implement a method like hasFinishLoading!

Example

See full example here.

Installation

Your top-level build.gradle:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

In module-level build.gradle:

dependencies {
    implementation 'com.github.mu29:paginator:1.0'
}

Because this library uses support library 27.1.0, you may get errors if you are already using a different version. In that case, exclude support library:

dependencies {
    implementation ('com.github.mu29:paginator:1.0') {
        exclude group: "com.android.support"
    }
}

Usage

1. Define view in your layout

<net.yeoubi.paginator.PagingRecyclerView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="45dp"
    app:progressColor="@color/gray_30"
    app:innerClipToPadding="false"
    app:innerPaddingTop="24dp"/>

The progressColor attribute must exist and is reference type. You can't define it just like "#FFF".

2. Implement OnPaginateListener

class MyActivity extends AppCompatActivity implements PagingRecyclerView.OnPaginateListener {

    private PagingRecyclerView itemList;
    private YourCustomAdapter adapter;

    private void setRecyclerView() {
        // Adapter must be set before the OnPaginateListener.
        itemList.setAdapter(adapter);
        itemList.setOnPaginateListener(this);
    }
    
    @Override
    public void onPaginate(int page) {
        // ...fetch data from database, network, etc...
        adapter.notifyDataSetChanged();
    }
}

As mentioned above, you must set the adapter before the OnPaginateListener.

Author

InJung Chung / @mu29

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.