优化
This commit is contained in:
@@ -760,7 +760,7 @@ class HomeActivity : BaseActivity() {
|
||||
* 过期时间定时任务
|
||||
*/
|
||||
private fun overdueTask() {
|
||||
overdueTaskJob = taskExecutor.startIntervalTaskWithInitialDelay(5 * 1000L, 10 * 1000L) {
|
||||
overdueTaskJob = taskExecutor.startIntervalTaskWithInitialDelay(5 * 1000L, 5 * 60* 1000L) {
|
||||
updateOverdueState()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class CrashHandler private constructor(private val context: Context) :
|
||||
|
||||
companion object {
|
||||
private const val TAG = "CrashHandler"
|
||||
private const val CRASH_REPORTS_DIR = "crash_reports"
|
||||
const val CRASH_REPORTS_DIR = "crash_reports"
|
||||
private const val LOG_LINES = 500 // 收集最近500行日志
|
||||
|
||||
@Volatile
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.shuwei.intelligent.shelves.utils
|
||||
|
||||
import android.content.Context
|
||||
import com.shuwei.intelligent.shelves.utils.CrashHandler.Companion.CRASH_REPORTS_DIR
|
||||
import java.io.*
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
@@ -80,17 +81,38 @@ class FileLogger(private val context: Context) {
|
||||
return readLogsByName(fileName)
|
||||
}
|
||||
fun readLogsByName(fileName: String): List<String> {
|
||||
return try {
|
||||
try {
|
||||
val input = context.openFileInput(fileName)
|
||||
val reader = BufferedReader(InputStreamReader(input))
|
||||
reader.useLines { lines ->
|
||||
lines.toList()
|
||||
val list: MutableList<String> = reader.useLines { lines ->
|
||||
lines.toList().toMutableList()
|
||||
}
|
||||
|
||||
// val input2 = FileInputStream(getCrashDir(context))
|
||||
// val reader2 = BufferedReader(InputStreamReader(input2))
|
||||
// val list2: MutableList<String> = reader2.useLines {lines ->
|
||||
// lines.toList().toMutableList()
|
||||
// }
|
||||
// list.addAll(list2)
|
||||
return list
|
||||
} catch (e: FileNotFoundException) {
|
||||
emptyList()
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
public fun getCrashDir(context: Context):File {
|
||||
//val crashDir = File(context.getExternalFilesDir(null), CRASH_REPORTS_DIR)
|
||||
var crashDir = File(context.filesDir, CRASH_REPORTS_DIR)
|
||||
if (!crashDir.exists()) {
|
||||
crashDir.mkdirs()
|
||||
}
|
||||
|
||||
if (!(crashDir.exists())) {
|
||||
crashDir = File(context.cacheDir, CRASH_REPORTS_DIR)
|
||||
}
|
||||
return crashDir
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有日志文件列表
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user