Skip to content

Commit

Permalink
[MOD/#30] 코드 최적화
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Jan 7, 2024
1 parent b920e63 commit 520e774
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import androidx.viewpager2.adapter.FragmentStateAdapter
import com.going.presentation.tripdashboard.triplist.CompletedTripFragment
import com.going.presentation.tripdashboard.triplist.OngoingTripFragment

class DashBoardViewPagerAdapter(fragment: FragmentActivity) : FragmentStateAdapter(fragment){
class DashBoardViewPagerAdapter(fragment: FragmentActivity) : FragmentStateAdapter(fragment) {
override fun getItemCount(): Int = 2

override fun createFragment(position: Int): Fragment {
return when(position){
return when (position) {
0 -> OngoingTripFragment()
else -> CompletedTripFragment()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,69 @@ import com.going.domain.entity.response.TripCreateListModel

class TripDashBoardViewModel : ViewModel() {

val mockDataList : List<TripCreateListModel> = listOf(
val mockDataList: List<TripCreateListModel> = listOf(
TripCreateListModel(
title = "굉굉이랑 합숙",
startDate = "2024.03.24",
endDate = "2024.03.31",
day = 16
),
TripCreateListModel(
title ="여행 제목 자리",
title = "여행 제목 자리",
startDate = "2024.03.24",
endDate = "2024.03.31",
day = 16
),
TripCreateListModel(
title ="상호랑 제주도 여행",
title = "상호랑 제주도 여행",
startDate = "2025.03.24",
endDate = "2025.03.31",
day = 100
),
TripCreateListModel(
title ="동민이랑 서울 구경",
title = "동민이랑 서울 구경",
startDate = "2026.03.24",
endDate = "2026.03.31",
day = 200
),
TripCreateListModel(
title ="유빈이랑 부산 여행",
title = "유빈이랑 부산 여행",
startDate = "2027.03.24",
endDate = "2027.03.31",
day = 300
),
TripCreateListModel(
title ="세연이랑 바다 구경",
title = "세연이랑 바다 구경",
startDate = "2028.03.24",
endDate = "2028.03.31",
day = 400
),
TripCreateListModel(
title ="솝트랑 MT",
title = "솝트랑 MT",
startDate = "2021.03.24",
endDate = "2021.03.31",
day = -10
),
TripCreateListModel(
title ="굉굉 신년회",
title = "굉굉 신년회",
startDate = "2024.01.02",
endDate = "2024.01.32",
day = -10
),
TripCreateListModel(
title ="안드 단체 여행",
title = "안드 단체 여행",
startDate = "2020.03.24",
endDate = "2021.03.31",
day = -100
),
TripCreateListModel(
title ="유빈이 생일 파티",
title = "유빈이 생일 파티",
startDate = "2022.09.22",
endDate = "2022.09.23",
day = -120
),
TripCreateListModel(
title ="두릅",
title = "두릅",
startDate = "2003.03.24",
endDate = "2004.03.31",
day = -1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ TripListAdapter.OnDashBoardSelectedListener{
super.onDestroyView()
_adapter = null
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class OngoingTripFragment :
private var _adapter: TripListAdapter? = null
private val adapter get() = requireNotNull(_adapter) { getString(R.string.adapter_not_initialized_error_msg) }

// private val itemDeco = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

Expand All @@ -40,7 +39,7 @@ class OngoingTripFragment :
adapter.submitList(viewModel.mockDataList)
}

private fun initItemDecoration(){
private fun initItemDecoration() {
val itemDeco = TripDecoration(requireContext())
binding.rvDashboardOngoingTrip.addItemDecoration(itemDeco)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class TripListAdapter(
holder.onBind(getItem(position))
}



companion object {
private val diffUtil = ItemDiffCallback<TripCreateListModel>(
onItemsTheSame = { old, new -> old.title == new.title },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TripListViewHolder(
) : RecyclerView.ViewHolder(binding.root) {

fun onBind(item: TripCreateListModel) {
binding.run{
binding.run {
tvDashboardTripTitle.text = item.title
tvDashboardDateStart.text = item.startDate
tvDashboardDateEnd.text = item.endDate
Expand Down
3 changes: 2 additions & 1 deletion presentation/src/main/res/layout/fragment_completed_trip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/gray_50">

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_dashboard_completed_trip"
Expand Down

0 comments on commit 520e774

Please sign in to comment.