Skip to content

Commit

Permalink
Fix crash when user tap back button
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <[email protected]>
  • Loading branch information
alperozturk96 committed Nov 2, 2023
1 parent 760fdcd commit e0192f4
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,19 +196,23 @@ class FirstRunActivity : BaseActivity(), ViewPager.OnPageChangeListener, Injecta
private fun handleOnBackPressed() {
onBackPressedDispatcher.addCallback(
this,
object : OnBackPressedCallback(true) {
object: OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
onFinish()
val isFromAddAccount = intent.getBooleanExtra(EXTRA_ALLOW_CLOSE, false)

if (intent.getBooleanExtra(EXTRA_ALLOW_CLOSE, false)) {
onBackPressedDispatcher.onBackPressed()
val destination: Intent = if (isFromAddAccount) {
Intent(applicationContext, FileDisplayActivity::class.java)
} else {
val intent = Intent(applicationContext, AuthenticatorActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
intent.putExtra(EXTRA_EXIT, true)
startActivity(intent)
finish()
Intent(applicationContext, AuthenticatorActivity::class.java)
}

if (!isFromAddAccount) {
destination.putExtra(EXTRA_EXIT, true)
}

destination.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
startActivity(destination)
finish()
}
}
)
Expand Down

0 comments on commit e0192f4

Please sign in to comment.