From f0430cd57a73010bd872c0df3b2dc54e1b2ff9ba Mon Sep 17 00:00:00 2001 From: Son Myeongji <114990782+m6z1@users.noreply.github.com> Date: Sun, 15 Sep 2024 22:44:15 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EB=B3=B5=EC=88=98=ED=98=95=EC=9C=BC=EB=A1=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/repository/CafeteriaRepository.kt | 4 ++-- .../ui/view/cafeteria/CafeteriaFragment.kt | 6 +++--- .../ui/view/cafeteria/CafeteriaViewModel.kt | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/dongyang/android/youdongknowme/data/repository/CafeteriaRepository.kt b/app/src/main/java/com/dongyang/android/youdongknowme/data/repository/CafeteriaRepository.kt index fcb06d76..0c4d13f8 100644 --- a/app/src/main/java/com/dongyang/android/youdongknowme/data/repository/CafeteriaRepository.kt +++ b/app/src/main/java/com/dongyang/android/youdongknowme/data/repository/CafeteriaRepository.kt @@ -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> { return try { @@ -21,7 +21,7 @@ class CafeteriaRepository( } } - fun fetchDaysMenu(todayDay: Weekdays): List { + fun fetchDaysMenus(todayDay: Weekdays): List { return DaysMenu.values().filter { menu -> menu.operatingDays.contains(todayDay) } diff --git a/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CafeteriaFragment.kt b/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CafeteriaFragment.kt index 1712c599..b4e8189c 100644 --- a/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CafeteriaFragment.kt +++ b/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CafeteriaFragment.kt @@ -86,11 +86,11 @@ class CafeteriaFragment : BaseFragment> = MutableLiveData() val cafeteriaList: LiveData> = _cafeteriaList - private val _koreaMenu: MutableLiveData> = MutableLiveData() - val koreaMenu: LiveData> = _koreaMenu + private val _koreaMenus: MutableLiveData> = MutableLiveData() + val koreaMenus: LiveData> = _koreaMenus - private val _daysMenu: MutableLiveData> = MutableLiveData() - val daysMenu: LiveData> = _daysMenu + private val _daysMenus: MutableLiveData> = MutableLiveData() + val daysMenus: LiveData> = _daysMenus private val emptyMenu = listOf(resourceProvider.getString(R.string.cafeteria_no_menu)) @@ -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 { @@ -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 }