Skip to content

Commit

Permalink
refactor/#11: isInitialized로 초기화 확인
Browse files Browse the repository at this point in the history
  • Loading branch information
youjin09222 committed May 11, 2024
1 parent 5bdae0e commit bd73dad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion app/src/main/java/com/sopt/now/compose/data/ApiFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.sopt.now.compose.data

import android.util.Log
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.sopt.now.compose.BuildConfig
import com.sopt.now.BuildConfig
import kotlinx.serialization.json.Json
import okhttp3.Interceptor
import okhttp3.MediaType.Companion.toMediaType
Expand All @@ -14,6 +14,8 @@ import java.io.IOException
object ApiFactory {
private const val BASE_URL: String = BuildConfig.AUTH_BASE_URL
lateinit var userPreference: UserPreference
var isInitialized = false
private set

fun initializeUserPreference(userPreference: UserPreference) {
ApiFactory.userPreference = userPreference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ class LoginActivity : ComponentActivity() {
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {

userPreference = UserPreference(LocalContext.current)
ApiFactory.initializeUserPreference(userPreference)
if (!ApiFactory.isInitialized) {
ApiFactory.initializeUserPreference(userPreference)
}

val viewModel: LoginViewModel = remember { LoginViewModel() }
LoginView(viewModel)
Expand Down

0 comments on commit bd73dad

Please sign in to comment.