From 1a1c3a34e3d78b4713921c16fa4ef641fcaa0f7c Mon Sep 17 00:00:00 2001 From: Son Myeongji <114990782+m6z1@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:09:27 +0900 Subject: [PATCH 1/8] =?UTF-8?q?feat:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20API=5FKEY=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 1 - .../android/youdongknowme/standard/network/RetrofitObject.kt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0d0b882f..73f40764 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,7 +18,6 @@ android { versionCode 11 versionName "2.0.1" - buildConfigField "String", "API_KEY", properties['API_KEY'] buildConfigField "String", "BASE_URL", properties['BASE_URL'] testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/dongyang/android/youdongknowme/standard/network/RetrofitObject.kt b/app/src/main/java/com/dongyang/android/youdongknowme/standard/network/RetrofitObject.kt index de816d56..9cfc5834 100644 --- a/app/src/main/java/com/dongyang/android/youdongknowme/standard/network/RetrofitObject.kt +++ b/app/src/main/java/com/dongyang/android/youdongknowme/standard/network/RetrofitObject.kt @@ -16,7 +16,7 @@ object RetrofitObject { val request = chain.request().newBuilder() val originalHttpUrl = chain.request().url - val url = originalHttpUrl.newBuilder().addQueryParameter("api_key", BuildConfig.API_KEY) + val url = originalHttpUrl.newBuilder() .build() request.url(url) chain.proceed(request.build()) From 4fdabbdce67e75f69b60b64b78aa7db791fcedb7 Mon Sep 17 00:00:00 2001 From: Son Myeongji <114990782+m6z1@users.noreply.github.com> Date: Fri, 13 Sep 2024 10:30:35 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20=ED=95=99=EC=8B=9D=20=EC=9A=B4?= =?UTF-8?q?=EC=98=81=20=EC=8B=9C=EA=B0=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/values/strings.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0f257cec..eeb8a4bf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -122,12 +122,11 @@ 학생식당 메뉴 점심 - 11:30 - 14:00, 16:30 - 18:00 + 11:00 - 14:00, 16:30 - 18:00 8호관 3층 😅 등록된 메뉴가 없어요. 🍚 한식 🍛 일품 - 라면 3,500원 / 치즈라면 4,000원 / 해물라면 4,500원 / 돈까스 5,500원 / 치즈돈까스 5,500원 / 고구마치즈돈까스 6,000원 / 스팸김치볶음밥 4,900원 / 치킨마요덮밥 4,500원 / 불닭마요덮밥 4,500원 / 오므라이스 5,500원 오픈소스 라이센스 From 7d74204eb0b4c0ca19f4af1a4ccbfa4111068f82 Mon Sep 17 00:00:00 2001 From: Son Myeongji <114990782+m6z1@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:20:03 +0900 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20=EC=9D=BC=ED=92=88=20=EC=8B=9D?= =?UTF-8?q?=EB=8B=A8=20=EB=A9=94=EB=89=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/repository/CafeteriaRepository.kt | 29 +++++++++++++- .../youdongknowme/standard/util/Weekdays.kt | 25 ++++++++++++ .../ui/view/cafeteria/CafeteriaFragment.kt | 40 ++++++++++--------- .../ui/view/cafeteria/CafeteriaViewModel.kt | 26 ++++++++++-- .../ui/view/cafeteria/CalendarInterface.kt | 1 + 5 files changed, 97 insertions(+), 24 deletions(-) create mode 100644 app/src/main/java/com/dongyang/android/youdongknowme/standard/util/Weekdays.kt 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 d92dab7e..77561d56 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 @@ -5,17 +5,42 @@ import com.dongyang.android.youdongknowme.data.remote.service.CafeteriaService import com.dongyang.android.youdongknowme.standard.network.ErrorResponseHandler import com.dongyang.android.youdongknowme.standard.network.NetworkResult 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 { - val response = RetrofitObject.getNetwork().create(CafeteriaService::class.java).getMenuList() + val response = + RetrofitObject.getNetwork().create(CafeteriaService::class.java).getMenuList() NetworkResult.Success(response) } catch (exception: Exception) { val error = errorResponseHandler.getError(exception) NetworkResult.Error(error) } } + + fun fetchAnotherMenus(todayDay: Weekdays): List { + return DaysMenu.values().filter { menu -> + menu.operatingDays.contains(todayDay) + } + } + + enum class DaysMenu( + val menuNameKr: String, + val price: Int, + val operatingDays: List, + ) { + PORKCUTLET("돈까스", 5_000, Weekdays.values().toList()), + CHEESE_PORKCUTLET("치즈돈까스", 5_500, Weekdays.values().toList()), + SWEET_POTATO_CHEESE_PORKCUTLET("고구마치즈돈까스", 6_000, Weekdays.values().toList()), + RAMEN("라면", 3_500, Weekdays.values().toList()), + CHEESE_RAMEN("치즈라면", 4_000, Weekdays.values().toList()), + SEAFOOD_RAMEN("해물라면", 4_500, Weekdays.values().toList()), + SPAM_KIMCHI_FRIED_RICE("스팸김치볶음밥", 4_900, listOf(Weekdays.MONDAY, Weekdays.TUESDAY)), + HOT_CHICKEN_MAYO_RICE("불닭마요덮밥", 4_500, listOf(Weekdays.WEDNESDAY, Weekdays.THURSDAY)), + CHICKEN_MAYO_RICE("치킨마요덮밥", 4_500, listOf(Weekdays.WEDNESDAY, Weekdays.THURSDAY)), + OMELET_RICE("오므라이스", 5_500, listOf(Weekdays.FRIDAY)); + } } \ No newline at end of file diff --git a/app/src/main/java/com/dongyang/android/youdongknowme/standard/util/Weekdays.kt b/app/src/main/java/com/dongyang/android/youdongknowme/standard/util/Weekdays.kt new file mode 100644 index 00000000..acc3381f --- /dev/null +++ b/app/src/main/java/com/dongyang/android/youdongknowme/standard/util/Weekdays.kt @@ -0,0 +1,25 @@ +package com.dongyang.android.youdongknowme.standard.util + +import java.time.DayOfWeek + +enum class Weekdays(val dayKr: String) { + MONDAY("월"), + TUESDAY("화"), + WEDNESDAY("수"), + THURSDAY("목"), + FRIDAY("금"); + + companion object { + + fun from(dayOfWeek: DayOfWeek): Weekdays { + return when (dayOfWeek) { + DayOfWeek.MONDAY -> MONDAY + DayOfWeek.TUESDAY -> TUESDAY + DayOfWeek.WEDNESDAY -> WEDNESDAY + DayOfWeek.THURSDAY -> THURSDAY + DayOfWeek.FRIDAY -> FRIDAY + else -> throw IllegalArgumentException("에러") + } + } + } +} \ No newline at end of file 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 e8d0e86f..cbbfd509 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 @@ -4,7 +4,6 @@ import android.annotation.SuppressLint import android.util.TypedValue import android.view.MotionEvent import android.view.View -import androidx.recyclerview.widget.RecyclerView import androidx.window.layout.WindowMetricsCalculator import com.dongyang.android.youdongknowme.R import com.dongyang.android.youdongknowme.databinding.FragmentCafeteriaBinding @@ -17,12 +16,11 @@ import com.kizitonwose.calendarview.model.CalendarDay import com.kizitonwose.calendarview.ui.DayBinder import com.kizitonwose.calendarview.utils.Size import org.koin.androidx.viewmodel.ext.android.viewModel -import java.time.DayOfWeek +import java.time.DayOfWeek.* import java.time.LocalDate import java.time.YearMonth import java.time.temporal.TemporalAdjusters - class CafeteriaFragment : BaseFragment(), CalendarInterface { @@ -60,9 +58,9 @@ class CafeteriaFragment : BaseFragment @@ -123,16 +125,16 @@ class CafeteriaFragment : BaseFragment { - currentDate.with(TemporalAdjusters.next(DayOfWeek.MONDAY)) + SATURDAY, SUNDAY -> { + currentDate.with(TemporalAdjusters.next(MONDAY)) } - DayOfWeek.MONDAY -> { + MONDAY -> { currentDate } else -> { - currentDate.with(TemporalAdjusters.previous(DayOfWeek.MONDAY)) + currentDate.with(TemporalAdjusters.previous(MONDAY)) } } } @@ -140,10 +142,10 @@ class CafeteriaFragment : BaseFragment> = MutableLiveData() val cafeteriaList: LiveData> = _cafeteriaList - private val _menus: MutableLiveData> = MutableLiveData() - val menus: LiveData> = _menus + private val _koreaMenu: MutableLiveData> = MutableLiveData() + val koreaMenu: LiveData> = _koreaMenu + + private val _daysMenu: MutableLiveData> = MutableLiveData() + val daysMenu: LiveData> = _daysMenu private val emptyMenu = listOf(resourceProvider.getString(R.string.cafeteria_no_menu)) @@ -68,7 +73,7 @@ class CafeteriaViewModel( val cafeteriaList = _cafeteriaList.value ?: emptyList() _selectedDate.value = selectedDate val selectedMenu = cafeteriaList.find { it.date == selectedDate.toString() }?.menus - _menus.postValue( + _koreaMenu.postValue( if (selectedMenu.isNullOrEmpty()) { emptyMenu } else { @@ -76,4 +81,19 @@ class CafeteriaViewModel( } ) } + + fun updateAnotherMenus(selectedDate: LocalDate) { + viewModelScope.launch { + val dateToWeekday: Weekdays = Weekdays.from(selectedDate.dayOfWeek) + runCatching { + cafeteriaRepository.fetchAnotherMenus(dateToWeekday) + }.onSuccess { daysMenu -> + val formatter = DecimalFormat("#,###") + val formattedMenuWithPrice = daysMenu.map { "${it.menuNameKr} ${formatter.format(it.price)}원" } + _daysMenu.value = formattedMenuWithPrice + }.onFailure { + _isError.value = true + } + } + } } diff --git a/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CalendarInterface.kt b/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CalendarInterface.kt index a71cf464..58e47662 100644 --- a/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CalendarInterface.kt +++ b/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CalendarInterface.kt @@ -11,6 +11,7 @@ interface CalendarInterface { selectedDate: LocalDate ) { viewModel.updateMenuList(selectedDate) + viewModel.updateAnotherMenus(selectedDate) calendarView.notifyDateChanged(selectedDate) oldDate?.let { calendarView.notifyDateChanged(it) } } From a2793d356ddd65a80e91009477a774af0b048def Mon Sep 17 00:00:00 2001 From: Son Myeongji <114990782+m6z1@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:23:01 +0900 Subject: [PATCH 4/8] =?UTF-8?q?refactor:=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../youdongknowme/ui/view/cafeteria/CafeteriaFragment.kt | 4 ++-- .../youdongknowme/ui/view/cafeteria/CafeteriaViewModel.kt | 2 +- .../youdongknowme/ui/view/cafeteria/CalendarInterface.kt | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) 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 cbbfd509..1712c599 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 @@ -73,7 +73,7 @@ class CafeteriaFragment : BaseFragment diff --git a/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CafeteriaViewModel.kt b/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CafeteriaViewModel.kt index d08ff2bd..a021e5f1 100644 --- a/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CafeteriaViewModel.kt +++ b/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CafeteriaViewModel.kt @@ -82,7 +82,7 @@ class CafeteriaViewModel( ) } - fun updateAnotherMenus(selectedDate: LocalDate) { + fun updateDaysMenu(selectedDate: LocalDate) { viewModelScope.launch { val dateToWeekday: Weekdays = Weekdays.from(selectedDate.dayOfWeek) runCatching { diff --git a/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CalendarInterface.kt b/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CalendarInterface.kt index 58e47662..88b41b6e 100644 --- a/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CalendarInterface.kt +++ b/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CalendarInterface.kt @@ -11,7 +11,7 @@ interface CalendarInterface { selectedDate: LocalDate ) { viewModel.updateMenuList(selectedDate) - viewModel.updateAnotherMenus(selectedDate) + viewModel.updateDaysMenu(selectedDate) calendarView.notifyDateChanged(selectedDate) oldDate?.let { calendarView.notifyDateChanged(it) } } From cae03bb73235bf30be19935087c1dd155fd56f39 Mon Sep 17 00:00:00 2001 From: Son Myeongji <114990782+m6z1@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:26:55 +0900 Subject: [PATCH 5/8] =?UTF-8?q?refactor:=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../youdongknowme/data/repository/CafeteriaRepository.kt | 2 +- .../youdongknowme/ui/view/cafeteria/CafeteriaViewModel.kt | 2 +- 2 files changed, 2 insertions(+), 2 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 77561d56..fcb06d76 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 @@ -21,7 +21,7 @@ class CafeteriaRepository( } } - fun fetchAnotherMenus(todayDay: Weekdays): List { + fun fetchDaysMenu(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/CafeteriaViewModel.kt b/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CafeteriaViewModel.kt index a021e5f1..5d4020db 100644 --- a/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CafeteriaViewModel.kt +++ b/app/src/main/java/com/dongyang/android/youdongknowme/ui/view/cafeteria/CafeteriaViewModel.kt @@ -86,7 +86,7 @@ class CafeteriaViewModel( viewModelScope.launch { val dateToWeekday: Weekdays = Weekdays.from(selectedDate.dayOfWeek) runCatching { - cafeteriaRepository.fetchAnotherMenus(dateToWeekday) + cafeteriaRepository.fetchDaysMenu(dateToWeekday) }.onSuccess { daysMenu -> val formatter = DecimalFormat("#,###") val formattedMenuWithPrice = daysMenu.map { "${it.menuNameKr} ${formatter.format(it.price)}원" } From 7565dabbc811fdf99bd53296081a2c4fdac63cf4 Mon Sep 17 00:00:00 2001 From: Son Myeongji <114990782+m6z1@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:29:35 +0900 Subject: [PATCH 6/8] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=9D=B4=EB=84=98=20=EA=B0=92=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=8D=BC=ED=8B=B0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/youdongknowme/standard/util/Weekdays.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/dongyang/android/youdongknowme/standard/util/Weekdays.kt b/app/src/main/java/com/dongyang/android/youdongknowme/standard/util/Weekdays.kt index acc3381f..95bd86fb 100644 --- a/app/src/main/java/com/dongyang/android/youdongknowme/standard/util/Weekdays.kt +++ b/app/src/main/java/com/dongyang/android/youdongknowme/standard/util/Weekdays.kt @@ -2,12 +2,12 @@ package com.dongyang.android.youdongknowme.standard.util import java.time.DayOfWeek -enum class Weekdays(val dayKr: String) { - MONDAY("월"), - TUESDAY("화"), - WEDNESDAY("수"), - THURSDAY("목"), - FRIDAY("금"); +enum class Weekdays { + MONDAY, + TUESDAY, + WEDNESDAY, + THURSDAY, + FRIDAY; companion object { From a457da40082814d062ae21f69eae2c897f5d2e6a Mon Sep 17 00:00:00 2001 From: Son Myeongji <114990782+m6z1@users.noreply.github.com> Date: Sun, 15 Sep 2024 22:43:43 +0900 Subject: [PATCH 7/8] =?UTF-8?q?build:=20=EC=97=90=EB=9F=AC=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EB=AA=85=ED=99=95=ED=9E=88=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dongyang/android/youdongknowme/standard/util/Weekdays.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/dongyang/android/youdongknowme/standard/util/Weekdays.kt b/app/src/main/java/com/dongyang/android/youdongknowme/standard/util/Weekdays.kt index 95bd86fb..61ede045 100644 --- a/app/src/main/java/com/dongyang/android/youdongknowme/standard/util/Weekdays.kt +++ b/app/src/main/java/com/dongyang/android/youdongknowme/standard/util/Weekdays.kt @@ -18,7 +18,7 @@ enum class Weekdays { DayOfWeek.WEDNESDAY -> WEDNESDAY DayOfWeek.THURSDAY -> THURSDAY DayOfWeek.FRIDAY -> FRIDAY - else -> throw IllegalArgumentException("에러") + else -> throw IllegalArgumentException("월요일 - 금요일을 벗어났습니다.") } } } 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 8/8] =?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 }