-
Notifications
You must be signed in to change notification settings - Fork 0
[FIX] 카카오 소셜 로그인 SDK 로직 개선 #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
Near/app/src/main/java/com/alarmy/near/data/di/ContextProviderModule.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.alarmy.near.data.di | ||
|
|
||
| import com.alarmy.near.data.provider.ActivityContextProvider | ||
| import com.alarmy.near.presentation.provider.ActivityContextProviderImpl | ||
| import dagger.Binds | ||
| import dagger.Module | ||
| import dagger.hilt.InstallIn | ||
| import dagger.hilt.components.SingletonComponent | ||
| import javax.inject.Singleton | ||
|
|
||
| /** | ||
| * Context Provider 모듈 | ||
| * Activity Context 제공을 위한 의존성 주입 설정 | ||
| */ | ||
| @Module | ||
| @InstallIn(SingletonComponent::class) | ||
| interface ContextProviderModule { | ||
| @Binds | ||
| @Singleton | ||
| fun bindActivityContextProvider(impl: ActivityContextProviderImpl): ActivityContextProvider | ||
| } | ||
|
|
16 changes: 16 additions & 0 deletions
16
Near/app/src/main/java/com/alarmy/near/data/provider/ActivityContextProvider.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.alarmy.near.data.provider | ||
|
|
||
| import android.content.Context | ||
|
|
||
| /** | ||
| * Activity Context 제공 인터페이스 | ||
| * 카카오 로그인 등 Activity Context가 필요한 경우에 사용 | ||
| */ | ||
| interface ActivityContextProvider { | ||
| /** | ||
| * 현재 Activity의 Context를 반환 | ||
| * Activity Context, 없으면 null | ||
| */ | ||
| fun getActivityContext(): Context? | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
Near/app/src/main/java/com/alarmy/near/presentation/provider/ActivityContextProviderImpl.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.alarmy.near.presentation.provider | ||
|
|
||
| import android.content.Context | ||
| import com.alarmy.near.data.provider.ActivityContextProvider | ||
| import java.lang.ref.WeakReference | ||
| import javax.inject.Inject | ||
| import javax.inject.Singleton | ||
|
|
||
| /** | ||
| * Activity Context 제공 구현체 | ||
| * MainActivity에서 직접 Context를 설정하는 방식 | ||
| */ | ||
| @Singleton | ||
| class ActivityContextProviderImpl | ||
| @Inject | ||
| constructor() : ActivityContextProvider { | ||
| private var activityContextRef: WeakReference<Context>? = null | ||
|
|
||
| /** | ||
| * Activity Context 설정 | ||
| * MainActivity의 onCreate/onDestroy에서 호출됨 | ||
| */ | ||
| fun setActivityContext(context: Context?) { | ||
| activityContextRef = | ||
| if (context != null) { | ||
| WeakReference(context) | ||
| } else { | ||
| null | ||
| } | ||
| } | ||
|
|
||
| override fun getActivityContext(): Context? = activityContextRef?.get() | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tempAccessToken과tempProviderType에!!연산자를 사용하는 것은 잠재적인NullPointerException위험이 있습니다. 예를 들어, 안드로이드 시스템이 메모리 확보를 위해 앱 프로세스를 종료했다가 사용자가 다시 앱으로 돌아오면 ViewModel이 재생성되면서 이 변수들이null이 될 수 있습니다. 이 경우!!연산자로 인해 앱이 비정상 종료됩니다.이러한 상황을 방지하기 위해,
socialLogin을 호출하기 전에accessToken과providerType이null이 아닌지 확인하는 방어 코드를 추가하는 것이 좋습니다.null일 경우, 사용자에게 오류 메시지를 보여주고 다시 로그인을 시도하도록 안내하는 것이 안전합니다.