Skip to content

Commit

Permalink
[FIX/#73] 코드리뷰 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
leeeyubin committed Jan 12, 2024
1 parent 1c62950 commit 0348fe8
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 39 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

<activity
android:name="com.going.presentation.dashboard.DashBoardActivity"
android:exported="false"
android:exported="true"
android:screenOrientation="portrait" />

<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import com.going.data.dto.BaseResponse
import com.going.data.dto.response.DashBoardResponseDto

interface DashBoardDataSource {

suspend fun getTripList(
progress: String
): BaseResponse<DashBoardResponseDto>

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import javax.inject.Inject
class DashBoardDataSourceImpl @Inject constructor(
private val dashBoardService: DashBoardService
) : DashBoardDataSource {

override suspend fun getTripList(progress: String): BaseResponse<DashBoardResponseDto> =
dashBoardService.getTripList(progress)

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ data class DashBoardResponseDto(
DashBoardModel.DashBoardTripModel(tripId, title, startDate, endDate, day)
}

fun toDashBoardEntity() =
fun toDashBoardModel() =
DashBoardModel(name, trips.map {
it.toTripsModel()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import javax.inject.Inject
class DashBoardRepositoryImpl @Inject constructor(
private val dashBoardSource: DashBoardDataSource
) : DashBoardRepository {

override suspend fun getDashBoardList(
progress: String
): Result<DashBoardModel> =
runCatching {
dashBoardSource.getTripList(progress).data.toDashBoardEntity()
dashBoardSource.getTripList(progress).data.toDashBoardModel()
}

}
2 changes: 2 additions & 0 deletions data/src/main/java/com/going/data/service/DashBoardService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import retrofit2.http.GET
import retrofit2.http.Query

interface DashBoardService {

@GET("api/trips")
suspend fun getTripList(
@Query("progress") progress: String
) : BaseResponse<DashBoardResponseDto>

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.going.presentation.dashboard
import android.os.Bundle
import androidx.activity.viewModels
import com.going.presentation.R
import com.going.presentation.dashboard.triplist.OngoingTripFragment
import com.going.presentation.databinding.ActivityTripDashBoardBinding
import com.going.ui.base.BaseActivity
import com.google.android.material.tabs.TabLayoutMediator
Expand All @@ -16,8 +17,6 @@ class DashBoardActivity :

private val viewModel by viewModels<DashBoardViewModel>()

var name: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand Down Expand Up @@ -46,7 +45,7 @@ class DashBoardActivity :
}

private fun setTravelerName() {
val progress = "incomplete"
val progress = DashBoardViewModel.COMPLETED
viewModel.getTravelerNameFromServer(progress)
viewModel.name.observe(this) { travelerName ->
binding.tvDashboardTitle.text = getString(R.string.dashboard_tv_title, travelerName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DashBoardViewModel @Inject constructor(
private val _dashBoardCompletedListState =
MutableStateFlow<UiState<DashBoardModel>>(UiState.Empty)

val name = MutableLiveData<String?>()
val name = MutableLiveData("")

val dashBoardCompletedListState: StateFlow<UiState<DashBoardModel>> get() = _dashBoardCompletedListState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package com.going.presentation.dashboard.triplist
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import com.going.domain.entity.response.DashBoardModel
import com.going.domain.entity.response.DashBoardModel.DashBoardTripModel
import com.going.presentation.databinding.ItemDashBoardCompletedBinding
import com.going.ui.extension.ItemDiffCallback

class CompletedAdapter(
private val listener: OnDashBoardSelectedListener
) : ListAdapter<DashBoardModel.DashBoardTripModel, CompletedViewHolder>(diffUtil) {
) : ListAdapter<DashBoardTripModel, CompletedViewHolder>(diffUtil) {

interface OnDashBoardSelectedListener {
fun onDashBoardSelectedListener(tripCreate: DashBoardModel.DashBoardTripModel)
fun onDashBoardSelectedListener(tripCreate: DashBoardTripModel)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CompletedViewHolder {
Expand All @@ -30,7 +30,7 @@ class CompletedAdapter(
}

companion object {
private val diffUtil = ItemDiffCallback<DashBoardModel.DashBoardTripModel>(
private val diffUtil = ItemDiffCallback<DashBoardTripModel>(
onItemsTheSame = { old, new -> old.title == new.title },
onContentsTheSame = { old, new -> old == new },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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
import com.going.domain.entity.response.DashBoardModel.DashBoardTripModel
import com.going.presentation.R
import com.going.presentation.dashboard.DashBoardViewModel
import com.going.presentation.databinding.FragmentCompletedTripBinding
Expand All @@ -30,14 +30,14 @@ class CompletedTripFragment :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

setRecyclerView()
initAdapter()
initItemDecoration()
setTripList()
observeDashBoardListState()

}

private fun setRecyclerView() {
private fun initAdapter() {
_adapter = CompletedAdapter(this)
binding.rvDashboardCompletedTrip.adapter = adapter
}
Expand Down Expand Up @@ -80,7 +80,7 @@ class CompletedTripFragment :
_adapter = null
}

override fun onDashBoardSelectedListener(tripCreate: DashBoardModel.DashBoardTripModel) {
override fun onDashBoardSelectedListener(tripCreate: DashBoardTripModel) {

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.going.presentation.dashboard.triplist

import androidx.recyclerview.widget.RecyclerView
import com.going.domain.entity.response.DashBoardModel
import com.going.domain.entity.response.DashBoardModel.DashBoardTripModel
import com.going.presentation.R
import com.going.presentation.databinding.ItemDashBoardCompletedBinding
import com.going.ui.extension.setOnSingleClickListener
Expand All @@ -11,7 +11,7 @@ class CompletedViewHolder(
private val listener: CompletedAdapter.OnDashBoardSelectedListener
) : RecyclerView.ViewHolder(binding.root) {

fun onBind(item: DashBoardModel.DashBoardTripModel) {
fun onBind(item: DashBoardTripModel) {

binding.run {
tvDashboardTripTitle.text = item.title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package com.going.presentation.dashboard.triplist
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.ListAdapter
import com.going.domain.entity.response.DashBoardModel
import com.going.domain.entity.response.DashBoardModel.DashBoardTripModel
import com.going.presentation.databinding.ItemDashBoardOngoingBinding
import com.going.ui.extension.ItemDiffCallback

class OngoingAdapter(
private val listener: OnDashBoardSelectedListener
) : ListAdapter<DashBoardModel.DashBoardTripModel, OngoingViewHolder>(diffUtil) {
) : ListAdapter<DashBoardTripModel, OngoingViewHolder>(diffUtil) {

interface OnDashBoardSelectedListener {
fun onDashBoardSelectedListener(tripCreate: DashBoardModel.DashBoardTripModel)
fun onDashBoardSelectedListener(tripCreate: DashBoardTripModel)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OngoingViewHolder {
Expand All @@ -30,7 +30,7 @@ class OngoingAdapter(
}

companion object {
private val diffUtil = ItemDiffCallback<DashBoardModel.DashBoardTripModel>(
private val diffUtil = ItemDiffCallback<DashBoardTripModel>(
onItemsTheSame = { old, new -> old.title == new.title },
onContentsTheSame = { old, new -> old == new },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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
import com.going.domain.entity.response.DashBoardModel.DashBoardTripModel
import com.going.presentation.R
import com.going.presentation.dashboard.DashBoardViewModel
import com.going.presentation.databinding.FragmentOngoingTripBinding
Expand All @@ -30,15 +30,15 @@ class OngoingTripFragment :
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

setRecyclerView()
initAdapter()
initItemDecoration()
setTripList()
observeDashBoardListState()

}


private fun setRecyclerView() {
private fun initAdapter() {
_adapter = OngoingAdapter(this)
binding.rvDashboardOngoingTrip.adapter = adapter
}
Expand Down Expand Up @@ -80,7 +80,7 @@ class OngoingTripFragment :
_adapter = null
}

override fun onDashBoardSelectedListener(tripCreate: DashBoardModel.DashBoardTripModel) {
override fun onDashBoardSelectedListener(tripCreate: DashBoardTripModel) {

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.going.presentation.dashboard.triplist

import androidx.recyclerview.widget.RecyclerView
import com.going.domain.entity.response.DashBoardModel
import com.going.domain.entity.response.DashBoardModel.DashBoardTripModel
import com.going.presentation.R
import com.going.presentation.databinding.ItemDashBoardOngoingBinding
import com.going.ui.extension.setOnSingleClickListener
Expand All @@ -11,7 +11,7 @@ class OngoingViewHolder(
private val listener: OngoingAdapter.OnDashBoardSelectedListener
) : RecyclerView.ViewHolder(binding.root) {

fun onBind(item: DashBoardModel.DashBoardTripModel) {
fun onBind(item: DashBoardTripModel) {
binding.run {
tvDashboardTripTitle.text = item.title
tvDashboardDateStart.text = item.startDate
Expand Down
15 changes: 9 additions & 6 deletions presentation/src/main/res/layout/fragment_completed_trip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -37,10 +38,9 @@

<TextView
android:id="@+id/tv_dashboard_empty"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="28dp"
android:gravity="center"
android:text="@string/dashboard_tv_empty"
android:textColor="@color/gray_200"
app:layout_constraintBottom_toTopOf="@id/iv_dashboard_empty"
Expand All @@ -49,12 +49,15 @@

<ImageView
android:id="@+id/iv_dashboard_empty"
android:layout_width="210dp"
android:layout_height="324dp"
android:layout_marginBottom="100dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_empty_dashboard_doorip"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.67" />


</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down
13 changes: 7 additions & 6 deletions presentation/src/main/res/layout/fragment_ongoing_trip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@

<TextView
android:id="@+id/tv_dashboard_empty"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="28dp"
android:gravity="center"
android:text="@string/dashboard_tv_empty"
android:textColor="@color/gray_200"
app:layout_constraintBottom_toTopOf="@id/iv_dashboard_empty"
Expand All @@ -50,12 +49,14 @@

<ImageView
android:id="@+id/iv_dashboard_empty"
android:layout_width="210dp"
android:layout_height="324dp"
android:layout_marginBottom="100dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_empty_dashboard_doorip"
app:layout_constrainedHeight="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.67" />

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down

0 comments on commit 0348fe8

Please sign in to comment.