Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b342e18 authored by Fahim Salam Chowdhury's avatar Fahim Salam Chowdhury 👽
Browse files

Merge branch '7037-Add_shimmerview_for_homepage_category_applist' into 'main'

Optimize homePage category child view loading logic

See merge request !342
parents c07300b9 1205ab83
Loading
Loading
Loading
Loading
Loading
+24 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
package foundation.e.apps.ui.home.model

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.LinearLayoutManager
@@ -53,6 +54,14 @@ class HomeParentRVAdapter(

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val fusedHome = getItem(position)

        holder.binding.titleTV.text = fusedHome.title
        handleChildShimmerView(fusedHome, holder)

        if (fusedHome.list.isEmpty()) {
            return
        }

        val homeChildRVAdapter =
            HomeChildRVAdapter(
                fusedAPIInterface,
@@ -61,9 +70,8 @@ class HomeParentRVAdapter(
                lifecycleOwner,
                paidAppHandler
            )
        homeChildRVAdapter.setData(fusedHome.list)

        holder.binding.titleTV.text = fusedHome.title
        homeChildRVAdapter.setData(fusedHome.list)

        holder.binding.childRV.apply {
            recycledViewPool.setMaxRecycledViews(0, 0)
@@ -76,9 +84,23 @@ class HomeParentRVAdapter(
                )
            setRecycledViewPool(viewPool)
        }

        observeAppInstall(fusedHome, homeChildRVAdapter)
    }

    private fun handleChildShimmerView(fusedHome: FusedHome, holder: ViewHolder) {
        if (fusedHome.list.isEmpty()) {
            holder.binding.shimmerLayout.visibility = View.VISIBLE
            holder.binding.shimmerLayout.startShimmer()
            holder.binding.childRV.visibility = View.GONE
            return
        }

        holder.binding.shimmerLayout.visibility = View.GONE
        holder.binding.shimmerLayout.stopShimmer()
        holder.binding.childRV.visibility = View.VISIBLE
    }

    private fun observeAppInstall(
        fusedHome: FusedHome,
        homeChildRVAdapter: RecyclerView.Adapter<*>?
+12 −1
Original line number Diff line number Diff line
@@ -17,9 +17,9 @@
  -->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical">

    <RelativeLayout
@@ -46,6 +46,17 @@
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp">

        <com.facebook.shimmer.ShimmerFrameLayout
            android:id="@+id/shimmerLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:visibility="gone">

            <include layout="@layout/shimmer_placeholder_home_category" />
        </com.facebook.shimmer.ShimmerFrameLayout>


        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/childRV"
            android:layout_width="match_parent"
+43 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Apps  Quickly and easily install Android apps onto your device!
  ~ Copyright (C) 2023 MURENA SAS
  ~
  ~ This program is free software: you can redistribute it and/or modify
  ~ it under the terms of the GNU General Public License as published by
  ~ the Free Software Foundation, either version 3 of the License, or
  ~ (at your option) any later version.
  ~
  ~ This program is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~ GNU General Public License for more details.
  ~
  ~ You should have received a copy of the GNU General Public License
  ~ along with this program.  If not, see <https://www.gnu.org/licenses/>.
  -->
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scrollbars="none">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:orientation="horizontal">

        <include layout="@layout/shimmer_placeholder_home_child" />

        <include layout="@layout/shimmer_placeholder_home_child" />

        <include layout="@layout/shimmer_placeholder_home_child" />

        <include layout="@layout/shimmer_placeholder_home_child" />

        <include layout="@layout/shimmer_placeholder_home_child" />

        <include layout="@layout/shimmer_placeholder_home_child" />

    </LinearLayout>
</HorizontalScrollView>