Skip to content

Commit

Permalink
refactor : intent 객체화
Browse files Browse the repository at this point in the history
  • Loading branch information
huiwoo-jo committed Mar 23, 2024
1 parent f740b0f commit 1e21f38
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dongyang.android.youdongknowme.ui.view.depart

import android.content.Context
import android.content.Intent
import androidx.recyclerview.widget.LinearLayoutManager
import com.dongyang.android.youdongknowme.R
Expand Down Expand Up @@ -73,4 +74,10 @@ class OnboardingDepartActivity : BaseActivity<ActivityOnboardingDepartBinding, D
}
}
}

companion object {
fun createIntent(context: Context): Intent {
return Intent(context, OnboardingDepartActivity::class.java)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.dongyang.android.youdongknowme.ui.view.main

import android.content.Context
import android.content.Intent
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.plusAssign
import androidx.navigation.ui.setupWithNavController
Expand Down Expand Up @@ -31,4 +33,10 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
override fun initDataBinding() {}

override fun initAfterBinding() {}

companion object {
fun createIntent(context: Context): Intent {
return Intent(context, MainActivity::class.java)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class OnboardingPermissionActivity :

override fun initAfterBinding() {
binding.btnPermissionComplete.setOnClickListener {
val intent = Intent(this@OnboardingPermissionActivity, MainActivity::class.java)
val intent = MainActivity.createIntent(this@OnboardingPermissionActivity)
startActivity(intent)
finish()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
delay(SPLASH_TIME_MILLIS)

if (viewModel.isFirstLaunch.value == true) {
val intent = Intent(this@SplashActivity, OnboardingDepartActivity::class.java)
val intent = OnboardingDepartActivity.createIntent(this@SplashActivity)

if (PackageManager.PERMISSION_DENIED == ContextCompat.checkSelfPermission(
this@SplashActivity, Manifest.permission.POST_NOTIFICATIONS
Expand All @@ -59,7 +59,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
finish()
}
} else {
val intent = Intent(this@SplashActivity, MainActivity::class.java)
intent = MainActivity.createIntent(this@SplashActivity)
startActivity(intent)
finish()
}
Expand All @@ -74,10 +74,10 @@ class SplashActivity : BaseActivity<ActivitySplashBinding, SplashViewModel>() {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
if (requestCode == REQUEST_PERMISSION_CODE) {
// 권한 설정 결과 처리
val intent = if (viewModel.isFirstLaunch.value == true) {
Intent(this@SplashActivity, OnboardingDepartActivity::class.java)
intent = if (viewModel.isFirstLaunch.value == true) {
OnboardingDepartActivity.createIntent(this@SplashActivity)
} else {
Intent(this@SplashActivity, MainActivity::class.java)
MainActivity.createIntent(this@SplashActivity)
}
startActivity(intent)
finish()
Expand Down

0 comments on commit 1e21f38

Please sign in to comment.