Skip to content Skip to sidebar Skip to footer

How To Create Pagination In Chat App Using Firebase Real Time Database?

from documentation that says the paging adapter is not appropriate for a chat application so i tried to make pagination in swipeTorefreshLayout swipeRefreshLayout.setOnRefreshList

Solution 1:

I personally dont use the adapters when utilising Pagination, I simply send the current List size to my service layer, when the user reaches the bottom of a ListView. Seems like a less intensive and more efficient process, then you just need to implement SKIP and TAKE to the db

privatebooleanreachedEndOfList(int position)
    {
        returnposition== this.getCount() - 1;
    }

Solution 2:

u can try this method

privatevoidmyRecyclerUpdater() {
    mRecycleView.addOnScrollListener(newRecyclerView.OnScrollListener() {
        publicvoidonScrolled(RecyclerView recyclerView, int dx, int dy) {       //not importantsuper.onScrolled(recyclerView, dx, dy);
        }

        publicvoidonScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
     
   //try (2) instead of ACTION_DOWN if it didnt work   //and we check for scroll state here 0 means IDLE if (!recyclerView.canScrollVertically(MotionEvent.ACTION_DOWN) && newState == 0) {
          //make your data request//update your recycler list and notify changes
            }
        }
    });

}

Post a Comment for "How To Create Pagination In Chat App Using Firebase Real Time Database?"