From 0f0bd505848104560b7f8b084539fbf564ec63df Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 29 Aug 2020 09:36:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9B=AE=E5=BD=95=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/help/BookHelp.kt | 3 +++ .../io/legado/app/ui/book/chapterlist/ChapterListAdapter.kt | 4 +++- .../io/legado/app/ui/book/chapterlist/ChapterListFragment.kt | 3 +++ app/src/main/res/layout/item_chapter_list.xml | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) 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 b0e5575f8..85d5aaa87 100644 --- a/app/src/main/java/io/legado/app/help/BookHelp.kt +++ b/app/src/main/java/io/legado/app/help/BookHelp.kt @@ -108,6 +108,9 @@ object BookHelp { fun getChapterFiles(book: Book): List { val fileNameList = arrayListOf() + if (book.isLocalBook()) { + return fileNameList + } FileUtils.createFolderIfNotExist( downloadDir, subDirs = arrayOf(cacheFolderName, book.getFolderName()) diff --git a/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListAdapter.kt b/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListAdapter.kt index 17970bc65..5d4b3621b 100644 --- a/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListAdapter.kt @@ -22,7 +22,8 @@ class ChapterListAdapter(context: Context, val callback: Callback) : override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList) { with(holder.itemView) { val isDur = callback.durChapterIndex() == item.index - val cached = cacheFileNames.contains(BookHelp.formatChapterName(item)) + val cached = callback.isLocalBook + || cacheFileNames.contains(BookHelp.formatChapterName(item)) if (payloads.isEmpty()) { if (isDur) { tv_chapter_name.setTextColor(context.accentColor) @@ -60,6 +61,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) : } interface Callback { + val isLocalBook: Boolean fun openChapter(bookChapter: BookChapter) fun durChapterIndex(): Int } diff --git a/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListFragment.kt b/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListFragment.kt index 58d47efeb..d4339bb23 100644 --- a/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListFragment.kt +++ b/app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListFragment.kt @@ -129,6 +129,9 @@ class ChapterListFragment : VMBaseFragment(R.layout.fragme } } + override val isLocalBook: Boolean + get() = viewModel.book?.isLocalBook() == true + override fun durChapterIndex(): Int { return durChapterIndex } diff --git a/app/src/main/res/layout/item_chapter_list.xml b/app/src/main/res/layout/item_chapter_list.xml index b0e9d4f23..285af05ba 100644 --- a/app/src/main/res/layout/item_chapter_list.xml +++ b/app/src/main/res/layout/item_chapter_list.xml @@ -29,8 +29,8 @@