Skip to content

Commit

Permalink
#180 / 뒤로가기 시 빈 화면 띄워주지 않기 위해 화면 전환로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
taeheeL committed Dec 20, 2023
1 parent 66dfc9e commit 4a4ed19
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 4 deletions.
20 changes: 19 additions & 1 deletion app/src/main/java/sopt/uni/presentation/invite/DdayActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sopt.uni.presentation.invite

import android.content.Intent
import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import androidx.activity.viewModels
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
Expand All @@ -12,6 +13,7 @@ import sopt.uni.presentation.common.content.INVITECODE
import sopt.uni.util.DateUtil
import sopt.uni.util.binding.BindingActivity
import sopt.uni.util.extension.setOnSingleClickListener
import sopt.uni.util.extension.startActivity
import java.util.Calendar

@AndroidEntryPoint
Expand All @@ -24,6 +26,7 @@ class DdayActivity : BindingActivity<ActivityDDayBinding>(R.layout.activity_d_da
setMaxDate()
moveToShareInviteCode()
moveToPrevPage()
initOnBackPressedListener()
}

private fun moveToShareInviteCode() {
Expand All @@ -48,12 +51,27 @@ class DdayActivity : BindingActivity<ActivityDDayBinding>(R.layout.activity_d_da

private fun moveToPrevPage() {
binding.ivBackArrow.setOnSingleClickListener {
finish()
backToInviteHub()
}
}

private fun setMaxDate() {
val calendar = Calendar.getInstance()
binding.dpDDay.maxDate = calendar.timeInMillis
}

private fun initOnBackPressedListener() {
val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
backToInviteHub()
}
}
this.onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
}

private fun backToInviteHub() {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity<InviteHubActivity>()
finish()
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package sopt.uni.presentation.invite

import android.content.Intent
import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import dagger.hilt.android.AndroidEntryPoint
import sopt.uni.R
import sopt.uni.databinding.ActivityInviteHubBinding
Expand All @@ -17,6 +19,7 @@ class InviteHubActivity : BindingActivity<ActivityInviteHubBinding>(R.layout.act
moveToEnterDday()
moveToEnterInviteCode()
moveToPrevPage()
initOnBackPressedListener()
}

private fun moveToEnterDday() {
Expand All @@ -33,7 +36,22 @@ class InviteHubActivity : BindingActivity<ActivityInviteHubBinding>(R.layout.act

private fun moveToPrevPage() {
binding.ivBackArrow.setOnSingleClickListener {
finish()
backToNickNameActivity()
}
}

private fun initOnBackPressedListener() {
val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
backToNickNameActivity()
}
}
this.onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
}

private fun backToNickNameActivity() {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity<NickNameActivity>()
finish()
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package sopt.uni.presentation.invite

import android.content.Context
import android.content.Intent
import android.graphics.Rect
import android.os.Bundle
import android.view.MotionEvent
import android.view.MotionEvent.ACTION_DOWN
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import androidx.activity.OnBackPressedCallback
import androidx.activity.viewModels
import dagger.hilt.android.AndroidEntryPoint
import sopt.uni.R
import sopt.uni.databinding.ActivityNicknameBinding
import sopt.uni.presentation.login.LoginActivity
import sopt.uni.presentation.mypage.MypageAccountLogoutDialogFragment
import sopt.uni.util.binding.BindingActivity
import sopt.uni.util.extension.setOnSingleClickListener
Expand All @@ -28,6 +31,7 @@ class NickNameActivity : BindingActivity<ActivityNicknameBinding>(R.layout.activ
moveToPrevPage()
moveToAskPage()
logoutOnNickNamePage()
initOnBackPressedListener()
}

private fun moveToInviteHub() {
Expand All @@ -39,7 +43,7 @@ class NickNameActivity : BindingActivity<ActivityNicknameBinding>(R.layout.activ

private fun moveToPrevPage() {
binding.ivBackArrow.setOnSingleClickListener {
finish()
backToLogin()
}
}

Expand Down Expand Up @@ -74,4 +78,19 @@ class NickNameActivity : BindingActivity<ActivityNicknameBinding>(R.layout.activ
)
}
}

private fun initOnBackPressedListener() {
val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
backToLogin()
}
}
this.onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
}

private fun backToLogin() {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity<LoginActivity>()
finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sopt.uni.presentation.invite

import android.content.Intent
import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import androidx.activity.viewModels
import androidx.lifecycle.flowWithLifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -30,6 +31,7 @@ class ShareInviteCodeActivity :
getInviteCode()
checkCoupleConnection()
copyInviteCode()
initOnBackPressedListener()
}

private fun getInviteCode() {
Expand All @@ -38,7 +40,7 @@ class ShareInviteCodeActivity :

private fun moveToPrevPage() {
binding.ivBackArrow.setOnSingleClickListener {
finish()
backToDdayActivity()
}
}

Expand Down Expand Up @@ -79,4 +81,19 @@ class ShareInviteCodeActivity :
startActivity(shareIntent)
}
}

private fun initOnBackPressedListener() {
val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
backToDdayActivity()
}
}
this.onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
}

private fun backToDdayActivity() {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity<DdayActivity>()
finish()
}
}

0 comments on commit 4a4ed19

Please sign in to comment.