From 2ecd94ffde312240e36c7393df204db4c799b496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A3=E5=8F=A3=E5=90=95?= <156081428@qq.com> Date: Sat, 24 Oct 2020 20:08:02 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=B9=A6=E6=9E=B6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B9=A6=E7=B1=8D=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/data/dao/BookDao.kt | 12 ++++++++++++ .../app/ui/main/bookshelf/BookshelfFragment.kt | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) 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 8794296f6..39986674a 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 @@ -45,6 +45,18 @@ interface BookDao { @get:Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups) & `group` = 0") val noGroupSize: Int + @Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups) & `group` = :groupId") + fun groupCount(groupId: Long): Int + + @get:Query("SELECT count(*) FROM books where origin = '${BookType.local}'") + val localBookCount: Int + + @get:Query("SELECT count(*) FROM books where origin = '${BookType.audio}'") + val audioBookCount: Int + + @get:Query("SELECT count(*) FROM books where origin != '${BookType.audio}' and origin != '${BookType.local}' and `group` = 0") + val noneBookCount: Int + @get:Query("SELECT * FROM books where origin <> '${BookType.local}' and type = 0") val webBooks: List diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index 218bc004a..64f7220f2 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -8,6 +8,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter import androidx.lifecycle.LiveData +import androidx.lifecycle.observe import com.google.android.material.tabs.TabLayout import io.legado.app.App import io.legado.app.R @@ -58,6 +59,11 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b initBookGroupData() } + override fun onResume() { + super.onResume() + adapter.notifyDataSetChanged() + } + override fun onCompatCreateOptionsMenu(menu: Menu) { menuInflater.inflate(R.menu.main_bookshelf, menu) } @@ -209,7 +215,14 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { override fun getPageTitle(position: Int): CharSequence? { - return bookGroups[position].groupName + val group = bookGroups[position] + return "${group.groupName} • ${when (group.groupId) { + AppConst.bookGroupAllId -> "${App.db.bookDao().allBookCount}" + AppConst.bookGroupLocalId -> "${App.db.bookDao().localBookCount}" + AppConst.bookGroupAudioId -> "${App.db.bookDao().audioBookCount}" + AppConst.bookGroupNoneId -> "${App.db.bookDao().noneBookCount}" + else -> "${App.db.bookDao().groupCount(group.groupId)}" + }}" } override fun getItemPosition(`object`: Any): Int { From 39676981d165717ddd6518166c50540cbe13750f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A3=E5=8F=A3=E5=90=95?= <156081428@qq.com> Date: Sat, 24 Oct 2020 23:42:41 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BC=98=E5=8C=96?= 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 39986674a..6749d06f7 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 @@ -45,7 +45,7 @@ interface BookDao { @get:Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups) & `group` = 0") val noGroupSize: Int - @Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups) & `group` = :groupId") + @Query("select count(bookUrl) from books where `group` = :groupId") fun groupCount(groupId: Long): Int @get:Query("SELECT count(*) FROM books where origin = '${BookType.local}'") From f4100a5ffcd4d95d11337738742d18b5694499cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A3=E5=8F=A3=E5=90=95?= <156081428@qq.com> Date: Sun, 1 Nov 2020 16:12:01 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E5=AD=90=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/ui/book/local/ImportBookActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt index 1bda5c1f7..b5615344e 100644 --- a/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt @@ -299,7 +299,7 @@ class ImportBookActivity : VMBaseActivity(R.layout.activity if (uri.toString().isContentPath()) { subDocs.add(DocumentFile.fromSingleUri(this, uri)!!) } else { - path = uri.toString() + path = uri.path.toString() } upPath() } From f60b0890b1e1cb2def0dc01a7eae569b4e6975db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A3=E5=8F=A3=E5=90=95?= <156081428@qq.com> Date: Sun, 1 Nov 2020 16:29:43 +0800 Subject: [PATCH 4/5] =?UTF-8?q?Revert=20"=E4=B9=A6=E6=9E=B6=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B9=A6=E7=B1=8D=E6=95=B0=E9=87=8F"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 2ecd94ff --- .../main/java/io/legado/app/data/dao/BookDao.kt | 2 +- .../app/ui/main/bookshelf/BookshelfFragment.kt | 15 +-------------- 2 files changed, 2 insertions(+), 15 deletions(-) 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 6749d06f7..39986674a 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 @@ -45,7 +45,7 @@ interface BookDao { @get:Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups) & `group` = 0") val noGroupSize: Int - @Query("select count(bookUrl) from books where `group` = :groupId") + @Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups) & `group` = :groupId") fun groupCount(groupId: Long): Int @get:Query("SELECT count(*) FROM books where origin = '${BookType.local}'") diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt index bb93f2001..e1b37f31e 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfFragment.kt @@ -8,7 +8,6 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentStatePagerAdapter import androidx.lifecycle.LiveData -import androidx.lifecycle.observe import com.google.android.material.tabs.TabLayout import io.legado.app.App import io.legado.app.R @@ -59,11 +58,6 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b initBookGroupData() } - override fun onResume() { - super.onResume() - adapter.notifyDataSetChanged() - } - override fun onCompatCreateOptionsMenu(menu: Menu) { menuInflater.inflate(R.menu.main_bookshelf, menu) } @@ -218,14 +212,7 @@ class BookshelfFragment : VMBaseFragment(R.layout.fragment_b FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { override fun getPageTitle(position: Int): CharSequence? { - val group = bookGroups[position] - return "${group.groupName} • ${when (group.groupId) { - AppConst.bookGroupAllId -> "${App.db.bookDao().allBookCount}" - AppConst.bookGroupLocalId -> "${App.db.bookDao().localBookCount}" - AppConst.bookGroupAudioId -> "${App.db.bookDao().audioBookCount}" - AppConst.bookGroupNoneId -> "${App.db.bookDao().noneBookCount}" - else -> "${App.db.bookDao().groupCount(group.groupId)}" - }}" + return bookGroups[position].groupName } override fun getItemPosition(`object`: Any): Int { From d8f0a38a951bf7803800ea4be889d843d9740cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=A3=E5=8F=A3=E5=90=95?= <156081428@qq.com> Date: Sun, 1 Nov 2020 16:31:25 +0800 Subject: [PATCH 5/5] =?UTF-8?q?Revert=20"=E4=B9=A6=E6=9E=B6=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B9=A6=E7=B1=8D=E6=95=B0=E9=87=8F"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 2ecd94ff --- app/src/main/java/io/legado/app/data/dao/BookDao.kt | 12 ------------ 1 file changed, 12 deletions(-) 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 39986674a..8794296f6 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 @@ -45,18 +45,6 @@ interface BookDao { @get:Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups) & `group` = 0") val noGroupSize: Int - @Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups) & `group` = :groupId") - fun groupCount(groupId: Long): Int - - @get:Query("SELECT count(*) FROM books where origin = '${BookType.local}'") - val localBookCount: Int - - @get:Query("SELECT count(*) FROM books where origin = '${BookType.audio}'") - val audioBookCount: Int - - @get:Query("SELECT count(*) FROM books where origin != '${BookType.audio}' and origin != '${BookType.local}' and `group` = 0") - val noneBookCount: Int - @get:Query("SELECT * FROM books where origin <> '${BookType.local}' and type = 0") val webBooks: List