MarkoMilos / Paginate

Library for creating simple pagination functionality upon RecyclerView and AbsListView
Apache License 2.0
1.35k stars 225 forks source link

RecyclerView with GridLInearLayout manager Weird Behavior #5

Closed ashraful29 closed 8 years ago

ashraful29 commented 8 years ago

Sometime The RecyclerView Item Take Whole row og GridLayoutManger On load more Action I upload below image for understanding the problem. sometimeadaptermismatch

MarkoMilos commented 8 years ago

Hi @ashraful29 ,

can you provide code snippet for Paginate setuping and how do you add more items into the list. Can you confirm that this item (that takes full span) is the last item on a certain page?

ashraful29 commented 8 years ago

There is Paginate Initialization code.. Where newSpanCount is number of Grid Column

 int threshold=4;
        paginate = Paginate.with(listProduct, this)
                .setLoadingTriggerThreshold(threshold)
                .setLoadingListItemSpanSizeLookup(new LoadingListItemSpanLookup() {
                    @Override
                    public int getSpanSize() {
                        return newSpanCount ;
                    }
                })
                .build();

And below code is adding more items...

 int range = productAdapter.getItemCount();
            // productAdapter.products.addAll(productsResponse.getProducts());
            productAdapter.addAll(productsResponse.getProducts());
            loading = false;
            System.out.print("Size" + productList.size());
            productAdapter.notifyItemRangeInserted(range,productsResponse.getProducts().size());
            productAdapter.notifyDataSetChanged();

And The item which take full span is the first item in a particular page when loading more..

MarkoMilos commented 8 years ago

What's the implementation of productAdapter.addAll(items) - do you call any adapter related callbacks inside that method?

Why do you call both notifyItemRangeInserted(int positionStart, itemCount) and notifyDataSetChanged() ?

Check the sample for the example for RecyclerView + GridLayoutManager with span = 2.

MarkoMilos commented 8 years ago

Since long inactivity on this issue, I will close it for now. Feel free to reopen it if you still have problems with this.