From 10f52f3d2ab1665ec09817bee9f84f06555c5b94 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 24 Jul 2020 11:22:39 +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 --- .../java/io/legado/app/ui/config/OtherConfigFragment.kt | 4 +--- app/src/main/java/io/legado/app/ui/main/MainViewModel.kt | 6 +----- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt index 845b73ef2..ec9942eba 100644 --- a/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt +++ b/app/src/main/java/io/legado/app/ui/config/OtherConfigFragment.kt @@ -80,9 +80,7 @@ class OtherConfigFragment : PreferenceFragmentCompat(), } PreferKey.cleanCache -> { BookHelp.clearCache() - requireActivity().cacheDir.listFiles()?.forEach { - it.delete() - } + FileUtils.deleteFile(requireActivity().cacheDir.absolutePath) toast(R.string.clear_cache_success) } PreferKey.defaultCover -> { diff --git a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt index 186f54a92..a3268db42 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt @@ -81,11 +81,7 @@ class MainViewModel(application: Application) : BaseViewModel(application) { fun postLoad() { execute { - FileUtils.getDirFile(context.cacheDir, "Fonts").let { - if (it.exists()) { - it.delete() - } - } + FileUtils.deleteFile(FileUtils.getPath(context.cacheDir, "Fonts")) } } } \ No newline at end of file