nonews / nopaginate Goto Github PK
View Code? Open in Web Editor NEWAndroid pagination library (updated 01.05.2018)
License: Apache License 2.0
Android pagination library (updated 01.05.2018)
License: Apache License 2.0
Firstly thanks for the great library i was able to remove a lot of boilerplate from my code.👍
My api call is supposed to load 10 items per page but since the data coming from first call is only 4 items this results in onLoadMore
being called one more time.
when I add code in your MianActivity
like :
@Override
protected void onPostCreate(@Nullable Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
new Handler().postDelayed(() -> mainActivityPresenter.addItems(), 500);
}
notice,it‘s a async action,now recyclerview only have one child(loadmore item), so it will cause load more twice,becase your code didn't calculcate loadmore item count(1)
Do you have plan to support androidX? There are the problem about RecyclerView.
Keep:
layoutManager.setStackFromEnd(true);
layoutManager.setReverseLayout(true);
Now pagination is trigger initially. Is there any workaround?
I tried to implement swiperefresh with your library via this code
if (!isRefresh) {
showProgressBar();
} else if (noPaginate != null) {
noPaginate.unbind();
}
noPaginate = NoPaginate.with(listNews)
.setOnLoadMoreListener(new OnLoadMoreListener() {
@Override
public void onLoadMore() {
//network code
}
})
.setLoadingTriggerThreshold(5)
.build();
but it is not working, paginate is not going into the load more method
I noticed the load more calls without scroll, I initially had a first call to Retrofit to load data before scroll to load more.
So is there away to load initial data where I can have my loading view of choice?
Then when user scrolls, more are loaded??
Hi, first of all thanks for such an awesome library.
I am calling noPaginate.showLoading(false)
to hide the loader but its still showing.
Hello,
First of all thanks for this library.
One thing noticed when I called notifyItemChanged(position, payload) it will call
onBindViewHolder(holder, position) not onBindViewHolder(holder, position, payload) .
Please handle this scenario.
Similarly other methods like onViewRecycled(), onViewAttachedToWindow(), onViewDetachedFromWindow() related methods are also not fired.
Thanks
When put RecyclerView inside NestedScrollView then called all pages continuously until last page without scroll!
I received an exception while scrolling horizontally. I modified ErrorItem and LoadingItem for Horizontal and Vertical scrolls.
public interface LoadingItem extends BaseLinearLayoutManagerItem {
LoadingItem VERTICAL = new LoadingItem() {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(
R.layout.pagination_item_loading, parent, false
);
return new RecyclerView.ViewHolder(view) {};
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {}
};
LoadingItem HORIZONTAL = new LoadingItem() {
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(
R.layout.pagination_item_loading_horizontal_scroll, parent, false
);
return new RecyclerView.ViewHolder(view) {};
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {}
};
}
And, then, I setOrientation()
using PaginateBuilder:
public PaginateBuilder setOrientation (PaginateOrientation orientation) {
if (orientation == PaginateOrientation.HORIZONTAL) {
setCustomErrorItem(ErrorItem.HORIZONTAL);
setCustomLoadingItem(LoadingItem.HORIZONTAL);
}
else {
setCustomErrorItem(ErrorItem.VERTICAL);
setCustomLoadingItem(LoadingItem.VERTICAL);
}
return this;
}
This is the exception I get:
03-24 10:06:48.274 W/RecyclerView: Cannot call this method in a scroll callback. Scroll callbacks mightbe run during a measure & layout pass where you cannot change theRecyclerView data. Any method call that might change the structureof the RecyclerView or the adapter contents should be postponed tothe next frame.
java.lang.IllegalStateException: android.support.v7.widget.RecyclerView{a136c97 VFED..... ......ID 0,0-450,273}, adapter:com.xxxxx.xxxx.utils.pagination.paginate.WrapperAdapter@9256e84, layout:android.support.v7.widget.LinearLayoutManager@ab4766d, context:com.xxxxx.xxxxx.view.modules.ecommerce.ShopActivity@5d48e36
at android.support.v7.widget.RecyclerView.assertNotInLayoutOrScroll(RecyclerView.java:2673)
at android.support.v7.widget.RecyclerView$RecyclerViewDataObserver.onChanged(RecyclerView.java:5055)
at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyChanged(RecyclerView.java:11540)
at android.support.v7.widget.RecyclerView$Adapter.notifyDataSetChanged(RecyclerView.java:6762)
at com.xxxxx.xxxxx.utils.pagination.paginate.WrapperAdapterObserver.onChanged(WrapperAdapterObserver.java:50)
at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyChanged(RecyclerView.java:11540)
at android.support.v7.widget.RecyclerView$Adapter.notifyDataSetChanged(RecyclerView.java:6762)
at com.xxxxx.xxxxx.view.base.base_adapters.recycler_view_adapters.BaseListAdapter.informDataSetChanged(BaseListAdapter.java:902)
at com.xxxxx.xxxxx.view.base.base_adapters.recycler_view_adapters.BaseListAdapter.setItems(BaseListAdapter.java:701)
at com.xxxxxx.xxxxx.view.modules.ecommerce.features.product_similar.SimilarProductFragment.fetchSimilarProducts(SimilarProductFragment.java:97)
at com.xxxxx.xxxx.view.modules.ecommerce.features.product_similar.SimilarProductFragment.onLoadMore(SimilarProductFragment.java:274)
at com.xxxxx.xxxx.utils.pagination.paginate.Paginate.checkAdapterState(Paginate.java:76)
at com.xxxxx.xxxxxx.utils.pagination.paginate.Paginate.checkScroll(Paginate.java:101)
at com.xxxxx.xxxxx.utils.pagination.paginate.Paginate.access$000(Paginate.java:15)
at com.xxxxx.xxxxx.utils.pagination.paginate.Paginate$1.onScrolled(Paginate.java:68)
at android.support.v7.widget.RecyclerView.dispatchOnScrolled(RecyclerView.java:4722)
at android.support.v7.widget.RecyclerView.scrollByInternal(RecyclerView.java:1787)
at android.support.v7.widget.RecyclerView.onTouchEvent(RecyclerView.java:2970)
at android.view.View.dispatchTouchEvent(View.java:9303)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2242)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2561)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2256)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2561)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2256)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2561)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2256)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2561)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2256)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2561)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2256)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2561)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2256)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2561)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2256)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2561)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2256)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2561)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2256)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2561)
at android.vi
Proposed solution is to wrap these calls in a Handler.post()
maybe.
Very good step.
You need to implement your sample app code with Retrofit.
Can you add an Item in adapter to show that Adapter is empty? View can notify Paginate that the item-count has changed. If user enables this Empty Item and item-count reaches 0, you can show this item.
I use a layout to show Empty Adapter, but it is shown on top of RecyclerView in FrameLayout. I want to have it in Adapter, and be able to turn it on/off manually.
Thanks. Your library works amazingly even without this feature.
Hi @NoNews ,
I am using noPaginate lib ti handle a list of accounts movements, if I use the recyclerView [alone] the onLoadMore listener works fine when a reach the last item of the list, but when a Try to use NestedScrollView with RecyclerView the onLoadMore is called before I scroll down.
I hope you can Help me about this issue.
Cheers.
PD: I need to use NestedScrollView in order to use CollapsinToolbarLayout.
Hi @NoNews its me again.. lol.
Just one question,:
is it possible to show a custom view when there is not more items to show.?..I mean something like "There is not more items to show for the moment"
PD: something like the custom error view.
Regards.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.