refactor duplicated code

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-04-28 21:18:29 +02:00
parent 48c7ccb4b0
commit eaab887765
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B

View File

@ -118,6 +118,15 @@ class MainActivity : BaseActivity(), ActionBarProvider {
if (userUtils.anyUserExists()) { if (userUtils.anyUserExists()) {
setDefaultRootController() setDefaultRootController()
} else { } else {
launchLoginScreen()
}
} else {
launchLoginScreen()
}
}
}
private fun launchLoginScreen() {
if (!TextUtils.isEmpty(resources.getString(R.string.weblogin_url))) { if (!TextUtils.isEmpty(resources.getString(R.string.weblogin_url))) {
router!!.pushController( router!!.pushController(
RouterTransaction.with( RouterTransaction.with(
@ -134,25 +143,6 @@ class MainActivity : BaseActivity(), ActionBarProvider {
) )
} }
} }
} else {
if (!TextUtils.isEmpty(resources.getString(R.string.weblogin_url))) {
router!!.pushController(
RouterTransaction.with(
WebViewLoginController(resources.getString(R.string.weblogin_url), false)
)
.pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler())
)
} else {
router!!.setRoot(
RouterTransaction.with(ServerSelectionController())
.pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler())
)
}
}
}
}
override fun onStart() { override fun onStart() {
Log.d(TAG, "onStart: Activity: " + System.identityHashCode(this).toString()) Log.d(TAG, "onStart: Activity: " + System.identityHashCode(this).toString())