Skip to content

Commit

Permalink
Merge pull request #1111 from minvws/3619-valid-qr-not-auto-closing
Browse files Browse the repository at this point in the history
set auto close fragment to millis
  • Loading branch information
aiden-shi authored Feb 16, 2022
2 parents 574d317 + 55a7ff7 commit 6f8cc1b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ abstract class AutoCloseFragment(contentLayoutId: Int) : Fragment(contentLayoutI
}

/**
* Checks if this fragment should close based on [aliveForSeconds]
* Checks if this fragment should close based on [aliveForMilliseconds]
* Navigates to [navigateToCloseAt] when finished
*/
private fun checkShouldClose() {
val fragmentCreatedInstant = Instant.ofEpochSecond(fragmentCreatedTimestamp)
val nowInstant = Instant.now(Clock.systemUTC())

if (fragmentCreatedInstant.plusSeconds(aliveForSeconds()).isBefore(nowInstant)) {
if (fragmentCreatedInstant.plusMillis(aliveForMilliseconds()).isBefore(nowInstant)) {
navigateToCloseAt()
}
}
Expand All @@ -70,6 +70,6 @@ abstract class AutoCloseFragment(contentLayoutId: Int) : Fragment(contentLayoutI
outState.putLong(FRAGMENT_CREATED_TIMESTAMP, fragmentCreatedTimestamp)
}

abstract fun aliveForSeconds(): Long
abstract fun aliveForMilliseconds(): Long
abstract fun navigateToCloseAt()
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ class ScanResultInvalidFragment : AutoCloseFragment(R.layout.fragment_scan_resul

private val args: ScanResultInvalidFragmentArgs by navArgs()

override fun aliveForSeconds(): Long {
return if (BuildConfig.FLAVOR == "acc") TimeUnit.SECONDS.toSeconds(10) else TimeUnit.MINUTES.toSeconds(
3
)
override fun aliveForMilliseconds(): Long {
return if (BuildConfig.FLAVOR == "acc") {
TimeUnit.SECONDS.toMillis(10)
} else {
TimeUnit.MINUTES.toMillis(3)
}
}

override fun navigateToCloseAt() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ class ScanResultPersonalDetailsFragment :

private val args: ScanResultPersonalDetailsFragmentArgs by navArgs()

override fun aliveForSeconds(): Long {
return if (BuildConfig.FLAVOR == "acc") TimeUnit.SECONDS.toSeconds(10) else TimeUnit.MINUTES.toSeconds(
3
)
override fun aliveForMilliseconds(): Long {
return if (BuildConfig.FLAVOR == "acc") {
TimeUnit.SECONDS.toMillis(10)
} else {
TimeUnit.MINUTES.toMillis(3)
}
}

override fun navigateToCloseAt() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ class ScanResultValidFragment : AutoCloseFragment(0) {
private val args: ScanResultValidFragmentArgs by navArgs()
private val verificationPolicySelectionStateUseCase: VerificationPolicySelectionStateUseCase by inject()

override fun aliveForSeconds(): Long {
return if (BuildConfig.FLAVOR == "acc") TimeUnit.SECONDS.toMillis(10) else TimeUnit.MILLISECONDS.toMillis(800)
}
override fun aliveForMilliseconds(): Long = 800

override fun navigateToCloseAt() {
navigateSafety(
Expand Down

0 comments on commit 6f8cc1b

Please sign in to comment.