From 0e2ecfacc5d10255f546f1f4da451e2b00181e87 Mon Sep 17 00:00:00 2001 From: niuhb <76513019+niu-hb@users.noreply.github.com> Date: Sat, 1 Feb 2025 22:06:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B9=A6=E7=B1=8D=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=EF=BC=9B=E4=BC=98=E5=8C=96=E5=88=86=E7=BB=84?= =?UTF-8?q?=E9=95=BFSQL=20(#4596)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 书籍详情页书名和分组信息过长时可滑动查看 * 书籍分组SQL优化 --- .../io/legado/app/data/dao/BookGroupDao.kt | 41 ++++++++-------- .../main/res/layout/activity_book_info.xml | 47 ++++++++++++------- 2 files changed, 51 insertions(+), 37 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt b/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt index 667429d34..724cae6f9 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt @@ -26,26 +26,29 @@ interface BookGroupDao { @get:Query( """ with const as (SELECT sum(groupId) sumGroupId FROM book_groups where groupId > 0) - SELECT book_groups.* FROM book_groups, const - where (groupId >= 0 and show > 0 and exists (select 1 from books where `group` & book_groups.groupId > 0)) - or (groupId = -1 and show > 0) - or (groupId = -2 and show > 0 and exists (select 1 from books where type & ${BookType.local} > 0)) - or (groupId = -3 and show > 0 and exists (select 1 from books where type & ${BookType.audio} > 0)) - or (groupId = -11 and show > 0 and exists (select 1 from books where type & ${BookType.updateError} > 0)) - or (groupId = -4 and show > 0 - and exists ( - select 1 from books - where type & ${BookType.audio} = 0 - and type & ${BookType.local} = 0 - and const.sumGroupId & `group` = 0 + SELECT book_groups.* FROM book_groups join const + where show > 0 + and ( + (groupId >= 0 and exists (select 1 from books where `group` & book_groups.groupId > 0)) + or groupId = -1 + or (groupId = -2 and exists (select 1 from books where type & ${BookType.local} > 0)) + or (groupId = -3 and exists (select 1 from books where type & ${BookType.audio} > 0)) + or (groupId = -11 and exists (select 1 from books where type & ${BookType.updateError} > 0)) + or (groupId = -4 + and exists ( + select 1 from books + where type & ${BookType.audio} = 0 + and type & ${BookType.local} = 0 + and const.sumGroupId & `group` = 0 + ) ) - ) - or (groupId = -5 and show > 0 - and exists ( - select 1 from books - where type & ${BookType.audio} = 0 - and type & ${BookType.local} > 0 - and const.sumGroupId & `group` = 0 + or (groupId = -5 + and exists ( + select 1 from books + where type & ${BookType.audio} = 0 + and type & ${BookType.local} > 0 + and const.sumGroupId & `group` = 0 + ) ) ) ORDER BY `order`""" diff --git a/app/src/main/res/layout/activity_book_info.xml b/app/src/main/res/layout/activity_book_info.xml index a5ad5d5c7..a01adad97 100644 --- a/app/src/main/res/layout/activity_book_info.xml +++ b/app/src/main/res/layout/activity_book_info.xml @@ -105,27 +105,38 @@ android:paddingRight="10dp" android:paddingBottom="3dp"> - + android:layout_height="match_parent" + android:scrollbars="none"> + + - + android:layout_height="match_parent" + android:scrollbars="none"> + +