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