@@ -6,7 +6,7 @@ import androidx.core.view.isVisible
66import androidx.recyclerview.widget.RecyclerView
77import coil3.load
88import com.looker.droidify.databinding.ProductItemBinding
9- import com.looker.droidify.model.Product
9+ import com.looker.droidify.model.ProductItem
1010import com.looker.droidify.model.Repository
1111import com.looker.droidify.utility.common.extension.authentication
1212import com.looker.droidify.utility.common.extension.corneredBackground
@@ -19,14 +19,14 @@ class FavouriteFragmentAdapter(
1919 private val onProductClick : (String ) -> Unit
2020) : RecyclerView.Adapter<FavouriteFragmentAdapter.ViewHolder>() {
2121
22- inner class ViewHolder (binding : ProductItemBinding ) : RecyclerView.ViewHolder(binding.root) {
22+ class ViewHolder (binding : ProductItemBinding ) : RecyclerView.ViewHolder(binding.root) {
2323 val icon = binding.icon
2424 val name = binding.name
2525 val summary = binding.summary
2626 val version = binding.status
2727 }
2828
29- var apps: List <List < Product > > = emptyList()
29+ var apps: List <ProductItem > = emptyList()
3030 set(value) {
3131 field = value
3232 notifyDataSetChanged()
@@ -47,29 +47,34 @@ class FavouriteFragmentAdapter(
4747 )
4848 ).apply {
4949 itemView.setOnClickListener {
50- if (apps.isNotEmpty() && apps[absoluteAdapterPosition].firstOrNull() != null ) {
51- onProductClick(apps[absoluteAdapterPosition].first(). packageName)
50+ if (apps.isNotEmpty()) {
51+ onProductClick(apps[absoluteAdapterPosition].packageName)
5252 }
5353 }
5454 }
5555
5656 override fun getItemCount (): Int = apps.size
5757
5858 override fun onBindViewHolder (holder : ViewHolder , position : Int ) {
59- val item = apps[position].first().item()
59+ val item = apps[position]
60+ val context = holder.itemView.context
61+ val installedVersion = item.installedVersion.nullIfEmpty()
62+
6063 val repository: Repository ? = repositories[item.repositoryId]
6164 holder.name.text = item.name
6265 holder.summary.isVisible = item.summary.isNotEmpty()
6366 holder.summary.text = item.summary
67+
6468 if (repository != null ) {
6569 val iconUrl = item.icon(holder.icon, repository)
6670 holder.icon.load(iconUrl) {
6771 authentication(repository.authentication)
6872 }
6973 }
74+
7075 holder.version.apply {
71- text = item. installedVersion.nullIfEmpty() ? : item.version
72- val isInstalled = item. installedVersion.nullIfEmpty() != null
76+ text = installedVersion ? : item.version
77+ val isInstalled = installedVersion != null
7378 when {
7479 item.canUpdate -> {
7580 backgroundTintList =
0 commit comments