From 4a55f0c52ed6fe365268f78e5a7e43caa0e7b7cc Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 10 Sep 2021 17:31:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/AppLog.kt | 2 +- .../main/java/io/legado/app/ui/document/HandleFileViewModel.kt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/constant/AppLog.kt b/app/src/main/java/io/legado/app/constant/AppLog.kt index a9db5d848..8a175fb2a 100644 --- a/app/src/main/java/io/legado/app/constant/AppLog.kt +++ b/app/src/main/java/io/legado/app/constant/AppLog.kt @@ -5,7 +5,7 @@ object AppLog { val logs = arrayListOf>() @Synchronized - fun addLog(message: String?, throwable: Throwable?) { + fun addLog(message: String?, throwable: Throwable? = null) { message ?: return if (logs.size > 100) { logs.removeLastOrNull() diff --git a/app/src/main/java/io/legado/app/ui/document/HandleFileViewModel.kt b/app/src/main/java/io/legado/app/ui/document/HandleFileViewModel.kt index 71168e333..37fb436f8 100644 --- a/app/src/main/java/io/legado/app/ui/document/HandleFileViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/document/HandleFileViewModel.kt @@ -5,6 +5,7 @@ import android.net.Uri import androidx.documentfile.provider.DocumentFile import androidx.lifecycle.MutableLiveData import io.legado.app.base.BaseViewModel +import io.legado.app.constant.AppLog import io.legado.app.help.DirectLinkUpload import io.legado.app.utils.FileUtils import io.legado.app.utils.isContentScheme @@ -27,6 +28,7 @@ class HandleFileViewModel(application: Application) : BaseViewModel(application) }.onSuccess { success.invoke(it) }.onError { + AppLog.addLog("上传文件失败\n${it.localizedMessage}", it) it.printOnDebug() errorLiveData.postValue(it.localizedMessage) }