Skip to content

Commit

Permalink
refactor: 변수명 복수형으로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
m6z1 committed Sep 15, 2024
1 parent a457da4 commit f0430cd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.dongyang.android.youdongknowme.standard.network.RetrofitObject
import com.dongyang.android.youdongknowme.standard.util.Weekdays

class CafeteriaRepository(
private val errorResponseHandler: ErrorResponseHandler,
private val errorResponseHandler: ErrorResponseHandler
) {
suspend fun fetchMenuList(): NetworkResult<List<Cafeteria>> {
return try {
Expand All @@ -21,7 +21,7 @@ class CafeteriaRepository(
}
}

fun fetchDaysMenu(todayDay: Weekdays): List<DaysMenu> {
fun fetchDaysMenus(todayDay: Weekdays): List<DaysMenu> {
return DaysMenu.values().filter { menu ->
menu.operatingDays.contains(todayDay)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ class CafeteriaFragment : BaseFragment<FragmentCafeteriaBinding, CafeteriaViewMo
showToast(getString(resId))
})

viewModel.koreaMenu.observe(viewLifecycleOwner) {
viewModel.koreaMenus.observe(viewLifecycleOwner) {
koreanMenuAdapter.submitList(it)
}

viewModel.daysMenu.observe(viewLifecycleOwner) {
viewModel.daysMenus.observe(viewLifecycleOwner) {
anotherMenuAdapter.submitList(it)
}
}
Expand Down Expand Up @@ -145,7 +145,7 @@ class CafeteriaFragment : BaseFragment<FragmentCafeteriaBinding, CafeteriaViewMo
viewModel = viewModel,
calendarView = binding.cvCafeteriaCalendar,
oldDate = viewModel.selectedDate.value,
selectedDate = findNearestMonday(LocalDate.now()),
selectedDate = findNearestMonday(LocalDate.now())
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class CafeteriaViewModel(
private val _cafeteriaList: MutableLiveData<List<Cafeteria>> = MutableLiveData()
val cafeteriaList: LiveData<List<Cafeteria>> = _cafeteriaList

private val _koreaMenu: MutableLiveData<List<String>> = MutableLiveData()
val koreaMenu: LiveData<List<String>> = _koreaMenu
private val _koreaMenus: MutableLiveData<List<String>> = MutableLiveData()
val koreaMenus: LiveData<List<String>> = _koreaMenus

private val _daysMenu: MutableLiveData<List<String>> = MutableLiveData()
val daysMenu: LiveData<List<String>> = _daysMenu
private val _daysMenus: MutableLiveData<List<String>> = MutableLiveData()
val daysMenus: LiveData<List<String>> = _daysMenus

private val emptyMenu = listOf(resourceProvider.getString(R.string.cafeteria_no_menu))

Expand Down Expand Up @@ -73,7 +73,7 @@ class CafeteriaViewModel(
val cafeteriaList = _cafeteriaList.value ?: emptyList()
_selectedDate.value = selectedDate
val selectedMenu = cafeteriaList.find { it.date == selectedDate.toString() }?.menus
_koreaMenu.postValue(
_koreaMenus.postValue(
if (selectedMenu.isNullOrEmpty()) {
emptyMenu
} else {
Expand All @@ -86,11 +86,11 @@ class CafeteriaViewModel(
viewModelScope.launch {
val dateToWeekday: Weekdays = Weekdays.from(selectedDate.dayOfWeek)
runCatching {
cafeteriaRepository.fetchDaysMenu(dateToWeekday)
}.onSuccess { daysMenu ->
cafeteriaRepository.fetchDaysMenus(dateToWeekday)
}.onSuccess { daysMenus ->
val formatter = DecimalFormat("#,###")
val formattedMenuWithPrice = daysMenu.map { "${it.menuNameKr} ${formatter.format(it.price)}" }
_daysMenu.value = formattedMenuWithPrice
val formattedMenuWithPrice = daysMenus.map { "${it.menuNameKr} ${formatter.format(it.price)}" }
_daysMenus.value = formattedMenuWithPrice
}.onFailure {
_isError.value = true
}
Expand Down

0 comments on commit f0430cd

Please sign in to comment.