ErrorActivity: Kotlin-fy buildMarkdown method
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
parent
8968aab578
commit
c3dbed54e5
@ -208,8 +208,8 @@ class ErrorActivity : AppCompatActivity() {
|
|||||||
private fun buildMarkdown(): String {
|
private fun buildMarkdown(): String {
|
||||||
try {
|
try {
|
||||||
return buildString(1024) {
|
return buildString(1024) {
|
||||||
val userComment = binding.errorCommentBox.getText().toString()
|
val userComment = binding.errorCommentBox.text.toString()
|
||||||
if (!userComment.isEmpty()) {
|
if (userComment.isNotEmpty()) {
|
||||||
appendLine(userComment)
|
appendLine(userComment)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,28 +229,27 @@ class ErrorActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
// Collapse all logs to a single paragraph when there are more than one
|
// Collapse all logs to a single paragraph when there are more than one
|
||||||
// to keep the GitHub issue clean.
|
// to keep the GitHub issue clean.
|
||||||
if (errorInfo.stackTraces.size > 1) {
|
if (errorInfo.stackTraces.isNotEmpty()) {
|
||||||
append("<details><summary><b>Exceptions (")
|
append("<details><summary><b>Exceptions (")
|
||||||
append(errorInfo.stackTraces.size)
|
append(errorInfo.stackTraces.size)
|
||||||
append(")</b></summary><p>\n")
|
append(")</b></summary><p>\n")
|
||||||
}
|
|
||||||
|
|
||||||
// add the logs
|
// add the logs
|
||||||
for (i in errorInfo.stackTraces.indices) {
|
errorInfo.stackTraces.forEachIndexed { index, stacktrace ->
|
||||||
append("<details><summary><b>Crash log ")
|
append("<details><summary><b>Crash log ")
|
||||||
if (errorInfo.stackTraces.size > 1) {
|
if (errorInfo.stackTraces.isNotEmpty()) {
|
||||||
append(i + 1)
|
append(index + 1)
|
||||||
|
}
|
||||||
|
append("</b>")
|
||||||
|
append("</summary><p>\n")
|
||||||
|
append("\n```\n${stacktrace}\n```\n")
|
||||||
|
append("</details>\n")
|
||||||
}
|
}
|
||||||
append("</b>")
|
|
||||||
append("</summary><p>\n")
|
|
||||||
append("\n```\n${errorInfo.stackTraces[i]}\n```\n")
|
|
||||||
append("</details>\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure to close everything
|
// make sure to close everything
|
||||||
if (errorInfo.stackTraces.size > 1) {
|
|
||||||
append("</p></details>\n")
|
append("</p></details>\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
append("<hr>\n")
|
append("<hr>\n")
|
||||||
}
|
}
|
||||||
} catch (exception: Exception) {
|
} catch (exception: Exception) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user