LoadMoreWrapper

📦 Enable the RecyclerView to support loading more and customizing the footer view without modifying the original adapter of the RecyclerView. 在不改动 RecyclerView 原有的 adapter 的情况下,使 RecyclerView 滑动到底部的时候能够加载更多和自定义底部视图。

APACHE-2.0 License

Stars
190

LoadMoreWrapper

make recyclerView supports load more and customize the footer view, without changes to the original adater of recyclerView.

RecyclerView adapter

  • item
  • layoutManager Grid StaggeredGrid , footerView

Installation

JCenter:

add the dependency to your build.gradle:

    implementation 'com.github.nukc:loadmorewrapper:1.9.1'

JitPack:

Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:

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

Step 2. Add the dependency

    dependencies {
        implementation 'com.github.nukc:LoadMoreWrapper:v1.9.1'
    }

AndroidX

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        ...
        maven("https://jitpack.io")
    }
}
    dependencies {
        implementation("com.github.nukc:LoadMoreWrapper:v1.9.3")
    }

Usage

    //the adapter is the original ( adapter , )
    LoadMoreWrapper.with(adapter)
        .setFooterView(...) // view or layout resource
        .setShowNoMoreEnabled(true) // enable show NoMoreViewdefault false
        .setListener(new LoadMoreAdapter.OnLoadMoreListener() {
             @Override
             public void onLoadMore(LoadMoreAdapter.Enabled enabled) {
                 // do something
                 // you can enabled.setLoadMoreEnabled(false) when do not need load more
                 // you can enabled.setLoadFailed(true) when load failed
             })
        .into(recyclerView);

or

in the original adapter: demo

    private static class AnotherAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

        private LoadMoreWrapper mWrapper;

        // code..

        @Override
        public void onAttachedToRecyclerView(RecyclerView recyclerView) {
            super.onAttachedToRecyclerView(recyclerView);

            mWrapper = LoadMoreWrapper.with(this);
            mWrapper.setListener(
                    new LoadMoreAdapter.OnLoadMoreListener() {
                        @Override
                        public void onLoadMore(LoadMoreAdapter.Enabled enabled) {
                            // do something
                        }
                    })
                    .setShowNoMoreEnabled(true)
                    .into(recyclerView);
        }

    }

| :------------- | :------------- setLoadMoreEnabled(boolean enabled) | true setShowNoMoreEnabled(boolean enabled) | false setLoadFailed(boolean isLoadFailed) | false setNotShowFooterWhenNotCoveredScreen(boolean notShow) | item false getOriginalAdapter() | adapter getFooterView | getNoMoreView | getLoadFailedView |

setLoadMoreEnabled(false) View mLoadMoreEnabled true mLoadMoreEnabled ViewPager + Fragment setOffscreenPageLimit

License

Copyright 2016 nukc

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.