Skip to content

Commit

Permalink
[REFACTOR] #339 applicationContext -> context로 변경하고, null 안전하게 체크
Browse files Browse the repository at this point in the history
  • Loading branch information
sxunea committed Mar 27, 2024
1 parent e9c245b commit 0af3516
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
}

private fun checkVisitorMode() {
val accessToken = applicationContext.getAccessToken()
val accessToken = this.getAccessToken()
val loginStatus = LoginStatus.getLoginStatus(accessToken)
isVisitorMode = loginStatus == LoginStatus.VISITOR
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class GiveNicknameActivity :
}

private fun saveSignTokenInfo() {
applicationContext.saveToken(
this.saveToken(
accessToken = intent.getStringExtra("access") ?: "",
refreshToken = intent.getStringExtra("refresh") ?: ""
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 -> {
Expand Down Expand Up @@ -67,6 +68,7 @@ class LoginActivity :
}

private fun addListener() {
val ctx: Context = this
with(binding) {
cvGoogleLogin.setOnClickListener {
socialLogin = googleLogin
Expand All @@ -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
)
Expand Down Expand Up @@ -130,7 +132,7 @@ class LoginActivity :

private fun saveSignTokenInfo() {
viewModel.loginResult.value?.let { loginResult ->
applicationContext.saveToken(
this.saveToken(
accessToken = loginResult.accessToken,
refreshToken = loginResult.refreshToken
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down

0 comments on commit 0af3516

Please sign in to comment.