From 0fdb4c7e4a3258e5d3a193d6727229311c07134b Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 12 Sep 2020 19:02:01 +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/help/ThemeConfig.kt | 26 ++++++++++++------- .../legado/app/ui/config/ThemeListDialog.kt | 3 +-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ThemeConfig.kt b/app/src/main/java/io/legado/app/help/ThemeConfig.kt index f0434680b..5061d129f 100644 --- a/app/src/main/java/io/legado/app/help/ThemeConfig.kt +++ b/app/src/main/java/io/legado/app/help/ThemeConfig.kt @@ -7,7 +7,6 @@ import io.legado.app.App import io.legado.app.R import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey -import io.legado.app.help.coroutine.Coroutine import io.legado.app.utils.* import java.io.File @@ -32,13 +31,14 @@ object ThemeConfig { } fun save() { - Coroutine.async { - synchronized(this) { - val json = GSON.toJson(configList) - FileUtils.deleteFile(configFilePath) - FileUtils.createFileIfNotExist(configFilePath).writeText(json) - } - } + val json = GSON.toJson(configList) + FileUtils.deleteFile(configFilePath) + FileUtils.createFileIfNotExist(configFilePath).writeText(json) + } + + fun delConfig(index: Int) { + configList.removeAt(index) + save() } fun addConfig(json: String): Boolean { @@ -116,9 +116,15 @@ object ThemeConfig { fun saveNightTheme(context: Context, name: String) { val primary = - context.getPrefInt(PreferKey.cNPrimary, context.getCompatColor(R.color.md_blue_grey_600)) + context.getPrefInt( + PreferKey.cNPrimary, + context.getCompatColor(R.color.md_blue_grey_600) + ) val accent = - context.getPrefInt(PreferKey.cNAccent, context.getCompatColor(R.color.md_deep_orange_800)) + context.getPrefInt( + PreferKey.cNAccent, + context.getCompatColor(R.color.md_deep_orange_800) + ) val background = context.getPrefInt(PreferKey.cNBackground, context.getCompatColor(R.color.md_grey_900)) val bBackground = diff --git a/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt b/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt index b090332e4..d7000b127 100644 --- a/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt +++ b/app/src/main/java/io/legado/app/ui/config/ThemeListDialog.kt @@ -89,8 +89,7 @@ class ThemeListDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { fun delete(index: Int) { alert(R.string.delete, R.string.sure_del) { okButton { - ThemeConfig.configList.removeAt(index) - ThemeConfig.save() + ThemeConfig.delConfig(index) initData() } noButton()