From 109784233cbb178558fac81bc46890de67f36b7b Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 12 Feb 2020 21:09:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/constant/EventBus.kt | 1 + app/src/main/java/io/legado/app/help/BookHelp.kt | 2 ++ .../main/java/io/legado/app/ui/download/DownloadActivity.kt | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/constant/EventBus.kt b/app/src/main/java/io/legado/app/constant/EventBus.kt index 3fc80e3ac..ad49cb3e0 100644 --- a/app/src/main/java/io/legado/app/constant/EventBus.kt +++ b/app/src/main/java/io/legado/app/constant/EventBus.kt @@ -21,4 +21,5 @@ object EventBus { const val WEB_SERVICE_STOP = "webServiceStop" const val UP_DOWNLOAD = "upDownload" const val UP_TABS = "upTabs" + const val SAVE_CONTENT = "saveContent" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/BookHelp.kt b/app/src/main/java/io/legado/app/help/BookHelp.kt index 5fb191a96..bf00757bb 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -4,6 +4,7 @@ import android.net.Uri import androidx.documentfile.provider.DocumentFile import com.github.houbb.opencc4j.util.ZhConverterUtil import io.legado.app.App +import io.legado.app.constant.EventBus import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter @@ -68,6 +69,7 @@ object BookHelp { subDirs = *arrayOf(cacheFolderName, bookFolderName(book)) ).writeText(content) } + postEvent(EventBus.SAVE_CONTENT, bookChapter) } fun getChapterFiles(book: Book): List { diff --git a/app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt b/app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt index f499287f2..04c185989 100644 --- a/app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt +++ b/app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt @@ -11,6 +11,7 @@ import io.legado.app.R import io.legado.app.base.BaseActivity import io.legado.app.constant.EventBus import io.legado.app.data.entities.Book +import io.legado.app.data.entities.BookChapter import io.legado.app.help.BookHelp import io.legado.app.service.help.Download import io.legado.app.utils.applyTint @@ -93,11 +94,14 @@ class DownloadActivity : BaseActivity(R.layout.activity_download) { if (it) { menu?.findItem(R.id.menu_download)?.setIcon(R.drawable.ic_stop_black_24dp) menu?.applyTint(this) - adapter.notifyItemRangeChanged(0, adapter.itemCount, true) + adapter.notifyItemRangeChanged(0, adapter.getActualItemCount(), true) } else { menu?.findItem(R.id.menu_download)?.setIcon(R.drawable.ic_play_24dp) menu?.applyTint(this) } } + observeEvent(EventBus.SAVE_CONTENT) { + adapter.cacheChapters[it.bookUrl]?.add(it.url) + } } } \ No newline at end of file