From 6df8af9eca65ea36185a4490b82a70124f3b918b Mon Sep 17 00:00:00 2001 From: niranjannlc Date: Sun, 2 Oct 2022 11:41:42 +1100 Subject: [PATCH] refactored duplicate code items of assighning adapter --- .idea/misc.xml | 2 +- .idea/vcs.xml | 1 - .../presentation/shop/ShopFragment.kt | 29 +++++++------------ 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 3f359b1c..f6ca03bc 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -13,7 +13,7 @@ - + diff --git a/.idea/vcs.xml b/.idea/vcs.xml index f245aa7c..9661ac71 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,7 +1,6 @@ - \ No newline at end of file diff --git a/app/src/main/java/com/hieuwu/groceriesstore/presentation/shop/ShopFragment.kt b/app/src/main/java/com/hieuwu/groceriesstore/presentation/shop/ShopFragment.kt index 334388f1..3c0a68fa 100644 --- a/app/src/main/java/com/hieuwu/groceriesstore/presentation/shop/ShopFragment.kt +++ b/app/src/main/java/com/hieuwu/groceriesstore/presentation/shop/ShopFragment.kt @@ -32,7 +32,7 @@ class ShopFragment : Fragment() { private lateinit var viewModel: ShopViewModel private lateinit var dots: Array private lateinit var binding: FragmentShopBinding - + private lateinit var gridListItemAdapter: GridListItemAdapter private lateinit var nonActiveDot: Drawable private lateinit var activeDot: Drawable private var dotCount: Int = 0 @@ -122,34 +122,25 @@ class ShopFragment : Fragment() { } private fun setUpRecyclerView() { - binding.exclusiveOfferRecyclerview.adapter = - GridListItemAdapter( - GridListItemAdapter.OnClickListener( - clickListener = { viewModel.displayPropertyDetails(it) }, - addToCartListener = { addToCart(it) } - ) + gridListItemAdapter = GridListItemAdapter( + GridListItemAdapter.OnClickListener( + clickListener = { viewModel.displayPropertyDetails(it) }, + addToCartListener = { addToCart(it) } ) + ) + binding.exclusiveOfferRecyclerview.adapter = + gridListItemAdapter binding.exclusiveOfferRecyclerview.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) binding.bestSellingRecyclerview.adapter = - GridListItemAdapter( - GridListItemAdapter.OnClickListener( - clickListener = { viewModel.displayPropertyDetails(it) }, - addToCartListener = { addToCart(it) } - ) - ) + gridListItemAdapter binding.bestSellingRecyclerview.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) binding.recommendedRecyclerview.adapter = - GridListItemAdapter( - GridListItemAdapter.OnClickListener( - clickListener = { viewModel.displayPropertyDetails(it) }, - addToCartListener = { addToCart(it) } - ) - ) + gridListItemAdapter binding.recommendedRecyclerview.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false) }