Git Product home page Git Product logo

bkloadmore's Introduction

BKLoadMore(non-invasive)

Modified from Paginate, the extension is in addition to displaying the rows that have finished loading all the data.

Features

  • API is simple and flexible
  • No immersion implementation
  • Custom loading & no more data list item
  • Support RecyclerView (using linear, grid and staggered LayoutManager)

Preview

BKLoadMore.gif

Setup

TODO JCenter

Usage

Use the default implementation to start quickly.

BKLoadMore mBKLoadMore = BKLoadMoreImpl.with(recyclerView, this).build();

Implement the CallBacks interface to control paging action.

@Override
public void onLoadMore() {
    // Called when next page of data needs to be loaded.
    handler.postDelayed(fakeCallback, 1500);
}

@Override
public void onRetry() {
    // Called when the next page of data needs to be reloaded.
    handler.postDelayed(retryCallback, 1500);
}

Call the following method at the appropriate time, see the note for details.

// Called to check if there is more data (more pages) to load.
mBKLoadMore.setIsLastPage(isLastPage);

// This method is called when the data has been loaded.
mBKLoadMore.completedLoadMore();

// This method is called when data loading fails.It will show the load failed line.
mBKLoadMore.loadMoreFail();

Note: LayoutManager and RecyclerView.Adapter needs to be set before calling the code above.

Customize

mBKLoadMore = BKLoadMoreImpl.with(recyclerView, this)
                            .setLoadingItem(new CustomerLoadingItem())
                            .setNoMoreDataItem(new CustomerNoMoreDataItem())
                            .build();

Implement the LoadingItem interface to customize the loading line.

CustomerLoadingItem.java

public class CustomerLoadingItem implements LoadingItem {
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.loading_row_customer, parent, false);
        return new RecyclerView.ViewHolder(view) {
        };
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

    }
}

Implement the NoMoreDataItem interface to customize the showing no more data line.

CustomerNoMoreDataItem.java

public class CustomerNoMoreDataItem implements NoMoreDataItem {
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.no_more_data_row_customer, parent, false);
        return new RecyclerView.ViewHolder(view) {
        };
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

    }
}

For details, please refer to demo.

About me

License

Copyright 2017 [email protected]

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.

bkloadmore's People

Contributors

bakumon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

sagardep

bkloadmore's Issues

加载更多问题

你好,下载demo运行,发现当数据不满一页的时候,也会触发加载更多逻辑?请问这个逻辑怎么修改

RecyclerView设置LayoutManager为StaggeredGridLayoutManager时,数据全部加载完了,却一直显示正在加载的状态

  非常感谢作者提供这个库,在使用的过程中发现了点问题:

1、recyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL)); 数据全部加载完了,却一直显示加载中的状态。

2、recyclerView.setLayoutManager(new GridLayoutManager(this, 3)); 加载失败的item没有占满整个屏幕的宽,只是占据GridView的item宽度。

onAdapterDataChanged() 方法中调用了displayRow()方法,接着在checkEndOffset()方法中又调用了displayRow()方法,是不是重复调用了,我注释掉了onAdapterDataChanged() 方法中的displayRow()方法,再次运行后发现效果是一样的。
希望作者看到后能及时修复一下,谢谢。

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.