From 3c25cfa2bc15661cfdddcf59421e00e8c18a0c1c Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Fri, 4 Aug 2023 14:10:00 +0600 Subject: [PATCH 1/2] Add shimmerView for homePage per category appList --- .../apps/ui/home/model/HomeParentRVAdapter.kt | 16 +++++++ .../main/res/layout/home_parent_list_item.xml | 13 +++++- .../shimmer_placeholder_home_category.xml | 43 +++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/layout/shimmer_placeholder_home_category.xml diff --git a/app/src/main/java/foundation/e/apps/ui/home/model/HomeParentRVAdapter.kt b/app/src/main/java/foundation/e/apps/ui/home/model/HomeParentRVAdapter.kt index 808b4665f..04cf50889 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/model/HomeParentRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/model/HomeParentRVAdapter.kt @@ -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 @@ -77,6 +78,21 @@ class HomeParentRVAdapter( setRecycledViewPool(viewPool) } observeAppInstall(fusedHome, homeChildRVAdapter) + + handleChildShimmerView(fusedHome, holder) + } + + 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( diff --git a/app/src/main/res/layout/home_parent_list_item.xml b/app/src/main/res/layout/home_parent_list_item.xml index bcb362ac8..f5fa94485 100644 --- a/app/src/main/res/layout/home_parent_list_item.xml +++ b/app/src/main/res/layout/home_parent_list_item.xml @@ -17,9 +17,9 @@ --> + + + + + + + + + + + + + + + + + + + + + + + + -- GitLab From 1205ab831805a68ff2c03caeed5d255513d4eecb Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Fri, 4 Aug 2023 14:14:54 +0600 Subject: [PATCH 2/2] Optimize homePage category child view loading logic In HomeFragment, for per category appList is returned empty list, we don't have to setup recylerView adapter & load downLoad app status. We only need to enable the shimmerView & set the title. --- .../e/apps/ui/home/model/HomeParentRVAdapter.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/foundation/e/apps/ui/home/model/HomeParentRVAdapter.kt b/app/src/main/java/foundation/e/apps/ui/home/model/HomeParentRVAdapter.kt index 04cf50889..5edbbebb9 100644 --- a/app/src/main/java/foundation/e/apps/ui/home/model/HomeParentRVAdapter.kt +++ b/app/src/main/java/foundation/e/apps/ui/home/model/HomeParentRVAdapter.kt @@ -54,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, @@ -62,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) @@ -77,9 +84,8 @@ class HomeParentRVAdapter( ) setRecycledViewPool(viewPool) } - observeAppInstall(fusedHome, homeChildRVAdapter) - handleChildShimmerView(fusedHome, holder) + observeAppInstall(fusedHome, homeChildRVAdapter) } private fun handleChildShimmerView(fusedHome: FusedHome, holder: ViewHolder) { -- GitLab