Simplify UI code for Magisk logs

We have all texts, no need to go through recyclerview
This commit is contained in:
topjohnwu
2020-06-29 05:22:16 -07:00
parent ddc2f317ab
commit 89e9e7c176
3 changed files with 41 additions and 32 deletions

View File

@@ -15,8 +15,22 @@ class LogRepository(
fun fetchLogs() = logDao.fetchAll()
fun fetchMagiskLogs() = Single.fromCallable {
Shell.su("tail -n 5000 ${Const.MAGISK_LOG}").exec().out
}.flattenAsFlowable { it }.filter { it.isNotEmpty() }
val list = object : AbstractMutableList<String>() {
val buf = StringBuilder()
override val size get() = 0
override fun get(index: Int): String = ""
override fun removeAt(index: Int): String = ""
override fun set(index: Int, element: String): String = ""
override fun add(index: Int, element: String) {
if (element.isNotEmpty()) {
buf.append(element)
buf.append('\n')
}
}
}
Shell.su("cat ${Const.MAGISK_LOG}").to(list).exec()
list.buf.toString()
}
fun clearLogs() = logDao.deleteAll()