Using lastOrNull in mainactivity to prevent a crash

This commit is contained in:
Jays2Kings 2021-05-27 23:26:12 -04:00
parent 11467cdb01
commit 34fc0a662c

View File

@ -642,7 +642,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), DownloadServiceLi
}
override fun onBackPressed() {
val sheetController = router.backstack.last().controller as? BottomSheetController
val sheetController = router.backstack.lastOrNull()?.controller as? BottomSheetController
if (if (router.backstackSize == 1) !(sheetController?.handleSheetBack() ?: false)
else !router.handleBack()
) {