Skip to content

Commit

Permalink
[feat/mypage]: refactor to MultiViewType Rv
Browse files Browse the repository at this point in the history
  • Loading branch information
librarywon committed Jul 7, 2023
1 parent a50b3ef commit 3c07746
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import androidx.recyclerview.widget.GridLayoutManager
import com.teampophory.pophory.R
import com.teampophory.pophory.common.fragment.toast
import com.teampophory.pophory.common.view.GridSpacingItemDecoration
import com.teampophory.pophory.common.view.dp
import com.teampophory.pophory.common.view.viewBinding
import com.teampophory.pophory.databinding.FragmentMypageBinding
import com.teampophory.pophory.feature.home.mypage.adapter.MyPageAdapter
Expand Down Expand Up @@ -110,7 +111,7 @@ class MyPageFragment : Fragment() {
layoutManager = gridLayoutManager
adapter = myPageAdapter
isNestedScrollingEnabled = false
}.addItemDecoration(GridSpacingCustomDecoration(3, 2, false))
}.addItemDecoration(GridSpacingCustomDecoration(3, 2.dp, false))
}

private fun setOnClickListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import com.teampophory.pophory.databinding.ItemMypageProfileBinding
import com.teampophory.pophory.feature.home.mypage.MyPageDisplayItem

class MyPageAdapter(
private val onItemClicked: (MyPageDisplayItem.Photo) -> Unit
private val onItemClicked: (MyPageDisplayItem.Photo) -> Unit
) : ListAdapter<MyPageDisplayItem, RecyclerView.ViewHolder>(
ItemDiffCallback<MyPageDisplayItem>(
onItemsTheSame = { old, new -> old == new },
onContentsTheSame = { old, new -> old == new }
)
ItemDiffCallback<MyPageDisplayItem>(
onItemsTheSame = { old, new -> old == new },
onContentsTheSame = { old, new -> old == new }
)
) {
companion object {
const val VIEW_TYPE_PROFILE = 0
Expand All @@ -44,19 +44,19 @@ class MyPageAdapter(
return when (viewType) {
VIEW_TYPE_PROFILE -> {
val binding =
ItemMypageProfileBinding.inflate(LayoutInflater.from(context), parent, false)
ItemMypageProfileBinding.inflate(LayoutInflater.from(context), parent, false)
ProfileViewHolder(binding, context)
}

VIEW_TYPE_PHOTO -> {
val binding =
ItemMypageFeedBinding.inflate(LayoutInflater.from(context), parent, false)
ItemMypageFeedBinding.inflate(LayoutInflater.from(context), parent, false)
PhotoViewHolder(binding, onItemClicked)
}

VIEW_TYPE_EMPTY -> {
val binding =
ItemMypageEmptyBinding.inflate(LayoutInflater.from(context), parent, false)
ItemMypageEmptyBinding.inflate(LayoutInflater.from(context), parent, false)
EmptyViewHolder(binding)
}

Expand Down Expand Up @@ -127,8 +127,9 @@ class MyPageAdapter(
return spannableStringBuilder
}
}
class EmptyViewHolder(private val binding: ItemMypageEmptyBinding)
: RecyclerView.ViewHolder(binding.root) {

class EmptyViewHolder(private val binding: ItemMypageEmptyBinding) :
RecyclerView.ViewHolder(binding.root) {
}
}

0 comments on commit 3c07746

Please sign in to comment.