From e4517c181d8713246dd04e47cdac0ae0883e66b4 Mon Sep 17 00:00:00 2001 From: TRASALBY Date: Mon, 12 Dec 2022 17:25:35 +0900 Subject: [PATCH] =?UTF-8?q?Issue=20#202=20feat:=20Loading=20state=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EC=A0=95=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/lateinit/rightweight/ui/MainViewModel.kt | 3 +++ .../java/com/lateinit/rightweight/ui/login/LoginViewModel.kt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/lateinit/rightweight/ui/MainViewModel.kt b/app/src/main/java/com/lateinit/rightweight/ui/MainViewModel.kt index b09f0b63..92b46ef0 100644 --- a/app/src/main/java/com/lateinit/rightweight/ui/MainViewModel.kt +++ b/app/src/main/java/com/lateinit/rightweight/ui/MainViewModel.kt @@ -89,6 +89,7 @@ class MainViewModel @Inject constructor( fun backup() { viewModelScope.launch() { + sendNetworkResultEvent(NetworkState.LOADING) backupUserInfo() backupMyRoutine() backupHistory() @@ -99,6 +100,7 @@ class MainViewModel @Inject constructor( fun restore(){ val userId = userInfo.value?.userId ?: return viewModelScope.launch(networkExceptionHandler) { + sendNetworkResultEvent(NetworkState.LOADING) val userInfoInServer = userRepository.restoreUserInfo(userId) if(userInfoInServer != null){ restoreRoutine() @@ -109,6 +111,7 @@ class MainViewModel @Inject constructor( userInfoInServer.completedDayId.value ) } + sendNetworkResultEvent(NetworkState.SUCCESS) } } diff --git a/app/src/main/java/com/lateinit/rightweight/ui/login/LoginViewModel.kt b/app/src/main/java/com/lateinit/rightweight/ui/login/LoginViewModel.kt index 8617bb5e..01a9438b 100644 --- a/app/src/main/java/com/lateinit/rightweight/ui/login/LoginViewModel.kt +++ b/app/src/main/java/com/lateinit/rightweight/ui/login/LoginViewModel.kt @@ -51,5 +51,5 @@ class LoginViewModel @Inject constructor( } enum class NetworkState { - NO_ERROR, BAD_INTERNET, PARSE_ERROR, WRONG_CONNECTION, OTHER_ERROR, SUCCESS + NO_ERROR, BAD_INTERNET, PARSE_ERROR, WRONG_CONNECTION, OTHER_ERROR, SUCCESS, LOADING } \ No newline at end of file