feat: 优化代码

pull/103/head
kunfei 5 years ago
parent b1e85ead4d
commit 91a7a71636
  1. 15
      app/src/main/java/io/legado/app/help/CrashHandler.kt

@ -9,8 +9,7 @@ import android.os.Looper
import android.util.Log
import android.widget.Toast
import io.legado.app.service.TTSReadAloudService
import java.io.File
import java.io.FileOutputStream
import io.legado.app.utils.FileUtils
import java.io.PrintWriter
import java.io.StringWriter
import java.text.SimpleDateFormat
@ -141,14 +140,10 @@ class CrashHandler : Thread.UncaughtExceptionHandler {
val timestamp = System.currentTimeMillis()
val time = format.format(Date())
val fileName = "crash-$time-$timestamp.log"
val path = mContext?.externalCacheDir?.toString() + "/crash/"
val dir = File(path)
if (!dir.exists()) {
dir.mkdirs()
}
val fos = FileOutputStream(path + fileName)
fos.write(sb.toString().toByteArray())
fos.close()
mContext?.externalCacheDir?.let {
FileUtils.createFileIfNotExist(it, fileName, "crash")
.writeText(sb.toString())
}
}
}

Loading…
Cancel
Save