Skip to content

Commit

Permalink
feat(FestivalListFragment): 축제 목록 불러오기 화면에 연동
Browse files Browse the repository at this point in the history
  • Loading branch information
SeongHoonC committed Jan 27, 2024
1 parent 03abd43 commit 610b10f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import com.festago.festago.presentation.ui.home.festivallist.festival.FestivalLi
import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalListUiState
import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalTabUiState
import com.festago.festago.presentation.util.repeatOnStarted
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class FestivalListFragment : Fragment() {

private var _binding: FragmentFestivalListBinding? = null
Expand Down Expand Up @@ -53,7 +55,7 @@ class FestivalListFragment : Fragment() {

private fun initView() {
initViewPager()
vm.loadPopularFestival()
vm.loadFestivals()
initRecyclerView()
}

Expand Down Expand Up @@ -103,7 +105,7 @@ class FestivalListFragment : Fragment() {
{
Toast.makeText(requireContext(), "Clicked $it", Toast.LENGTH_SHORT).show()
/* TODO: Handle tab click */
vm.loadPopularFestival()
vm.loadFestivals()
},
),
) + uiState.festivals,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FestivalListAdapter : ListAdapter<Any, FestivalListViewHolder>(diffUtil) {
override fun onBindViewHolder(holder: FestivalListViewHolder, position: Int) {
val item = getItem(position)
return when (holder) {
is FestivalListPopularViewHolder -> holder.bind((item as FestivalListUiState.Success).festivals)
is FestivalListPopularViewHolder -> holder.bind((item as FestivalListUiState.Success).popularFestivals)
is FestivalListFestivalViewHolder -> holder.bind(item as FestivalItemUiState)
is FestivalListTabViewHolder -> holder.bind(item as FestivalTabUiState)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import android.view.ViewGroup
import com.festago.festago.presentation.databinding.ItemFestivalListPopularBinding
import com.festago.festago.presentation.ui.home.festivallist.popularfestival.PopularFestivalViewPagerAdapter
import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalItemUiState
import com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalListUiState
import com.google.android.material.tabs.TabLayoutMediator

class FestivalListPopularViewHolder(val binding: ItemFestivalListPopularBinding) :
Expand All @@ -25,10 +24,6 @@ class FestivalListPopularViewHolder(val binding: ItemFestivalListPopularBinding)

fun bind(festivals: List<FestivalItemUiState>) {
popularFestivalViewPager.submitList(festivals)
binding.uiState = FestivalListUiState.Success(
popularFestivals = festivals,
festivals = festivals,
)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<data>

<variable
name="uiState"
type="com.festago.festago.presentation.ui.home.festivallist.uistate.FestivalListUiState" />
</data>

<androidx.constraintlayout.widget.ConstraintLayout
visibility="@{uiState.shouldShowSuccess}"
android:layout_width="match_parent"
android:layout_height="wrap_content">

Expand All @@ -20,7 +12,7 @@
android:layout_height="0dp"
android:layout_marginBottom="-8dp"
app:layout_constraintBottom_toBottomOf="@id/tlDotIndicator"
app:layout_constraintTop_toTopOf="parent"/>
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/tvPopularFestivalTitle"
Expand Down

0 comments on commit 610b10f

Please sign in to comment.