From b2ac302c45e987379b46b0ddecd82fd8efcb6b1f Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 27 Sep 2019 14:38:49 +0800 Subject: [PATCH] up --- .../java/io/legado/app/ui/main/bookshelf/BooksAdapter.kt | 2 +- .../java/io/legado/app/ui/main/bookshelf/BooksFragment.kt | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BooksAdapter.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BooksAdapter.kt index 603684163..d6df919e0 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BooksAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BooksAdapter.kt @@ -35,7 +35,7 @@ class BooksAdapter(private val callBack: CallBack) : } fun notification(bookUrl: String) { - for (i in 0..itemCount) { + for (i in 0 until itemCount) { getItem(i)?.let { if (it.bookUrl == bookUrl) { notifyItemChanged(i) diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BooksFragment.kt index 4819d288f..47d168562 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BooksFragment.kt @@ -12,6 +12,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseFragment +import io.legado.app.constant.Bus import io.legado.app.data.entities.Book import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.accentColor @@ -20,6 +21,7 @@ import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.main.MainViewModel import io.legado.app.utils.getViewModel import io.legado.app.utils.getViewModelOfActivity +import io.legado.app.utils.observeEvent import kotlinx.android.synthetic.main.fragment_books.* import org.jetbrains.anko.startActivity @@ -52,6 +54,9 @@ class BooksFragment : VMBaseFragment(R.layout.fragment_books), } initRecyclerView() upRecyclerData() + observeEvent(Bus.UP_BOOK) { + booksAdapter.notification(it) + } } private fun initRecyclerView() { @@ -70,7 +75,6 @@ class BooksFragment : VMBaseFragment(R.layout.fragment_books), }) booksAdapter = BooksAdapter(this) rv_bookshelf.adapter = booksAdapter - } private fun upRecyclerData() {