From 327718065f8d29a96ee777f4e3c68d02699cbd70 Mon Sep 17 00:00:00 2001 From: dkyuuum Date: Tue, 20 Feb 2024 00:43:49 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=ED=8B=80?= =?UTF-8?q?=EB=A0=B8=EC=9D=84=20=EB=95=8C=20=ED=85=8D=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95=20#1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/deploymentTargetDropDown.xml | 2 +- .../umc/com/mobile/project/ui/login/LoginActivity.kt | 6 +++--- .../project/ui/login/viewmodel/LoginViewModel.kt | 10 +++++++++- app/src/main/res/layout/activity_login.xml | 9 --------- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index 52cce6f8..9ab3e266 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -12,6 +12,6 @@ - + \ No newline at end of file diff --git a/app/src/main/java/umc/com/mobile/project/ui/login/LoginActivity.kt b/app/src/main/java/umc/com/mobile/project/ui/login/LoginActivity.kt index 10e20ad5..5aaa8108 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/login/LoginActivity.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/login/LoginActivity.kt @@ -36,11 +36,11 @@ class LoginActivity : AppCompatActivity() { viewModel.login() } - viewModel.loginStatus.observe(this, Observer { loginStatus -> - if (!loginStatus) { + viewModel.loginSuccess.observe(this, Observer { loginSuccess -> + if (!loginSuccess) { val intent = Intent(this@LoginActivity, MainActivity::class.java) startActivity(intent) - finish() // 로그인 성공시 로그인 액티비티 종료 + finish() } else { // 로그인 실패시 처리할 로직 추가 가능 } diff --git a/app/src/main/java/umc/com/mobile/project/ui/login/viewmodel/LoginViewModel.kt b/app/src/main/java/umc/com/mobile/project/ui/login/viewmodel/LoginViewModel.kt index 98259adb..76fd26ed 100644 --- a/app/src/main/java/umc/com/mobile/project/ui/login/viewmodel/LoginViewModel.kt +++ b/app/src/main/java/umc/com/mobile/project/ui/login/viewmodel/LoginViewModel.kt @@ -49,6 +49,10 @@ class LoginViewModel : ViewModel() { fun init() { id.postValue("") pw.postValue("") + _loginSuccess.postValue(false) + } + + init { _loginStatus.postValue(false) } @@ -71,7 +75,7 @@ class LoginViewModel : ViewModel() { ) } _loginResult.postValue(response.body()) - _loginStatus.postValue(false) + _loginSuccess.postValue(false) Log.d("cookies", "$cookies") Log.d("Login", "${response.body()}") @@ -84,7 +88,9 @@ class LoginViewModel : ViewModel() { result = null ) ) + _loginSuccess.postValue(true) _loginStatus.postValue(true) + Log.e("Login", "정보 틀림: $loginResult") } } @@ -98,7 +104,9 @@ class LoginViewModel : ViewModel() { result = null ) ) + _loginSuccess.postValue(true) _loginStatus.postValue(true) + Log.e("Login", "네트워크 오류: $loginResult / $loginStatus") } }) diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 7b854dcb..9e8274d7 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -147,14 +147,5 @@ android:text="@string/login_title" android:textColor="@color/white" /> - - \ No newline at end of file