mirror of
https://github.com/KitsunePie/AppErrorsTracking.git
synced 2025-09-04 02:05:16 +08:00
Merge pull request #132 from ZQDesigned/master
[BUG FIX] Deprecated AppErrorInfo when dialog covers AppErrorsDetailActivity
This commit is contained in:
@@ -62,8 +62,34 @@ class AppErrorsDetailActivity : BaseActivity<ActivityAppErrorsDetailBinding>() {
|
|||||||
private var stackTrace = ""
|
private var stackTrace = ""
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
|
if (initUi(intent).not()) return
|
||||||
|
binding.titleBackIcon.setOnClickListener { onBackPressed() }
|
||||||
|
binding.disableAutoWrapErrorStackTraceSwitch.bind(ConfigData.DISABLE_AUTO_WRAP_ERROR_STACK_TRACE) {
|
||||||
|
onInitialize {
|
||||||
|
binding.errorStackTraceScrollView.isVisible = it
|
||||||
|
binding.errorStackTraceFixedText.isGone = it
|
||||||
|
}
|
||||||
|
onChanged {
|
||||||
|
reinitialize()
|
||||||
|
resetScrollView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
binding.detailTitleText.setOnClickListener { binding.appPanelScrollView.smoothScrollTo(0, 0) }
|
||||||
|
resetScrollView()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 [Intent] 中解析 [AppErrorsInfoBean] 并加载至界面
|
||||||
|
*
|
||||||
|
* @param intent 用于获取并解析 [AppErrorsInfoBean] 的 [Intent] 实例
|
||||||
|
* @return [Boolean] 是否解析成功:true 为成功;false 为失败,可能是 [Intent] 为空或者 [AppErrorsInfoBean] 为空
|
||||||
|
*/
|
||||||
|
private fun initUi(intent: Intent?): Boolean {
|
||||||
val appErrorsInfo = runCatching { intent?.getSerializableExtraCompat<AppErrorsInfoBean>(EXTRA_APP_ERRORS_INFO) }.getOrNull()
|
val appErrorsInfo = runCatching { intent?.getSerializableExtraCompat<AppErrorsInfoBean>(EXTRA_APP_ERRORS_INFO) }.getOrNull()
|
||||||
?: return toastAndFinish(name = "AppErrorsInfo")
|
if (appErrorsInfo == null) {
|
||||||
|
toastAndFinish(name = "AppErrorsInfo")
|
||||||
|
return false
|
||||||
|
}
|
||||||
if (appErrorsInfo.isEmpty) {
|
if (appErrorsInfo.isEmpty) {
|
||||||
binding.appPanelScrollView.isVisible = false
|
binding.appPanelScrollView.isVisible = false
|
||||||
showDialog {
|
showDialog {
|
||||||
@@ -80,10 +106,9 @@ class AppErrorsDetailActivity : BaseActivity<ActivityAppErrorsDetailBinding>() {
|
|||||||
}
|
}
|
||||||
noCancelable()
|
noCancelable()
|
||||||
}
|
}
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
binding.appInfoItem.setOnClickListener { openSelfSetting(appErrorsInfo.packageName) }
|
binding.appInfoItem.setOnClickListener { openSelfSetting(appErrorsInfo.packageName) }
|
||||||
binding.titleBackIcon.setOnClickListener { onBackPressed() }
|
|
||||||
binding.printIcon.setOnClickListener {
|
binding.printIcon.setOnClickListener {
|
||||||
loggerE(msg = appErrorsInfo.stackTrace)
|
loggerE(msg = appErrorsInfo.stackTrace)
|
||||||
toast(LocaleString.printToLogcatSuccess)
|
toast(LocaleString.printToLogcatSuccess)
|
||||||
@@ -122,23 +147,12 @@ class AppErrorsDetailActivity : BaseActivity<ActivityAppErrorsDetailBinding>() {
|
|||||||
binding.errorRecordTimeText.text = appErrorsInfo.dateTime
|
binding.errorRecordTimeText.text = appErrorsInfo.dateTime
|
||||||
binding.errorStackTraceMovableText.text = appErrorsInfo.stackTrace
|
binding.errorStackTraceMovableText.text = appErrorsInfo.stackTrace
|
||||||
binding.errorStackTraceFixedText.text = appErrorsInfo.stackTrace
|
binding.errorStackTraceFixedText.text = appErrorsInfo.stackTrace
|
||||||
binding.disableAutoWrapErrorStackTraceSwitch.bind(ConfigData.DISABLE_AUTO_WRAP_ERROR_STACK_TRACE) {
|
|
||||||
onInitialize {
|
|
||||||
binding.errorStackTraceScrollView.isVisible = it
|
|
||||||
binding.errorStackTraceFixedText.isGone = it
|
|
||||||
}
|
|
||||||
onChanged {
|
|
||||||
reinitialize()
|
|
||||||
resetScrollView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
binding.appPanelScrollView.setOnScrollChangeListener { _, _, y, _, _ ->
|
binding.appPanelScrollView.setOnScrollChangeListener { _, _, y, _, _ ->
|
||||||
binding.detailTitleText.text = if (y >= 30.dp(context = this))
|
binding.detailTitleText.text = if (y >= 30.dp(context = this@AppErrorsDetailActivity))
|
||||||
appNameOf(appErrorsInfo.packageName).ifBlank { appErrorsInfo.packageName }
|
appNameOf(appErrorsInfo.packageName).ifBlank { appErrorsInfo.packageName }
|
||||||
else LocaleString.appName
|
else LocaleString.appName
|
||||||
}
|
}
|
||||||
binding.detailTitleText.setOnClickListener { binding.appPanelScrollView.smoothScrollTo(0, 0) }
|
return true
|
||||||
resetScrollView()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 修复在一些小屏设备上设置了 [TextView.setTextIsSelectable] 后布局自动上滑问题 */
|
/** 修复在一些小屏设备上设置了 [TextView.setTextIsSelectable] 后布局自动上滑问题 */
|
||||||
@@ -163,4 +177,9 @@ class AppErrorsDetailActivity : BaseActivity<ActivityAppErrorsDetailBinding>() {
|
|||||||
intent?.removeExtra(EXTRA_APP_ERRORS_INFO)
|
intent?.removeExtra(EXTRA_APP_ERRORS_INFO)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onNewIntent(intent: Intent?) {
|
||||||
|
super.onNewIntent(intent)
|
||||||
|
if (initUi(intent)) binding.appPanelScrollView.scrollTo(0, 0)
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user