From 3b6add3594bc8773c7735b2867a30aa76cea771b Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 3 Sep 2019 17:36:00 +0800 Subject: [PATCH] up --- .../io/legado/app/data/entities/BookSource.kt | 6 ++++++ .../app/ui/main/bookshelf/BookshelfViewModel.kt | 1 + .../app/ui/main/findbook/FindBookAdapter.kt | 16 ++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/entities/BookSource.kt b/app/src/main/java/io/legado/app/data/entities/BookSource.kt index ef652f3e7..8f1d6448c 100644 --- a/app/src/main/java/io/legado/app/data/entities/BookSource.kt +++ b/app/src/main/java/io/legado/app/data/entities/BookSource.kt @@ -111,4 +111,10 @@ data class BookSource( } return contentRuleV!! } + + fun getExploreKind() { + getExploreRule().exploreUrl?.let { + + } + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt index 0accc1813..fae740f80 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt @@ -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()) } diff --git a/app/src/main/java/io/legado/app/ui/main/findbook/FindBookAdapter.kt b/app/src/main/java/io/legado/app/ui/main/findbook/FindBookAdapter.kt index 41b190618..af0ae836f 100644 --- a/app/src/main/java/io/legado/app/ui/main/findbook/FindBookAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/findbook/FindBookAdapter.kt @@ -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(DIFF_CALLBACK) { + var exIndex = 0 + companion object { var DIFF_CALLBACK = object : DiffUtil.ItemCallback() { override fun areItemsTheSame(oldItem: BookSource, newItem: BookSource): Boolean = @@ -31,16 +35,24 @@ class FindBookAdapter:PagedListAdapter 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() + } } } } \ No newline at end of file