From 7b3cff79a9ee6d091181b389b855d789bb1c2c9c Mon Sep 17 00:00:00 2001 From: swit-jim Date: Sun, 17 Mar 2024 17:15:09 +0900 Subject: [PATCH] =?UTF-8?q?[fix/restaurant=5Frelated=5Faction]:=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=EA=B2=80=EC=83=89=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EB=A7=88=EC=9D=B4=EA=B7=B8=EB=A0=88=EC=9D=B4?= =?UTF-8?q?=EC=85=98=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../allsearch/SearchCategoryAllFragment.kt | 18 +++++++++++- .../adapter/SearchCategoryGroupAdapter.kt | 29 +++++++------------ .../SearchCategoryGroupPreviewAdapter.kt | 27 ++++++----------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/presentation/src/main/java/org/gdsc/presentation/view/allsearch/SearchCategoryAllFragment.kt b/presentation/src/main/java/org/gdsc/presentation/view/allsearch/SearchCategoryAllFragment.kt index ecdaad49..b77ca2bb 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/allsearch/SearchCategoryAllFragment.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/allsearch/SearchCategoryAllFragment.kt @@ -15,11 +15,13 @@ import com.bumptech.glide.Glide import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.collect import org.gdsc.domain.model.GroupInfo +import org.gdsc.domain.model.GroupPreview import org.gdsc.domain.model.RegisteredRestaurant import org.gdsc.presentation.R import org.gdsc.presentation.base.BaseViewHolder import org.gdsc.presentation.base.ViewHolderBindListener import org.gdsc.presentation.databinding.FragmentSearchCategoryAllBinding +import org.gdsc.presentation.databinding.ItemSearchGroupBinding import org.gdsc.presentation.databinding.ItemSearchRestaurantBinding import org.gdsc.presentation.utils.repeatWhenUiStarted import org.gdsc.presentation.view.allsearch.adapter.SearchCategoryGroupPreviewAdapter @@ -37,7 +39,7 @@ class SearchCategoryAllFragment( val viewModel: AllSearchViewModel by activityViewModels() private val searchCategoryRestaurantPreviewAdapter = SearchCategoryRestaurantPreviewAdapter(this) - private val searchCategoryGroupPreviewAdapter = SearchCategoryGroupPreviewAdapter() + private val searchCategoryGroupPreviewAdapter = SearchCategoryGroupPreviewAdapter(this) override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -100,6 +102,7 @@ class SearchCategoryAllFragment( .placeholder(R.drawable.base_profile_image) .into(userProfileImage) + groupName.text = _item.groupName userName.text = _item.userNickName Glide.with(root) @@ -117,6 +120,19 @@ class SearchCategoryAllFragment( ) ) } + } else if (holder is SearchCategoryGroupPreviewAdapter.GroupWithSearchPreviewViewHolder && _item is GroupPreview) { + val binding = ItemSearchGroupBinding.bind(holder.itemView) + binding.run { + Glide.with(root) + .load(_item.groupProfileImageUrl) + .placeholder(R.drawable.base_profile_image) + .into(ivGroupImage) + + tvGroupName.text = _item.groupName + tvIntroduction.text = _item.groupIntroduce + tvMemberCount.text = _item.memberCnt.toString() + tvRestaurantCount.text = _item.restaurantCnt.toString() + } } } } \ No newline at end of file diff --git a/presentation/src/main/java/org/gdsc/presentation/view/allsearch/adapter/SearchCategoryGroupAdapter.kt b/presentation/src/main/java/org/gdsc/presentation/view/allsearch/adapter/SearchCategoryGroupAdapter.kt index e8d5e37a..9c835ce5 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/allsearch/adapter/SearchCategoryGroupAdapter.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/allsearch/adapter/SearchCategoryGroupAdapter.kt @@ -8,9 +8,13 @@ import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import org.gdsc.domain.model.GroupInfo import org.gdsc.presentation.R +import org.gdsc.presentation.base.BaseViewHolder +import org.gdsc.presentation.base.ViewHolderBindListener import org.gdsc.presentation.databinding.ItemSearchGroupBinding -class SearchCategoryGroupAdapter() : +class SearchCategoryGroupAdapter( + private val listener: ViewHolderBindListener, +) : PagingDataAdapter( DiffCallback ) { @@ -26,22 +30,11 @@ class SearchCategoryGroupAdapter() : } class SearchCategoryGroupViewHolder( - private val binding: ItemSearchGroupBinding, - ) : RecyclerView.ViewHolder(binding.root) { - fun bind(item: GroupInfo) { - binding.run { - Glide.with(itemView.context) - .load(item.groupProfileImageUrl) - .placeholder(R.drawable.base_profile_image) - .into(ivGroupImage) - - tvGroupName.text = item.groupName - tvIntroduction.text = item.groupIntroduce - tvMemberCount.text = item.memberCnt.toString() - tvRestaurantCount.text = item.restaurantCnt.toString() - } - } - } + binding: ItemSearchGroupBinding, + listener: ViewHolderBindListener, + ) : BaseViewHolder( + binding, listener + ) override fun onBindViewHolder( holder: SearchCategoryGroupViewHolder, @@ -59,6 +52,6 @@ class SearchCategoryGroupAdapter() : ): SearchCategoryGroupViewHolder { val binding = ItemSearchGroupBinding.inflate(LayoutInflater.from(parent.context), parent, false) - return SearchCategoryGroupViewHolder(binding) + return SearchCategoryGroupViewHolder(binding, listener) } } \ No newline at end of file diff --git a/presentation/src/main/java/org/gdsc/presentation/view/allsearch/adapter/SearchCategoryGroupPreviewAdapter.kt b/presentation/src/main/java/org/gdsc/presentation/view/allsearch/adapter/SearchCategoryGroupPreviewAdapter.kt index 82423220..d200ec50 100644 --- a/presentation/src/main/java/org/gdsc/presentation/view/allsearch/adapter/SearchCategoryGroupPreviewAdapter.kt +++ b/presentation/src/main/java/org/gdsc/presentation/view/allsearch/adapter/SearchCategoryGroupPreviewAdapter.kt @@ -8,9 +8,13 @@ import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import org.gdsc.domain.model.GroupPreview import org.gdsc.presentation.R +import org.gdsc.presentation.base.BaseViewHolder +import org.gdsc.presentation.base.ViewHolderBindListener import org.gdsc.presentation.databinding.ItemSearchGroupBinding -class SearchCategoryGroupPreviewAdapter +class SearchCategoryGroupPreviewAdapter( + private val listener: ViewHolderBindListener +) : ListAdapter( diffCallback ) { @@ -34,22 +38,9 @@ class SearchCategoryGroupPreviewAdapter } class GroupWithSearchPreviewViewHolder( - private val binding: ItemSearchGroupBinding, - ): RecyclerView.ViewHolder(binding.root) { - fun bind(item: GroupPreview) { - binding.run { - Glide.with(itemView.context) - .load("https://picsum.photos/200") - .placeholder(R.drawable.base_profile_image) - .into(ivGroupImage) - - tvGroupName.text = item.groupName - tvIntroduction.text = item.groupIntroduce - tvMemberCount.text = item.memberCnt.toString() - tvRestaurantCount.text = item.restaurantCnt.toString() - } - } - } + binding: ItemSearchGroupBinding, + listener: ViewHolderBindListener + ): BaseViewHolder(binding, listener) override fun onBindViewHolder(holder: GroupWithSearchPreviewViewHolder, position: Int) { val item = getItem(position) @@ -63,7 +54,7 @@ class SearchCategoryGroupPreviewAdapter viewType: Int ): GroupWithSearchPreviewViewHolder { val binding = ItemSearchGroupBinding.inflate(LayoutInflater.from(parent.context), parent, false) - return GroupWithSearchPreviewViewHolder(binding) + return GroupWithSearchPreviewViewHolder(binding, listener) } } \ No newline at end of file