🚄 No immersion implementation adds rows that are being loaded and loaded for RecyclerView.
Switch branches/tags
Nothing to show
Clone or download
Latest commit f1d45ea May 4, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea 🚶 update readme Apr 20, 2017
app 🚶 fixed #1 Apr 25, 2017
art 🚶 update readme Apr 20, 2017
gradle/wrapper 🚶 Initial commit Apr 14, 2017
library 🚶 fixed #2 May 4, 2017
.gitignore 🚶 Initial commit Apr 14, 2017
README.md 🚶 update readme Apr 20, 2017
build.gradle 🚶 Initial commit Apr 14, 2017
gradle.properties 🚶 Initial commit Apr 14, 2017
gradlew 🚶 Initial commit Apr 14, 2017
gradlew.bat 🚶 Initial commit Apr 14, 2017
settings.gradle 🚶 Initial commit Apr 14, 2017

README.md

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 bakumon@aliyun.com

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.