From 2b52966e4693647cca7629911b5e065ddbad1e7b Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 8 Mar 2020 13:47:27 +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/src/main/java/io/legado/app/data/dao/BookDao.kt | 3 +++ .../io/legado/app/ui/book/arrange/ArrangeBookActivity.kt | 6 ++++++ app/src/main/res/menu/arrange_book.xml | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/app/src/main/java/io/legado/app/data/dao/BookDao.kt b/app/src/main/java/io/legado/app/data/dao/BookDao.kt index f25d76be5..b323a2711 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookDao.kt @@ -27,6 +27,9 @@ interface BookDao { @Query("SELECT * FROM books WHERE (`group` & :group) > 0") fun observeByGroup(group: Int): LiveData> + @Query("select * from books where (SELECT sum(groupId) FROM book_groups) & `group` = 0") + fun observeNoGroup(): LiveData> + @Query("SELECT * FROM books WHERE name like '%'||:key||'%' or author like '%'||:key||'%'") fun liveDataSearch(key: String): LiveData> 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 f03cc1df5..f3b0d5ee5 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 @@ -100,6 +100,7 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi -1 -> App.db.bookDao().observeAll() -2 -> App.db.bookDao().observeLocal() -3 -> App.db.bookDao().observeAudio() + -11 -> App.db.bookDao().observeNoGroup() else -> App.db.bookDao().observeByGroup(groupId) } booksLiveData?.observe(this, Observer { @@ -112,6 +113,11 @@ class ArrangeBookActivity : VMBaseActivity(R.layout.activi when (item.itemId) { R.id.menu_group_manage -> GroupManageDialog() .show(supportFragmentManager, "groupManage") + R.id.menu_no_group -> { + title_bar.subtitle = getString(R.string.no_group) + groupId = -11 + initBookData() + } R.id.menu_all -> { title_bar.subtitle = item.title groupId = -1 diff --git a/app/src/main/res/menu/arrange_book.xml b/app/src/main/res/menu/arrange_book.xml index 25f88a1fc..4eb85fb8e 100644 --- a/app/src/main/res/menu/arrange_book.xml +++ b/app/src/main/res/menu/arrange_book.xml @@ -14,6 +14,10 @@ android:id="@+id/menu_group_manage" android:title="@string/group_manage" /> + +