LogViewerActivity: merge lines that don't match regex

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2020-03-26 16:59:54 -06:00
parent a3a429bc41
commit c8ac970d11

View File

@ -209,8 +209,8 @@ class LogViewerActivity : AppCompatActivity() {
rawLogLines.append(line) rawLogLines.append(line)
rawLogLines.append('\n') rawLogLines.append('\n')
val logLine = parseLine(line) val logLine = parseLine(line)
if (logLine != null) { withContext(Dispatchers.Main) {
withContext(Dispatchers.Main) { if (logLine != null) {
recyclerView?.let { recyclerView?.let {
val shouldScroll = it.canScrollVertically(1) val shouldScroll = it.canScrollVertically(1)
logLines.add(logLine) logLines.add(logLine)
@ -218,6 +218,13 @@ class LogViewerActivity : AppCompatActivity() {
if (!shouldScroll) if (!shouldScroll)
it.scrollToPosition(logLines.size - 1) it.scrollToPosition(logLines.size - 1)
} }
} else {
/* I'd prefer for the next line to be:
* logLines.lastOrNull()?.msg += "\n$line"
* However, as of writing, that causes the kotlin compiler to freak out and crash, spewing bytecode.
*/
logLines.lastOrNull()?.apply { msg += "\n$line" }
logAdapter.notifyDataSetChanged()
} }
} }
} }
@ -241,7 +248,7 @@ class LogViewerActivity : AppCompatActivity() {
} }
} }
private data class LogLine(val pid: Int, val tid: Int, val time: Date?, val level: String, val tag: String, val msg: String) private data class LogLine(val pid: Int, val tid: Int, val time: Date?, val level: String, val tag: String, var msg: String)
companion object { companion object {
/** /**