fix(home): 팔로잉 크리에이터 전체 버튼을 고정한다
This commit is contained in:
@@ -115,8 +115,7 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
||||
private val popularCommunityAdapter = HomePopularCommunityAdapter { openPopularCommunityPost(it) }
|
||||
private val creatorRankingAdapter = CreatorRankingAdapter { openCreatorRankingProfile(it) }
|
||||
private val followingCreatorAdapter = HomeFollowingCreatorAdapter(
|
||||
onClickItem = { openCreatorProfile(it.creatorId) },
|
||||
onClickAll = { openFollowingCreatorAll() }
|
||||
onClickItem = { openCreatorProfile(it.creatorId) }
|
||||
)
|
||||
private val followingLiveAdapter = HomeFollowingLiveAdapter { onFollowingLiveClick(it) }
|
||||
private val followingChatAdapter = HomeFollowingChatAdapter { openFollowingChat(it) }
|
||||
@@ -264,6 +263,7 @@ class HomeMainFragment : BaseFragment<FragmentV2MainHomeBinding>(
|
||||
}
|
||||
|
||||
private fun setUpFollowingAdapters() {
|
||||
binding.tvHomeFollowingCreatorAll.setOnClickListener { openFollowingCreatorAll() }
|
||||
binding.rvHomeFollowingCreators.apply {
|
||||
layoutManager = LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false)
|
||||
adapter = followingCreatorAdapter
|
||||
|
||||
+9
-35
@@ -10,9 +10,8 @@ import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeFollowingCreatorUiItem
|
||||
|
||||
class HomeFollowingCreatorAdapter(
|
||||
private val onClickItem: (HomeFollowingCreatorUiItem) -> Unit = {},
|
||||
private val onClickAll: () -> Unit = {}
|
||||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
private val onClickItem: (HomeFollowingCreatorUiItem) -> Unit = {}
|
||||
) : RecyclerView.Adapter<HomeFollowingCreatorAdapter.CreatorViewHolder>() {
|
||||
private var items: List<HomeFollowingCreatorUiItem> = emptyList()
|
||||
|
||||
fun submitItems(items: List<HomeFollowingCreatorUiItem>) {
|
||||
@@ -20,29 +19,18 @@ class HomeFollowingCreatorAdapter(
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val layoutResId = when (viewType) {
|
||||
VIEW_TYPE_ALL -> R.layout.item_home_following_creator_all
|
||||
else -> R.layout.item_home_following_creator
|
||||
}
|
||||
val view = LayoutInflater.from(parent.context).inflate(layoutResId, parent, false)
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CreatorViewHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.item_home_following_creator, parent, false)
|
||||
view.layoutParams = recyclerItemLayoutParams(parent)
|
||||
return when (viewType) {
|
||||
VIEW_TYPE_ALL -> AllViewHolder(view, onClickAll)
|
||||
else -> CreatorViewHolder(view, onClickItem)
|
||||
}
|
||||
return CreatorViewHolder(view, onClickItem)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
when (holder) {
|
||||
is AllViewHolder -> holder.bind()
|
||||
is CreatorViewHolder -> holder.bind(items[position])
|
||||
}
|
||||
override fun onBindViewHolder(holder: CreatorViewHolder, position: Int) {
|
||||
holder.bind(items[position])
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = items.size + if (items.isNotEmpty()) 1 else 0
|
||||
|
||||
override fun getItemViewType(position: Int): Int = if (position < items.size) VIEW_TYPE_CREATOR else VIEW_TYPE_ALL
|
||||
override fun getItemCount(): Int = items.size
|
||||
|
||||
class CreatorViewHolder(
|
||||
itemView: View,
|
||||
@@ -57,18 +45,4 @@ class HomeFollowingCreatorAdapter(
|
||||
itemView.setOnClickListener { onClickItem(item) }
|
||||
}
|
||||
}
|
||||
|
||||
class AllViewHolder(
|
||||
itemView: View,
|
||||
private val onClickAll: () -> Unit
|
||||
) : RecyclerView.ViewHolder(itemView) {
|
||||
fun bind() {
|
||||
itemView.setOnClickListener { onClickAll() }
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val VIEW_TYPE_CREATOR = 0
|
||||
private const val VIEW_TYPE_ALL = 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,17 +276,29 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/spacing_12"
|
||||
android:orientation="vertical">
|
||||
android:orientation="horizontal">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_home_following_creators"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:clipToPadding="false"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="@dimen/spacing_14"
|
||||
android:paddingHorizontal="@dimen/spacing_20"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
tools:listitem="@layout/item_home_following_creator" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_home_following_creator_all"
|
||||
style="@style/Typography.Body5"
|
||||
android:layout_width="@dimen/home_live_more_width"
|
||||
android:layout_height="@dimen/home_live_row_height"
|
||||
android:layout_marginEnd="@dimen/spacing_20"
|
||||
android:background="@color/black"
|
||||
android:gravity="center"
|
||||
android:text="@string/screen_home_theme_all"
|
||||
android:textColor="@color/soda_400" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="16dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_home_following_creator_all"
|
||||
style="@style/Typography.Body5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="75dp"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:text="@string/screen_home_theme_all"
|
||||
android:textColor="@color/soda_400" />
|
||||
|
||||
<TextView
|
||||
style="@style/Typography.Body5"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/spacing_6"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:text="@string/screen_home_theme_all"
|
||||
android:visibility="invisible" />
|
||||
</LinearLayout>
|
||||
+13
-14
@@ -316,29 +316,28 @@ class HomeFollowingFragmentSourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `팔로잉 크리에이터 목록은 전체 item을 마지막에 추가하고 이동을 연결한다`() {
|
||||
fun `팔로잉 크리에이터 전체 버튼은 목록 밖에 고정하고 이동을 연결한다`() {
|
||||
val layout = homeMainLayoutSource()
|
||||
val section = layout.substringAfter("@+id/ll_home_following_creators_section")
|
||||
.substringBefore("@+id/ll_home_following_on_air_section")
|
||||
val adapter = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowingCreatorAdapter.kt"
|
||||
).readText()
|
||||
val fragment = homeMainFragmentSource()
|
||||
val allLayoutFile = projectFileOrNull("app/src/main/res/layout/item_home_following_creator_all.xml")
|
||||
|
||||
assertTrue(allLayoutFile != null)
|
||||
val allLayout = allLayoutFile?.readText().orEmpty()
|
||||
|
||||
assertTrue(adapter.contains("VIEW_TYPE_CREATOR"))
|
||||
assertTrue(adapter.contains("VIEW_TYPE_ALL"))
|
||||
assertTrue(adapter.contains("getItemViewType(position: Int)"))
|
||||
assertTrue(adapter.contains("if (position < items.size) VIEW_TYPE_CREATOR else VIEW_TYPE_ALL"))
|
||||
assertTrue(adapter.contains("override fun getItemCount(): Int = items.size + if (items.isNotEmpty()) 1 else 0"))
|
||||
assertTrue(adapter.contains("R.layout.item_home_following_creator_all"))
|
||||
assertTrue(adapter.contains("AllViewHolder"))
|
||||
assertTrue(section.contains("@+id/rv_home_following_creators"))
|
||||
assertTrue(section.contains("@+id/tv_home_following_creator_all"))
|
||||
assertTrue(adapter.contains("override fun getItemCount(): Int = items.size"))
|
||||
assertFalse(adapter.contains("VIEW_TYPE_ALL"))
|
||||
assertFalse(adapter.contains("AllViewHolder"))
|
||||
assertFalse(adapter.contains("item_home_following_creator_all"))
|
||||
assertTrue(projectFileOrNull("app/src/main/res/layout/item_home_following_creator_all.xml") == null)
|
||||
assertTrue(fragment.contains("import kr.co.vividnext.sodalive.following.FollowingCreatorActivity"))
|
||||
assertTrue(fragment.contains("HomeFollowingCreatorAdapter("))
|
||||
assertTrue(fragment.contains("onClickAll = { openFollowingCreatorAll() }"))
|
||||
assertTrue(fragment.contains("binding.tvHomeFollowingCreatorAll.setOnClickListener"))
|
||||
assertTrue(fragment.contains("openFollowingCreatorAll()"))
|
||||
assertTrue(fragment.contains("private fun openFollowingCreatorAll()"))
|
||||
assertTrue(fragment.contains("startActivity(Intent(requireContext(), FollowingCreatorActivity::class.java))"))
|
||||
assertTrue(allLayout.contains("@string/screen_home_theme_all"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user