From a5e5f5405bc6b6cfbc71555131912841bc4cd9a2 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 15 Mar 2022 23:22:54 +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 --- .../main/java/io/legado/app/help/glide/ImageLoader.kt | 2 +- .../main/java/io/legado/app/utils/ContextExtensions.kt | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/glide/ImageLoader.kt b/app/src/main/java/io/legado/app/help/glide/ImageLoader.kt index 407e3a40f..5562a7671 100644 --- a/app/src/main/java/io/legado/app/help/glide/ImageLoader.kt +++ b/app/src/main/java/io/legado/app/help/glide/ImageLoader.kt @@ -29,7 +29,7 @@ object ImageLoader { val byteArray = Base64.decode(dataUriBase64, Base64.DEFAULT) Glide.with(context).load(byteArray) }.getOrDefault( - Glide.with(context).load(path) + GlideApp.with(context).load(path) ) path.isAbsUrl() -> { val url = kotlin.runCatching { diff --git a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt index b32ea7bf1..3ab04d1e8 100644 --- a/app/src/main/java/io/legado/app/utils/ContextExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/ContextExtensions.kt @@ -13,6 +13,7 @@ import android.content.res.ColorStateList import android.content.res.Configuration import android.graphics.Bitmap import android.graphics.drawable.Drawable +import android.net.ConnectivityManager import android.net.Uri import android.os.BatteryManager import android.os.Build @@ -29,7 +30,7 @@ import io.legado.app.R import io.legado.app.constant.AppConst import io.legado.app.help.IntentHelp import splitties.systemservices.clipboardManager - +import splitties.systemservices.connectivityManager import java.io.File import java.io.FileOutputStream @@ -326,6 +327,12 @@ fun Context.openFileUri(uri: Uri, type: String? = null) { } } +val Context.isWifiConnect: Boolean + get() { + val info = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI) + return info?.isConnected == true + } + val Context.isPad: Boolean get() { return resources.configuration.screenLayout and Configuration.SCREENLAYOUT_SIZE_MASK >= Configuration.SCREENLAYOUT_SIZE_LARGE