feat: 优化代码

pull/98/head
kunfei 5 years ago
parent f708657ce5
commit f9664f3fe7
  1. 15
      app/src/main/java/io/legado/app/ui/chapterlist/ChapterListAdapter.kt
  2. 3
      app/src/main/java/io/legado/app/ui/chapterlist/ChapterListFragment.kt

@ -1,10 +1,10 @@
package io.legado.app.ui.chapterlist
import android.content.Context
import android.widget.TextView
import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.help.BookHelp
import io.legado.app.lib.theme.accentColor
@ -35,17 +35,24 @@ class ChapterListAdapter(context: Context, val callback: Callback) :
this.onClick {
callback.openChapter(item)
}
tv_chapter_name.paint.isFakeBoldText =
upHasCache(
tv_chapter_name,
cacheFileNames.contains(BookHelp.formatChapterName(item))
)
} else {
tv_chapter_name.paint.isFakeBoldText =
upHasCache(
tv_chapter_name,
cacheFileNames.contains(BookHelp.formatChapterName(item))
)
}
}
}
private fun upHasCache(textView: TextView, contains: Boolean) {
textView.paint.isFakeBoldText = contains
}
interface Callback {
fun book(): Book?
fun openChapter(bookChapter: BookChapter)
fun durChapterIndex(): Int
}

@ -118,7 +118,4 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme
activity?.finish()
}
override fun book(): Book? {
return book
}
}
Loading…
Cancel
Save