2

I have recyclerview which contains horizontal child recycler views and in the end it has one single endless scrolling vertical recycler view child

<---RecyclerView-------->
    <Horizonatl recycler view>
    <Horizonatl recycler view>
    <Vertical recyler view endless scrolling>
<---RecyclerView-------->

I have added wrap_content height to child Vertical recyler view due to which I am not able to add scroll listner to this child recylerview

I have added endless scroll listener to outermost parent recyclerview but scroll is working till page 2 only and then its not working how can I achieve nested infinite scroll. Following is my code for listener applied on parent recyclerview

 @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            visibleItemCount = recyclerView.getChildCount();
            totalItemCount = layoutManager.getItemCount();
            firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
            if (dy > 0) {
                if (loading) {
                    if (totalItemCount > previousTotal) {
                        loading = false;
                        previousTotal = totalItemCount;
                        loading = false;
                        currentPage++;
                    }
                }
                if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold)) {
                    if (Utils.haveNetworkConnection(getActivity()) && currentPage < Constants.MAX_PAGES) {
                        loadMoreData();
                        loading = true;
                    }
                }
            }
        }
amodkanthe
  • 4,345
  • 6
  • 36
  • 77
  • Don't add vertical recycler view inside parent recycler view as vertical scroll inside vertical scroll is not a good practice instead add it as items to parent recycler view. – amodkanthe Mar 16 '23 at 18:44

0 Answers0