diff --git a/app/src/main/java/org/android/go/sopt/presentation/login/LoginActivity.kt b/app/src/main/java/org/android/go/sopt/presentation/login/LoginActivity.kt index 0c35546..b7231d2 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/login/LoginActivity.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/login/LoginActivity.kt @@ -25,12 +25,12 @@ class LoginActivity : BindingActivity(R.layout.activity_lo super.onCreate(savedInstanceState) binding.vm = viewModel - initLayout() + initLayoutClickListener() initSignupBtnClickListener() setupLoginState() } - private fun initLayout() { + private fun initLayoutClickListener() { binding.layoutLogin.setOnSingleClickListener { hideKeyboard() } } diff --git a/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt b/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt index ab5ea46..d3bf1cd 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/login/LoginViewModel.kt @@ -25,10 +25,10 @@ class LoginViewModel @Inject constructor( val pwd = MutableLiveData("") init { - checkAutoLogin() + setupAutoLogin() } - private fun checkAutoLogin() { + private fun setupAutoLogin() { if (authRepository.getAutoLogin() && authRepository.getSignedUpUser() != null) _loginState.value = Success } diff --git a/app/src/main/java/org/android/go/sopt/presentation/main/MainActivity.kt b/app/src/main/java/org/android/go/sopt/presentation/main/MainActivity.kt index 2b80fb6..7e79d74 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/main/MainActivity.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/main/MainActivity.kt @@ -18,10 +18,10 @@ class MainActivity : BindingActivity(R.layout.activity_main override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - initNavigationBar() + initBnvItemSelectedListener() } - private fun initNavigationBar() { + private fun initBnvItemSelectedListener() { supportFragmentManager.findFragmentById(R.id.fcv_main_container) ?: navigateTo() diff --git a/app/src/main/java/org/android/go/sopt/presentation/main/profile/ProfileFragment.kt b/app/src/main/java/org/android/go/sopt/presentation/main/profile/ProfileFragment.kt index cfd63d5..a47495a 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/main/profile/ProfileFragment.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/main/profile/ProfileFragment.kt @@ -25,12 +25,17 @@ class ProfileFragment : BindingFragment(R.layout.fragmen private fun initLogoutAndLeaveBtnClickListener() { binding.btnProfileLogoutAndLeave.setOnSingleClickListener { + // TODO: show Logout And Leave Dialog viewModel.clearLocalPref() requireContext().showToast(getString(R.string.profile_logout_and_leave_msg)) - Intent(activity, LoginActivity::class.java).apply { - flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK - startActivity(this) - } + intentToLogin() + } + } + + private fun intentToLogin() { + Intent(activity, LoginActivity::class.java).apply { + flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK + startActivity(this) } } diff --git a/app/src/main/java/org/android/go/sopt/presentation/signup/SignupActivity.kt b/app/src/main/java/org/android/go/sopt/presentation/signup/SignupActivity.kt index a131516..80645b7 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/signup/SignupActivity.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/signup/SignupActivity.kt @@ -9,8 +9,8 @@ import dagger.hilt.android.AndroidEntryPoint import org.android.go.sopt.R import org.android.go.sopt.databinding.ActivitySignupBinding import org.android.go.sopt.presentation.login.LoginActivity -import org.android.go.sopt.presentation.signup.SignupViewModel.Companion.INVALID_ID_CODE -import org.android.go.sopt.presentation.signup.SignupViewModel.Companion.INVALID_PWD_CODE +import org.android.go.sopt.presentation.signup.SignupViewModel.Companion.CODE_INVALID_ID +import org.android.go.sopt.presentation.signup.SignupViewModel.Companion.CODE_INVALID_PWD import org.android.go.sopt.util.UiState.Failure import org.android.go.sopt.util.UiState.Success import org.android.go.sopt.util.binding.BindingActivity @@ -26,11 +26,11 @@ class SignupActivity : BindingActivity(R.layout.activity_ super.onCreate(savedInstanceState) binding.vm = viewModel - initLayout() + initLayoutClickListener() setupSignupState() } - private fun initLayout() { + private fun initLayoutClickListener() { with(binding) { layoutSignup.setOnSingleClickListener { hideKeyboard() } svSignup.setOnSingleClickListener { hideKeyboard() } @@ -44,11 +44,11 @@ class SignupActivity : BindingActivity(R.layout.activity_ is Success -> intentToLogin() is Failure -> { when (state.code) { - INVALID_ID_CODE -> showSnackbar( + CODE_INVALID_ID -> showSnackbar( binding.root, getString(R.string.signup_invalid_id_msg), ) - INVALID_PWD_CODE -> showSnackbar( + CODE_INVALID_PWD -> showSnackbar( binding.root, getString(R.string.signup_invalid_pwd_msg), ) diff --git a/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt b/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt index 4e9de72..31b8735 100644 --- a/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt +++ b/app/src/main/java/org/android/go/sopt/presentation/signup/SignupViewModel.kt @@ -35,11 +35,11 @@ class SignupViewModel @Inject constructor( fun signup() { if (!isValidId(id.value)) { - _signupState.value = Failure(INVALID_ID_CODE) + _signupState.value = Failure(CODE_INVALID_ID) return } if (!isValidPwd(pwd.value)) { - _signupState.value = Failure(INVALID_PWD_CODE) + _signupState.value = Failure(CODE_INVALID_PWD) return } authRepository.setSignedUpUser(getUser()) @@ -62,7 +62,7 @@ class SignupViewModel @Inject constructor( const val MIN_PWD_LENGTH = 8 const val MAX_PWD_LENGTH = 12 - const val INVALID_ID_CODE = 100 - const val INVALID_PWD_CODE = 101 + const val CODE_INVALID_ID = 100 + const val CODE_INVALID_PWD = 101 } }