-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[REFACTOR/#192] 여행 대시 보드 뷰 / 코드 리팩토링 #197
Changes from all commits
12e039e
2aa939a
052f8c3
3d77d5e
31efe30
d497214
3365793
70d8808
604ff53
bbd32e5
2e4d758
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,18 @@ import com.going.presentation.databinding.ItemDashBoardCompletedBinding | |
import com.going.ui.extension.ItemDiffCallback | ||
|
||
class CompletedAdapter( | ||
private val listener: OnDashBoardSelectedListener | ||
private val itemDetailClick: (DashBoardTripModel) -> Unit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 람다로 수정해주는거 너무 좋아요 ~~~~ |
||
) : ListAdapter<DashBoardTripModel, CompletedViewHolder>(diffUtil) { | ||
|
||
interface OnDashBoardSelectedListener { | ||
fun onDashBoardSelectedListener(tripCreate: DashBoardTripModel) | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CompletedViewHolder { | ||
val inflater by lazy { LayoutInflater.from(parent.context) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거로 쓰는게 왜 좋게~요 |
||
val binding: ItemDashBoardCompletedBinding = | ||
ItemDashBoardCompletedBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
inflater, | ||
parent, | ||
false | ||
) | ||
return CompletedViewHolder(binding, listener) | ||
return CompletedViewHolder(binding, itemDetailClick) | ||
} | ||
|
||
override fun onBindViewHolder(holder: CompletedViewHolder, position: Int) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
package com.going.presentation.dashboard.triplist.completed | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.core.view.isVisible | ||
import androidx.fragment.app.activityViewModels | ||
import androidx.lifecycle.flowWithLifecycle | ||
import androidx.lifecycle.lifecycleScope | ||
import com.going.domain.entity.response.DashBoardModel.DashBoardTripModel | ||
import com.going.presentation.R | ||
import com.going.presentation.dashboard.DashBoardViewModel | ||
import com.going.presentation.dashboard.triplist.DashBoardDecoration | ||
import com.going.presentation.dashboard.triplist.ongoing.OngoingTripFragment | ||
import com.going.presentation.databinding.FragmentCompletedTripBinding | ||
import com.going.presentation.entertrip.StartTripSplashActivity | ||
import com.going.presentation.todo.TodoActivity | ||
import com.going.presentation.todo.TodoActivity.Companion.EXTRA_TRIP_ID | ||
import com.going.ui.base.BaseFragment | ||
import com.going.ui.extension.UiState | ||
import com.going.ui.extension.toast | ||
|
@@ -25,8 +20,7 @@ import kotlinx.coroutines.flow.onEach | |
|
||
@AndroidEntryPoint | ||
class CompletedTripFragment : | ||
BaseFragment<FragmentCompletedTripBinding>(R.layout.fragment_completed_trip), | ||
CompletedAdapter.OnDashBoardSelectedListener { | ||
BaseFragment<FragmentCompletedTripBinding>(R.layout.fragment_completed_trip) { | ||
|
||
private val viewModel by activityViewModels<DashBoardViewModel>() | ||
|
||
|
@@ -36,14 +30,19 @@ class CompletedTripFragment : | |
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
initAdapter() | ||
initAdapterWithClickListener() | ||
initItemDecoration() | ||
setTripList() | ||
observeDashBoardListState() | ||
} | ||
|
||
private fun initAdapter() { | ||
_adapter = CompletedAdapter(this) | ||
private fun initAdapterWithClickListener() { | ||
_adapter = CompletedAdapter { dashBoardTripModel -> | ||
TodoActivity.createIntent( | ||
requireContext(), | ||
dashBoardTripModel.tripId | ||
).apply { startActivity(this) } | ||
Comment on lines
+41
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 좋아용! 사용법 잘 알고있네요 ~~~ 안에 내용이 좀 길어진다 싶으면 따로 함수화해주어도 가독성이 더 좋아집니다 ! |
||
} | ||
binding.rvDashboardCompletedTrip.adapter = adapter | ||
} | ||
|
||
|
@@ -86,11 +85,4 @@ class CompletedTripFragment : | |
_adapter = null | ||
} | ||
|
||
override fun onDashBoardSelectedListener(tripCreate: DashBoardTripModel) { | ||
Intent(activity, TodoActivity::class.java).apply { | ||
putExtra(EXTRA_TRIP_ID, tripCreate.tripId) | ||
startActivity(this) | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,18 @@ import com.going.presentation.databinding.ItemDashBoardOngoingBinding | |
import com.going.ui.extension.ItemDiffCallback | ||
|
||
class OngoingAdapter( | ||
private val listener: OnDashBoardSelectedListener | ||
private val itemDetailClick: (DashBoardTripModel) -> Unit | ||
) : ListAdapter<DashBoardTripModel, OngoingViewHolder>(diffUtil) { | ||
|
||
interface OnDashBoardSelectedListener { | ||
fun onDashBoardSelectedListener(tripCreate: DashBoardTripModel) | ||
} | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OngoingViewHolder { | ||
val inflater by lazy { LayoutInflater.from(parent.context) } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 값이 할당된 후 바로 밑에서 사용되는데 by lazy를 사용한 이유는 뭘까요?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 동민이도 이거 알아오는거 숙제 ~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오호,,,생각해보도록 하겠습니닷 |
||
val binding: ItemDashBoardOngoingBinding = | ||
ItemDashBoardOngoingBinding.inflate( | ||
LayoutInflater.from(parent.context), | ||
inflater, | ||
parent, | ||
false | ||
) | ||
return OngoingViewHolder(binding, listener) | ||
return OngoingViewHolder(binding, itemDetailClick) | ||
} | ||
|
||
override fun onBindViewHolder(holder: OngoingViewHolder, position: Int) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋네욥 코드가 깔끔해진게 보여요 굿굿