Enhancing RecyclerView Performance in Android for a Facebook-like Social App News Feed with Pagination

30 views Asked by At

I am working on a social app where I have the home screen similar to Facebook. I have a list of stories, a list of suggested friends, and wall posts. The wall loads the data in pages. I'm currently using NestedScrollView to handle this, but the challenge is that with NestedScrollView, RecyclerView does not recycle the views, resulting in slow and laggy performance.

I want to use the paging library. I tried implementing a single RecyclerView with three different views: one for stories, one for suggested friends, and one for the posts (using pagination). But the posts vertical RecyclerView inside my main RecyclerView is not recycling the views either (I confirmed it through Layout Inspector), so I'm still facing the same performance issue.

Now my questions are:

  1. How can I implement a Facebook-like news feed using pagination and still be able to recycle the views without making the code too complex?
  2. How can I handle the situations when the user likes the post? In this case, I have to call the API for the current page again. I use PagingSource.invalidate() to do this, but I'm not sure if that's a good way.
  3. How can I cache the results so that even when I invalidate the PagingSource, the user can still smoothly scroll to the top without waiting for the API calls to get the top data.

Any link open source project will really be appreciated.

0

There are 0 answers