From e8bc9374ce45b3f7964c9e1e9338c9cc622f8a83 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 8 Sep 2020 17:27:09 +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/storage/Backup.kt | 4 ++-- .../ui/book/source/edit/BookSourceEditActivity.kt | 12 +++--------- .../ui/rss/source/edit/RssSourceEditActivity.kt | 14 +++----------- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/storage/Backup.kt b/app/src/main/java/io/legado/app/help/storage/Backup.kt index c08f0dd1d..b52688846 100644 --- a/app/src/main/java/io/legado/app/help/storage/Backup.kt +++ b/app/src/main/java/io/legado/app/help/storage/Backup.kt @@ -63,11 +63,11 @@ object Backup { writeListToJson(App.db.txtTocRule().all, "txtTocRule.json", backupPath) writeListToJson(App.db.readRecordDao().all, "readRecord.json", backupPath) writeListToJson(App.db.httpTTSDao().all, "httpTTS.json", backupPath) - GSON.toJson(ReadBookConfig.configList)?.let { + GSON.toJson(ReadBookConfig.configList).let { FileUtils.createFileIfNotExist(backupPath + File.separator + ReadBookConfig.configFileName) .writeText(it) } - GSON.toJson(ThemeConfig.configList)?.let { + GSON.toJson(ThemeConfig.configList).let { FileUtils.createFileIfNotExist(backupPath + File.separator + ThemeConfig.configFileName) .writeText(it) } diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index 8a7deb2ab..57421991d 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -74,17 +74,11 @@ class BookSourceEditActivity : } } } - R.id.menu_copy_source -> getSource().let { source -> - GSON.toJson(source)?.let { sourceStr -> - sendToClip(sourceStr) - } - } + R.id.menu_copy_source -> sendToClip(GSON.toJson(getSource())) R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView(it) } R.id.menu_qr_code_camera -> startActivityForResult(qrRequestCode) - R.id.menu_share_str -> GSON.toJson(getSource())?.let { share(it) } - R.id.menu_share_qr -> GSON.toJson(getSource())?.let { sourceStr -> - shareWithQr(getString(R.string.share_book_source), sourceStr) - } + R.id.menu_share_str -> share(GSON.toJson(getSource())) + R.id.menu_share_qr -> shareWithQr(getString(R.string.share_book_source), GSON.toJson(getSource())) R.id.menu_rule_summary -> { try { val intent = Intent(Intent.ACTION_VIEW) diff --git a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt index 5072861ec..34b795a2b 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt @@ -91,19 +91,11 @@ class RssSourceEditActivity : } } } - R.id.menu_copy_source -> { - GSON.toJson(getRssSource())?.let { sourceStr -> - sendToClip(sourceStr) - } - } + R.id.menu_copy_source -> sendToClip(GSON.toJson(getRssSource())) R.id.menu_qr_code_camera -> startActivityForResult(qrRequestCode) R.id.menu_paste_source -> viewModel.pasteSource { upRecyclerView(it) } - R.id.menu_share_str -> GSON.toJson(getRssSource())?.let { sourceStr -> - share(sourceStr) - } - R.id.menu_share_qr -> GSON.toJson(getRssSource())?.let { sourceStr -> - shareWithQr(getString(R.string.share_rss_source), sourceStr) - } + R.id.menu_share_str -> share(GSON.toJson(getRssSource())) + R.id.menu_share_qr -> shareWithQr(getString(R.string.share_rss_source), GSON.toJson(getRssSource())) } return super.onCompatOptionsItemSelected(item) }