优化书籍详情页;优化分组长SQL (#4596)

* 书籍详情页书名和分组信息过长时可滑动查看

* 书籍分组SQL优化
This commit is contained in:
niuhb
2025-02-01 22:06:22 +08:00
committed by GitHub
parent 7aae910ef5
commit 0e2ecfacc5
2 changed files with 51 additions and 37 deletions
@@ -26,13 +26,15 @@ interface BookGroupDao {
@get:Query( @get:Query(
""" """
with const as (SELECT sum(groupId) sumGroupId FROM book_groups where groupId > 0) with const as (SELECT sum(groupId) sumGroupId FROM book_groups where groupId > 0)
SELECT book_groups.* FROM book_groups, const SELECT book_groups.* FROM book_groups join const
where (groupId >= 0 and show > 0 and exists (select 1 from books where `group` & book_groups.groupId > 0)) where show > 0
or (groupId = -1 and show > 0) and (
or (groupId = -2 and show > 0 and exists (select 1 from books where type & ${BookType.local} > 0)) (groupId >= 0 and exists (select 1 from books where `group` & book_groups.groupId > 0))
or (groupId = -3 and show > 0 and exists (select 1 from books where type & ${BookType.audio} > 0)) or groupId = -1
or (groupId = -11 and show > 0 and exists (select 1 from books where type & ${BookType.updateError} > 0)) or (groupId = -2 and exists (select 1 from books where type & ${BookType.local} > 0))
or (groupId = -4 and show > 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 ( and exists (
select 1 from books select 1 from books
where type & ${BookType.audio} = 0 where type & ${BookType.audio} = 0
@@ -40,7 +42,7 @@ interface BookGroupDao {
and const.sumGroupId & `group` = 0 and const.sumGroupId & `group` = 0
) )
) )
or (groupId = -5 and show > 0 or (groupId = -5
and exists ( and exists (
select 1 from books select 1 from books
where type & ${BookType.audio} = 0 where type & ${BookType.audio} = 0
@@ -48,6 +50,7 @@ interface BookGroupDao {
and const.sumGroupId & `group` = 0 and const.sumGroupId & `group` = 0
) )
) )
)
ORDER BY `order`""" ORDER BY `order`"""
) )
val show: LiveData<List<BookGroup>> val show: LiveData<List<BookGroup>>
+14 -3
View File
@@ -105,27 +105,38 @@
android:paddingRight="10dp" android:paddingRight="10dp"
android:paddingBottom="3dp"> android:paddingBottom="3dp">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<TextView <TextView
android:id="@+id/tv_name" android:id="@+id/tv_name"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="6dp" android:layout_marginBottom="6dp"
android:gravity="center" android:gravity="center"
android:layout_gravity="center"
android:includeFontPadding="false" android:includeFontPadding="false"
android:singleLine="true" android:singleLine="true"
android:text="@string/book_name" android:text="@string/book_name"
android:textColor="@color/primaryText" android:textColor="@color/primaryText"
android:textSize="18sp" android:textSize="18sp"
tools:ignore="RtlHardcoded" /> tools:ignore="RtlHardcoded" />
</HorizontalScrollView>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none">
<io.legado.app.ui.widget.LabelsBar <io.legado.app.ui.widget.LabelsBar
android:id="@+id/lb_kind" android:id="@+id/lb_kind"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginBottom="6dp"
android:gravity="center" android:gravity="center"
android:layout_marginBottom="6dp"
android:visibility="gone" /> android:visibility="gone" />
</HorizontalScrollView>
</LinearLayout> </LinearLayout>