Revert some changes and Refactor code style again

This commit is contained in:
2023-06-21 01:32:06 +08:00
parent 9834b6c8dd
commit a876854010

View File

@@ -62,8 +62,7 @@ class AppErrorsDetailActivity : BaseActivity<ActivityAppErrorsDetailBinding>() {
private var stackTrace = ""
override fun onCreate() {
if (intent.parseAppErrorsInfo().not()) return
if (initUi(intent).not()) return
binding.titleBackIcon.setOnClickListener { onBackPressed() }
binding.disableAutoWrapErrorStackTraceSwitch.bind(ConfigData.DISABLE_AUTO_WRAP_ERROR_STACK_TRACE) {
onInitialize {
@@ -82,12 +81,10 @@ class AppErrorsDetailActivity : BaseActivity<ActivityAppErrorsDetailBinding>() {
/**
* 从 [Intent] 中解析 [AppErrorsInfoBean] 并加载至界面
*
* @receiver [Intent] 待解析的 [Intent] 实例
*
* @return [Boolean] 是否解析成功true为成功false为失败可能是 [Intent] 为空或者 [AppErrorsInfoBean] 为空
* @return [Boolean] 是否解析成功true 为成功false 为失败,可能是 [Intent] 为空或者 [AppErrorsInfoBean] 为空
*/
private fun Intent?.parseAppErrorsInfo(): Boolean {
val appErrorsInfo = runCatching { this?.getSerializableExtraCompat<AppErrorsInfoBean>(EXTRA_APP_ERRORS_INFO) }.getOrNull()
private fun initUi(intent: Intent?): Boolean {
val appErrorsInfo = runCatching { intent?.getSerializableExtraCompat<AppErrorsInfoBean>(EXTRA_APP_ERRORS_INFO) }.getOrNull()
if (appErrorsInfo == null) {
toastAndFinish(name = "AppErrorsInfo")
return false
@@ -179,9 +176,9 @@ class AppErrorsDetailActivity : BaseActivity<ActivityAppErrorsDetailBinding>() {
intent?.removeExtra(EXTRA_APP_ERRORS_INFO)
finish()
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
if (intent.parseAppErrorsInfo()) binding.appPanelScrollView.scrollTo(0, 0)
if (initUi(intent)) binding.appPanelScrollView.scrollTo(0, 0)
}
}