From 722f71c93110885b4e34f46111b5408a87830aee Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 28 Jan 2020 11:47:24 +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/utils/ACache.kt | 10 +++++----- app/src/main/java/io/legado/app/utils/FileUtils.kt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/ACache.kt b/app/src/main/java/io/legado/app/utils/ACache.kt index 44f96631c..b173dc612 100644 --- a/app/src/main/java/io/legado/app/utils/ACache.kt +++ b/app/src/main/java/io/legado/app/utils/ACache.kt @@ -171,7 +171,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) * @return JSONObject数据 */ fun getAsJSONObject(key: String): JSONObject? { - val json = getAsString(key) + val json = getAsString(key) ?: return null return try { JSONObject(json) } catch (e: Exception) { @@ -311,17 +311,17 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int) fun getAsObject(key: String): Any? { val data = getAsBinary(key) if (data != null) { - var bais: ByteArrayInputStream? = null + var bis: ByteArrayInputStream? = null var ois: ObjectInputStream? = null try { - bais = ByteArrayInputStream(data) - ois = ObjectInputStream(bais) + bis = ByteArrayInputStream(data) + ois = ObjectInputStream(bis) return ois.readObject() } catch (e: Exception) { e.printStackTrace() } finally { try { - bais?.close() + bis?.close() } catch (e: IOException) { e.printStackTrace() } diff --git a/app/src/main/java/io/legado/app/utils/FileUtils.kt b/app/src/main/java/io/legado/app/utils/FileUtils.kt index 39148fe76..23cdcabab 100644 --- a/app/src/main/java/io/legado/app/utils/FileUtils.kt +++ b/app/src/main/java/io/legado/app/utils/FileUtils.kt @@ -43,7 +43,7 @@ object FileUtils { val storageVolumeClazz = Class.forName("android.os.storage.StorageVolume") val getPath = storageVolumeClazz.getMethod("getPath") - val invokeVolumeList = getVolumeList.invoke(storageManager) + val invokeVolumeList = getVolumeList.invoke(storageManager) ?: return null val length = Array.getLength(invokeVolumeList) val list = ArrayList()