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 808b4665f9a65cc4012a3b330c8ef77392df96c9..5edbbebb9c6efe7eafd77456f2ec6a987e7b0a07 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 @@ -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<*>? 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 bcb362ac8723995e9c0f4003753173add99825d0..f5fa944859749ad57150404f0dfc25f2b05f4ede 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 @@ --> + + + + + + + + + + + + + + + + + + + + + + + +