My HomeBuyersActivity consists of multiple recyclerviews (ex. popular stores, popular products, discover products, discover store and etc.) which are aligned vertically but their item layouts are aligned horizontally. So when I open the activity, the process of retrieving the data is too long because it was loading all the files at the same time. Here is the sample code of my XML file:
XML: (Note: all of the included layouts consists of recyclerviews)
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/a ndroid"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/defaultBackground"
tools:context=".Activity.HomeBuyersActivity">
<androidx.core.widget.NestedScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="0dp">
<include
layout="@layout/popular_store_layout"
android:visibility="visible" />
<include
layout="@layout/popular_products_layout"
android:visibility="visible" />
<include
layout="@layout/discover_store_layout"
android:visibility="visible" />
<include
layout="@layout/discover_products_layout"
android:visibility="visible" />
//.... and more recyclerviews
</androidx.core.widget.NestedScrollView>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
And in HomeBuyersActivity I am populating those recyclerviews with the data that are retrieved from firestore. The only solution that I came out with is to load only the layout that is/are visible to the screen but I don't know how to do it. Is there a way to achieve that process? If not, Is there any better solution or other way around?