Skip to content

Commit

Permalink
[fix] : adpater 도메인 영역 entity로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
chanubc committed Jan 2, 2024
1 parent 494c87f commit 2ba0067
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import org.sopt.dosopttemplate.data.dto.remote.respose.ResponseReqresDto
import org.sopt.dosopttemplate.databinding.ItemCarouselIntroduceBinding
import org.sopt.dosopttemplate.domain.entity.ReqresEntity

class CarouselUserAdapter(context: Context) :
ListAdapter<ResponseReqresDto.Data, CarouselUserAdapter.CarouseViewHolder>(diffUtil) {
ListAdapter<ReqresEntity, CarouselUserAdapter.CarouseViewHolder>(diffUtil) {
private val inflater by lazy { LayoutInflater.from(context) }

inner class CarouseViewHolder(private val binding: ItemCarouselIntroduceBinding) :
RecyclerView.ViewHolder(binding.root) {
fun bind(data: ResponseReqresDto.Data) {
fun bind(data: ReqresEntity) {
Glide.with(itemView)
.load(data.avatar)
.into(binding.imgCarousel)
Expand All @@ -36,23 +36,23 @@ class CarouselUserAdapter(context: Context) :
override fun getItemCount() = currentList.size

// submitList 사용
fun setCarouselList(imgList: List<ResponseReqresDto.Data>) {
fun setCarouselList(imgList: List<ReqresEntity>) {
submitList(imgList.toMutableList())
}

// diffUtill callback
companion object {
private var diffUtil = object : DiffUtil.ItemCallback<ResponseReqresDto.Data>() {
private var diffUtil = object : DiffUtil.ItemCallback<ReqresEntity>() {
override fun areItemsTheSame(
oldItem: ResponseReqresDto.Data,
newItem: ResponseReqresDto.Data,
oldItem: ReqresEntity,
newItem: ReqresEntity,
): Boolean {
return oldItem.id == newItem.id
}

override fun areContentsTheSame(
oldItem: ResponseReqresDto.Data,
newItem: ResponseReqresDto.Data,
oldItem: ReqresEntity,
newItem: ReqresEntity,
): Boolean {
return oldItem == newItem
}
Expand Down

0 comments on commit 2ba0067

Please sign in to comment.