From 91a7a71636c2ea4c626af973bf5982ddaac67d17 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 17 Feb 2020 20:49:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/CrashHandler.kt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/CrashHandler.kt b/app/src/main/java/io/legado/app/help/CrashHandler.kt index 9a5c7131a..f597bb846 100644 --- a/app/src/main/java/io/legado/app/help/CrashHandler.kt +++ b/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() + mContext?.externalCacheDir?.let { + FileUtils.createFileIfNotExist(it, fileName, "crash") + .writeText(sb.toString()) } - val fos = FileOutputStream(path + fileName) - fos.write(sb.toString().toByteArray()) - fos.close() } }