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" /> + +