From 08634398e3d64baf70c0707321fd82d1495697ac Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 22 Jan 2023 22:39:40 +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/help/AppUpdate.kt | 6 ++++-- .../java/io/legado/app/help/http/cronet/Cronet.kt | 13 ++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/AppUpdate.kt b/app/src/main/java/io/legado/app/help/AppUpdate.kt index dcb4272b0..af9b572f8 100644 --- a/app/src/main/java/io/legado/app/help/AppUpdate.kt +++ b/app/src/main/java/io/legado/app/help/AppUpdate.kt @@ -6,8 +6,10 @@ import kotlinx.coroutines.CoroutineScope object AppUpdate { val gitHubUpdate by lazy { - Class.forName("io.legado.app.help.AppUpdateGitHub").kotlin.objectInstance - as? AppUpdateInterface + kotlin.runCatching { + Class.forName("io.legado.app.help.AppUpdateGitHub") + .kotlin.objectInstance as AppUpdateInterface + }.getOrNull() } data class UpdateInfo( diff --git a/app/src/main/java/io/legado/app/help/http/cronet/Cronet.kt b/app/src/main/java/io/legado/app/help/http/cronet/Cronet.kt index d18abe083..094e6c464 100644 --- a/app/src/main/java/io/legado/app/help/http/cronet/Cronet.kt +++ b/app/src/main/java/io/legado/app/help/http/cronet/Cronet.kt @@ -5,9 +5,10 @@ import okhttp3.Interceptor object Cronet { val loader: CronetLoaderInterface? by lazy { - val cl = Class.forName("io.legado.app.lib.cronet.CronetLoader") - ?.kotlin?.objectInstance - cl as? CronetLoaderInterface + kotlin.runCatching { + Class.forName("io.legado.app.lib.cronet.CronetLoader") + .kotlin.objectInstance as CronetLoaderInterface + }.getOrNull() } fun preDownload() { @@ -15,8 +16,10 @@ object Cronet { } val interceptor: Interceptor? by lazy { - val cl = Class.forName("io.legado.app.lib.cronet.CronetInterceptor")?.newInstance() - cl as? Interceptor + kotlin.runCatching { + Class.forName("io.legado.app.lib.cronet.CronetInterceptor") + .newInstance() as Interceptor + }.getOrNull() } } \ No newline at end of file