Skip to content

Commit

Permalink
[fix/restaurant_related_action]: 전체 검색 데이터 마이그레이션 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
dogdduddy authored and Jim-swit committed Mar 17, 2024
1 parent b51d01f commit 7b3cff7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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?,
Expand Down Expand Up @@ -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)
Expand All @@ -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()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<GroupInfo, SearchCategoryGroupAdapter.SearchCategoryGroupViewHolder>(
DiffCallback
) {
Expand All @@ -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<ItemSearchGroupBinding>(
binding, listener
)

override fun onBindViewHolder(
holder: SearchCategoryGroupViewHolder,
Expand All @@ -59,6 +52,6 @@ class SearchCategoryGroupAdapter() :
): SearchCategoryGroupViewHolder {
val binding =
ItemSearchGroupBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return SearchCategoryGroupViewHolder(binding)
return SearchCategoryGroupViewHolder(binding, listener)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<GroupPreview, SearchCategoryGroupPreviewAdapter.GroupWithSearchPreviewViewHolder>(
diffCallback
) {
Expand All @@ -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<ItemSearchGroupBinding>(binding, listener)

override fun onBindViewHolder(holder: GroupWithSearchPreviewViewHolder, position: Int) {
val item = getItem(position)
Expand All @@ -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)
}

}

0 comments on commit 7b3cff7

Please sign in to comment.