Skip to content

Commit

Permalink
fix: crash in dialogError
Browse files Browse the repository at this point in the history
  • Loading branch information
klxiaoniu committed Apr 3, 2024
1 parent b06a1c0 commit 174eeec
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions app/src/main/java/com/xiaoniu/qqversionlist/util/InfoUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,20 @@ object InfoUtil {

fun Activity.dialogError(e: Exception) {
runOnUiThread {

val errorDialog =
MaterialAlertDialogBuilder(this)
.setTitle("程序出错,可前往 GitHub 反馈")
.setIcon(R.drawable.error_warning_line)
.setMessage(e.stackTraceToString())
.setPositiveButton("确定", null)
.setCancelable(false)
.setNeutralButton("复制", null)
.create()

errorDialog.getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener {
copyText("" + e.stackTraceToString())
}

errorDialog.show()
MaterialAlertDialogBuilder(this)
.setTitle("程序出错,可前往 GitHub 反馈")
.setIcon(R.drawable.error_warning_line)
.setMessage(e.stackTraceToString())
.setPositiveButton("确定", null)
.setCancelable(false)
.setNeutralButton("复制", null)
.create()
.apply {
show()
getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener {
copyText("" + e.stackTraceToString())
}
}
}
}

Expand Down

0 comments on commit 174eeec

Please sign in to comment.