Skip to content
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

#162 / [QA] 백 버튼 누를떄 다이얼로그 띄우기 #181

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions app/src/main/java/sopt/uni/presentation/timer/TimerStartActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sopt.uni.presentation.timer

import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import dagger.hilt.android.AndroidEntryPoint
import sopt.uni.R
import sopt.uni.data.datasource.local.SparkleStorage
Expand All @@ -11,12 +12,23 @@ import sopt.uni.util.extension.setOnSingleClickListener
@AndroidEntryPoint
class TimerStartActivity : BindingActivity<ActivityTimerBinding>(R.layout.activity_timer) {

private val onBackPressedCallback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
exitTimer()
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)

setBackButton()
setTimerFragment()
finishTimer()
}

private fun finishTimer() {
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
}

private fun setTimerFragment() {
Expand All @@ -36,16 +48,20 @@ class TimerStartActivity : BindingActivity<ActivityTimerBinding>(R.layout.activi

private fun setBackButton() {
binding.btnTimerBack.setOnSingleClickListener {
val currentFragment = supportFragmentManager.findFragmentById(R.id.fcv_timer)

if (currentFragment is TimerSettingFragment) {
finish()
} else {
TimerDialogFragment().show(
supportFragmentManager,
TIMER_DIALOG_TAG,
)
}
exitTimer()
}
}

private fun exitTimer() {
val currentFragment = supportFragmentManager.findFragmentById(R.id.fcv_timer)

if (currentFragment is TimerSettingFragment) {
finish()
} else {
TimerDialogFragment().show(
supportFragmentManager,
TIMER_DIALOG_TAG,
)
}
}

Expand Down
Loading