优化目录显示

pull/346/head
gedoor 4 years ago
parent 280f2f0a3d
commit 0f0bd50584
  1. 3
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListAdapter.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListFragment.kt
  4. 4
      app/src/main/res/layout/item_chapter_list.xml

@ -108,6 +108,9 @@ object BookHelp {
fun getChapterFiles(book: Book): List<String> { fun getChapterFiles(book: Book): List<String> {
val fileNameList = arrayListOf<String>() val fileNameList = arrayListOf<String>()
if (book.isLocalBook()) {
return fileNameList
}
FileUtils.createFolderIfNotExist( FileUtils.createFolderIfNotExist(
downloadDir, downloadDir,
subDirs = arrayOf(cacheFolderName, book.getFolderName()) subDirs = arrayOf(cacheFolderName, book.getFolderName())

@ -22,7 +22,8 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList<Any>) { override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList<Any>) {
with(holder.itemView) { with(holder.itemView) {
val isDur = callback.durChapterIndex() == item.index 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 (payloads.isEmpty()) {
if (isDur) { if (isDur) {
tv_chapter_name.setTextColor(context.accentColor) tv_chapter_name.setTextColor(context.accentColor)
@ -60,6 +61,7 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
} }
interface Callback { interface Callback {
val isLocalBook: Boolean
fun openChapter(bookChapter: BookChapter) fun openChapter(bookChapter: BookChapter)
fun durChapterIndex(): Int fun durChapterIndex(): Int
} }

@ -129,6 +129,9 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme
} }
} }
override val isLocalBook: Boolean
get() = viewModel.book?.isLocalBook() == true
override fun durChapterIndex(): Int { override fun durChapterIndex(): Int {
return durChapterIndex return durChapterIndex
} }

@ -29,8 +29,8 @@
<ImageView <ImageView
android:id="@+id/iv_checked" android:id="@+id/iv_checked"
android:layout_width="wrap_content" android:layout_width="16dp"
android:layout_height="wrap_content" android:layout_height="16dp"
android:src="@drawable/ic_check" android:src="@drawable/ic_check"
android:visibility="invisible" android:visibility="invisible"
android:contentDescription="@string/success" android:contentDescription="@string/success"

Loading…
Cancel
Save