From 53b596a3e8de26bf043780cae896139a1b388655 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 22 Mar 2020 16:39:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/arrange/ArrangeBookActivity.kt | 12 ++++++++++-- .../app/ui/main/bookshelf/books/BooksFragment.kt | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt index 15217f3bc..1fe5e1f63 100644 --- a/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt @@ -11,6 +11,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.App import io.legado.app.R import io.legado.app.base.VMBaseActivity +import io.legado.app.constant.PreferKey import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookGroup import io.legado.app.help.ItemTouchCallback @@ -23,6 +24,7 @@ import io.legado.app.ui.book.group.GroupSelectDialog import io.legado.app.ui.widget.SelectActionBar import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.utils.applyTint +import io.legado.app.utils.getPrefInt import io.legado.app.utils.getViewModel import kotlinx.android.synthetic.main.activity_arrange_book.* @@ -109,8 +111,14 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi -11 -> App.db.bookDao().observeNoGroup() else -> App.db.bookDao().observeByGroup(groupId) } - booksLiveData?.observe(this, Observer { - adapter.setItems(it) + booksLiveData?.observe(this, Observer { list -> + val books = when (getPrefInt(PreferKey.bookshelfSort)) { + 1 -> list.sortedByDescending { it.latestChapterTime } + 2 -> list.sortedBy { it.name } + 3 -> list.sortedBy { it.order } + else -> list + } + adapter.setItems(books) upSelectCount() }) } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt index d82480ca2..f791b6f5c 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt @@ -108,7 +108,7 @@ class BooksFragment : BaseFragment(R.layout.fragment_books), 1 -> list.sortedByDescending { it.latestChapterTime } 2 -> list.sortedBy { it.name } 3 -> list.sortedBy { it.order } - else -> list.sortedByDescending { it.durChapterTime } + else -> list } val diffResult = DiffUtil .calculateDiff(BooksDiffCallBack(booksAdapter.getItems(), books))