From cba1c3af8077cc0260183e90b9ae58f069319824 Mon Sep 17 00:00:00 2001 From: DoReMinWoo Date: Sat, 13 Jan 2024 00:42:48 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20#117=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20?= =?UTF-8?q?=EC=8B=9C=20=EB=8B=A8=EC=B2=B4=20=EC=A0=95=EB=B3=B4=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=ED=9B=84=20=ED=95=B4=EB=8B=B9=EB=90=98=EB=8A=94=20?= =?UTF-8?q?=EB=B7=B0=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pingle/presentation/ui/auth/AuthActivity.kt | 14 +++++++++++--- .../pingle/presentation/ui/auth/AuthViewModel.kt | 4 +++- .../presentation/ui/splash/SplashActivity.kt | 4 +++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/auth/AuthActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/auth/AuthActivity.kt index 98518314..a52dea53 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/auth/AuthActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/auth/AuthActivity.kt @@ -2,20 +2,22 @@ package org.sopt.pingle.presentation.ui.auth import android.content.Intent import android.os.Bundle +import android.util.Log import androidx.activity.viewModels import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint -import javax.inject.Inject import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import org.sopt.pingle.R import org.sopt.pingle.data.service.KakaoAuthService import org.sopt.pingle.databinding.ActivityAuthBinding +import org.sopt.pingle.presentation.ui.main.MainActivity import org.sopt.pingle.presentation.ui.onboarding.OnBoardingActivity import org.sopt.pingle.util.base.BindingActivity import org.sopt.pingle.util.view.UiState import timber.log.Timber +import javax.inject.Inject @AndroidEntryPoint class AuthActivity : BindingActivity(R.layout.activity_auth) { @@ -51,8 +53,14 @@ class AuthActivity : BindingActivity(R.layout.activity_auth } private fun navigateToOnBoarding() { - Intent(this, OnBoardingActivity::class.java).apply { - startActivity(this) + if (viewModel.isLocalGroupId()) { + Intent(this, MainActivity::class.java).apply { + startActivity(this) + } + } else { + Intent(this, OnBoardingActivity::class.java).apply { + startActivity(this) + } } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/auth/AuthViewModel.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/auth/AuthViewModel.kt index 535a98aa..64c815b1 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/auth/AuthViewModel.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/auth/AuthViewModel.kt @@ -3,7 +3,6 @@ package org.sopt.pingle.presentation.ui.auth import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.launch @@ -11,6 +10,7 @@ import org.sopt.pingle.data.datasource.local.PingleLocalDataSource import org.sopt.pingle.data.model.remote.request.RequestAuthDto import org.sopt.pingle.domain.repository.AuthRepository import org.sopt.pingle.util.view.UiState +import javax.inject.Inject @HiltViewModel class AuthViewModel @Inject constructor( @@ -42,6 +42,8 @@ class AuthViewModel @Inject constructor( localStorage.userName = userName } + fun isLocalGroupId(): Boolean = localStorage.groupId == -1 + companion object { const val LOGIN_PLATFORM = "KAKAO" const val HEADER_BEARER = "Bearer " diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/splash/SplashActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/splash/SplashActivity.kt index b577f546..64696374 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/splash/SplashActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/splash/SplashActivity.kt @@ -31,7 +31,9 @@ class SplashActivity : BindingActivity(R.layout.activity_ val storage = PingleLocalDataSourceImpl(this) val nextActivity = - if (storage.isLogin) MainActivity::class.java else AuthActivity::class.java + if (storage.isLogin) { + MainActivity::class.java + } else if (storage.groupId != -1) MainActivity::class.java else AuthActivity::class.java startActivity(Intent(this, nextActivity)) finish()