diff --git a/app/src/main/java/com/runnect/runnect/presentation/MainActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/MainActivity.kt index 2ea75aa1..44e87ecf 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/MainActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/MainActivity.kt @@ -44,7 +44,7 @@ class MainActivity : BindingActivity(R.layout.activity_main } private fun checkVisitorMode() { - val accessToken = applicationContext.getAccessToken() + val accessToken = this.getAccessToken() val loginStatus = LoginStatus.getLoginStatus(accessToken) isVisitorMode = loginStatus == LoginStatus.VISITOR } diff --git a/app/src/main/java/com/runnect/runnect/presentation/login/GiveNicknameActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/login/GiveNicknameActivity.kt index b2f0d356..03c4742d 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/login/GiveNicknameActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/login/GiveNicknameActivity.kt @@ -35,7 +35,7 @@ class GiveNicknameActivity : } private fun saveSignTokenInfo() { - applicationContext.saveToken( + this.saveToken( accessToken = intent.getStringExtra("access") ?: "", refreshToken = intent.getStringExtra("refresh") ?: "" ) diff --git a/app/src/main/java/com/runnect/runnect/presentation/login/LoginActivity.kt b/app/src/main/java/com/runnect/runnect/presentation/login/LoginActivity.kt index 5ecd5052..210b29d8 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/login/LoginActivity.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/login/LoginActivity.kt @@ -1,6 +1,7 @@ package com.runnect.runnect.presentation.login import android.content.ContentValues +import android.content.Context import android.content.Intent import android.os.Bundle import android.widget.Toast @@ -32,7 +33,7 @@ class LoginActivity : //자동 로그인 override fun onStart() { super.onStart() - val accessToken = applicationContext.getAccessToken() + val accessToken = this.getAccessToken() when (LoginStatus.getLoginStatus(accessToken)) { LoginStatus.EXPIRED -> { @@ -67,6 +68,7 @@ class LoginActivity : } private fun addListener() { + val ctx: Context = this with(binding) { cvGoogleLogin.setOnClickListener { socialLogin = googleLogin @@ -78,7 +80,7 @@ class LoginActivity : } btnVisitorMode.setOnClickListener { Analytics.logClickedItemEvent(EVENT_CLICK_VISITOR) - applicationContext.saveToken( + ctx.saveToken( accessToken = LoginStatus.VISITOR.value, refreshToken = LoginStatus.VISITOR.value ) @@ -130,7 +132,7 @@ class LoginActivity : private fun saveSignTokenInfo() { viewModel.loginResult.value?.let { loginResult -> - applicationContext.saveToken( + this.saveToken( accessToken = loginResult.accessToken, refreshToken = loginResult.refreshToken ) diff --git a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt index 4beb07c1..3996a1a1 100644 --- a/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt +++ b/app/src/main/java/com/runnect/runnect/presentation/mypage/setting/accountinfo/MySettingAccountInfoFragment.kt @@ -2,6 +2,7 @@ package com.runnect.runnect.presentation.mypage.setting.accountinfo import android.app.AlertDialog import android.content.ContentValues +import android.content.Context import android.content.Intent import android.os.Bundle import android.view.View @@ -111,7 +112,8 @@ class MySettingAccountInfoFragment : } private fun moveToLogin() { - requireActivity().applicationContext?.saveToken( + val ctx: Context = context ?: return + ctx.saveToken( accessToken = LoginStatus.NONE.value, refreshToken = LoginStatus.NONE.value )