pull/32/head
kunfei 5 years ago
parent bf32846a03
commit 3b6add3594
  1. 6
      app/src/main/java/io/legado/app/data/entities/BookSource.kt
  2. 1
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt
  3. 16
      app/src/main/java/io/legado/app/ui/main/findbook/FindBookAdapter.kt

@ -111,4 +111,10 @@ data class BookSource(
}
return contentRuleV!!
}
fun getExploreKind() {
getExploreRule().exploreUrl?.let {
}
}
}

@ -39,6 +39,7 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application)
postEvent(Bus.UP_BOOK, book.bookUrl)
WebBook(bookSource).getChapterList(book).onSuccess(IO) {
it?.let {
App.db.bookDao().update(book)
if (it.size > App.db.bookChapterDao().getChapterCount(book.bookUrl)) {
App.db.bookChapterDao().insert(*it.toTypedArray())
}

@ -10,10 +10,14 @@ import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.data.entities.BookSource
import io.legado.app.lib.theme.ColorUtils
import io.legado.app.utils.gone
import io.legado.app.utils.invisible
import kotlinx.android.synthetic.main.item_find_book.view.*
class FindBookAdapter:PagedListAdapter<BookSource, FindBookAdapter.MyViewHolder>(DIFF_CALLBACK) {
var exIndex = 0
companion object {
var DIFF_CALLBACK = object : DiffUtil.ItemCallback<BookSource>() {
override fun areItemsTheSame(oldItem: BookSource, newItem: BookSource): Boolean =
@ -31,16 +35,24 @@ class FindBookAdapter:PagedListAdapter<BookSource, FindBookAdapter.MyViewHolder>
override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
currentList?.get(position)?.let {
holder.bind(it)
holder.bind(it, position == exIndex)
}
}
class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
fun bind(bookSource: BookSource) = with(itemView) {
fun bind(bookSource: BookSource, ex: Boolean) = with(itemView) {
val bgShape: GradientDrawable? = tv_name.background as? GradientDrawable
bgShape?.setStroke(2, ColorUtils.getRandomColor())
tv_name.text = bookSource.bookSourceName
if (ex) {
gl_child.invisible()
bookSource.getExploreRule().exploreUrl?.let {
}
} else {
gl_child.gone()
}
}
}
}
Loading…
Cancel
Save