mirror of
https://github.com/gedoor/legado.git
synced 2024-07-17 00:58:29 +08:00
优化
This commit is contained in:
parent
80654461f7
commit
f9233ffb73
@ -96,14 +96,16 @@ interface BookSourceDao {
|
||||
@Query(
|
||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
||||
from book_sources where loginUrl is not null and loginUrl != ''"""
|
||||
from book_sources where loginUrl is not null and loginUrl != ''
|
||||
order by customOrder asc"""
|
||||
)
|
||||
fun flowLogin(): Flow<List<BookSourcePart>>
|
||||
|
||||
@Query(
|
||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
||||
from book_sources where bookSourceGroup is null or bookSourceGroup = '' or bookSourceGroup like '%未分组%'"""
|
||||
from book_sources where bookSourceGroup is null or bookSourceGroup = '' or bookSourceGroup like '%未分组%'
|
||||
order by customOrder asc"""
|
||||
)
|
||||
fun flowNoGroup(): Flow<List<BookSourcePart>>
|
||||
|
||||
@ -144,7 +146,7 @@ interface BookSourceDao {
|
||||
)
|
||||
fun flowExploreGroupsUnProcessed(): Flow<List<String>>
|
||||
|
||||
@Query("select * from book_sources where bookSourceGroup like '%' || :group || '%'")
|
||||
@Query("select * from book_sources where bookSourceGroup like '%' || :group || '%' order by customOrder asc")
|
||||
fun getByGroup(group: String): List<BookSource>
|
||||
|
||||
@Query(
|
||||
@ -153,11 +155,12 @@ interface BookSourceDao {
|
||||
and (bookSourceGroup = :group
|
||||
or bookSourceGroup like :group || ',%'
|
||||
or bookSourceGroup like '%,' || :group
|
||||
or bookSourceGroup like '%,' || :group || ',%')"""
|
||||
or bookSourceGroup like '%,' || :group || ',%')
|
||||
order by customOrder asc"""
|
||||
)
|
||||
fun getEnabledByGroup(group: String): List<BookSource>
|
||||
|
||||
@Query("select * from book_sources where bookUrlPattern != 'NONE' and bookSourceType = :type")
|
||||
@Query("select * from book_sources where bookUrlPattern != 'NONE' and bookSourceType = :type order by customOrder asc")
|
||||
fun getEnabledByType(type: Int): List<BookSource>
|
||||
|
||||
@Query("select * from book_sources where enabled = 1 and bookSourceUrl = :baseUrl")
|
||||
|
@ -128,9 +128,9 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
|
||||
}
|
||||
|
||||
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||
groupMenu = menu.findItem(R.id.menu_group)?.subMenu
|
||||
groupMenu?.findItem(R.id.action_sort)?.subMenu
|
||||
?.setGroupCheckable(R.id.menu_group_sort, true, true)
|
||||
val sortSubMenu = menu.findItem(R.id.action_sort).subMenu!!
|
||||
sortSubMenu.findItem(R.id.menu_sort_desc).isChecked = !sortAscending
|
||||
sortSubMenu.setGroupCheckable(R.id.menu_group_sort, true, true)
|
||||
upGroupMenu()
|
||||
return super.onPrepareOptionsMenu(menu)
|
||||
}
|
||||
@ -146,45 +146,52 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
|
||||
}
|
||||
|
||||
R.id.menu_import_onLine -> showImportDialog()
|
||||
|
||||
R.id.menu_sort_desc -> {
|
||||
sortAscending = !sortAscending
|
||||
item.isChecked = !sortAscending
|
||||
upBookSource(searchView.query?.toString())
|
||||
}
|
||||
|
||||
R.id.menu_sort_manual -> {
|
||||
item.isChecked = true
|
||||
sortCheck(Sort.Default)
|
||||
sort = Sort.Default
|
||||
upBookSource(searchView.query?.toString())
|
||||
}
|
||||
|
||||
R.id.menu_sort_auto -> {
|
||||
item.isChecked = true
|
||||
sortCheck(Sort.Weight)
|
||||
sort = Sort.Weight
|
||||
upBookSource(searchView.query?.toString())
|
||||
}
|
||||
|
||||
R.id.menu_sort_name -> {
|
||||
item.isChecked = true
|
||||
sortCheck(Sort.Name)
|
||||
sort = Sort.Name
|
||||
upBookSource(searchView.query?.toString())
|
||||
}
|
||||
|
||||
R.id.menu_sort_url -> {
|
||||
item.isChecked = true
|
||||
sortCheck(Sort.Url)
|
||||
sort = Sort.Url
|
||||
upBookSource(searchView.query?.toString())
|
||||
}
|
||||
|
||||
R.id.menu_sort_time -> {
|
||||
item.isChecked = true
|
||||
sortCheck(Sort.Update)
|
||||
sort = Sort.Update
|
||||
upBookSource(searchView.query?.toString())
|
||||
}
|
||||
|
||||
R.id.menu_sort_respondTime -> {
|
||||
item.isChecked = true
|
||||
sortCheck(Sort.Respond)
|
||||
sort = Sort.Respond
|
||||
upBookSource(searchView.query?.toString())
|
||||
}
|
||||
|
||||
R.id.menu_sort_enable -> {
|
||||
item.isChecked = true
|
||||
sortCheck(Sort.Enable)
|
||||
sort = Sort.Enable
|
||||
upBookSource(searchView.query?.toString())
|
||||
}
|
||||
|
||||
@ -321,15 +328,6 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
|
||||
showDialogFragment(TextDialog(getString(R.string.help), text, TextDialog.Mode.MD))
|
||||
}
|
||||
|
||||
private fun sortCheck(sort: Sort) {
|
||||
if (this.sort == sort) {
|
||||
sortAscending = !sortAscending
|
||||
} else {
|
||||
sortAscending = true
|
||||
this.sort = sort
|
||||
}
|
||||
}
|
||||
|
||||
private fun initLiveDataGroup() {
|
||||
launch {
|
||||
appDb.bookSourceDao.flowGroups().conflate().collect {
|
||||
|
@ -16,57 +16,6 @@
|
||||
android:id="@+id/menu_group_manage"
|
||||
android:title="@string/group_manage" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_sort"
|
||||
android:title="@string/sort">
|
||||
|
||||
<menu>
|
||||
<group
|
||||
android:id="@+id/menu_group_sort"
|
||||
android:checkableBehavior="single">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_manual"
|
||||
android:checkable="true"
|
||||
android:checked="true"
|
||||
android:title="@string/sort_manual" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_auto"
|
||||
android:checkable="true"
|
||||
android:title="@string/sort_auto" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_name"
|
||||
android:checkable="true"
|
||||
android:title="@string/sort_by_name" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_url"
|
||||
android:checkable="true"
|
||||
android:title="@string/sort_by_url" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_time"
|
||||
android:checkable="true"
|
||||
android:title="@string/sort_by_lastUpdateTime" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_respondTime"
|
||||
android:checkable="true"
|
||||
android:title="@string/sort_by_respondTime" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_enable"
|
||||
android:checkable="true"
|
||||
android:title="@string/is_enabled" />
|
||||
|
||||
</group>
|
||||
|
||||
</menu>
|
||||
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_enabled_group"
|
||||
android:title="@string/enabled" />
|
||||
@ -91,6 +40,66 @@
|
||||
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_sort"
|
||||
android:title="@string/sort"
|
||||
android:icon="@drawable/ic_sort"
|
||||
app:showAsAction="always"
|
||||
tools:ignore="AlwaysShowAction">
|
||||
|
||||
<menu>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_desc"
|
||||
android:checkable="true"
|
||||
android:title="@string/sort_desc" />
|
||||
|
||||
<group
|
||||
android:id="@+id/menu_group_sort"
|
||||
android:checkableBehavior="single">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_manual"
|
||||
android:checkable="true"
|
||||
android:checked="true"
|
||||
android:title="@string/sort_manual" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_auto"
|
||||
android:checkable="true"
|
||||
android:title="@string/sort_auto" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_name"
|
||||
android:checkable="true"
|
||||
android:title="@string/sort_by_name" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_url"
|
||||
android:checkable="true"
|
||||
android:title="@string/sort_by_url" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_time"
|
||||
android:checkable="true"
|
||||
android:title="@string/sort_by_lastUpdateTime" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_respondTime"
|
||||
android:checkable="true"
|
||||
android:title="@string/sort_by_respondTime" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_sort_enable"
|
||||
android:checkable="true"
|
||||
android:title="@string/is_enabled" />
|
||||
|
||||
</group>
|
||||
|
||||
</menu>
|
||||
|
||||
</item>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_add_book_source"
|
||||
android:icon="@drawable/ic_add"
|
||||
|
@ -1113,4 +1113,5 @@
|
||||
<string name="shrink_database">压缩数据库</string>
|
||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||
<string name="is_compress">是否压缩</string>
|
||||
<string name="sort_desc">反序</string>
|
||||
</resources>
|
||||
|
@ -1116,4 +1116,5 @@
|
||||
<string name="shrink_database">压缩数据库</string>
|
||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||
<string name="is_compress">是否压缩</string>
|
||||
<string name="sort_desc">反序</string>
|
||||
</resources>
|
||||
|
@ -1116,4 +1116,5 @@
|
||||
<string name="shrink_database">压缩数据库</string>
|
||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||
<string name="is_compress">是否压缩</string>
|
||||
<string name="sort_desc">反序</string>
|
||||
</resources>
|
||||
|
@ -1113,4 +1113,5 @@
|
||||
<string name="shrink_database">压缩数据库</string>
|
||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||
<string name="is_compress">是否压缩</string>
|
||||
<string name="sort_desc">反序</string>
|
||||
</resources>
|
||||
|
@ -1115,4 +1115,5 @@
|
||||
<string name="shrink_database">压缩数据库</string>
|
||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||
<string name="is_compress">是否压缩</string>
|
||||
<string name="sort_desc">反序</string>
|
||||
</resources>
|
||||
|
@ -1115,4 +1115,5 @@
|
||||
<string name="shrink_database">压缩数据库</string>
|
||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||
<string name="is_compress">是否压缩</string>
|
||||
<string name="sort_desc">反序</string>
|
||||
</resources>
|
||||
|
@ -1116,4 +1116,5 @@
|
||||
<string name="shrink_database">压缩数据库</string>
|
||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||
<string name="is_compress">是否压缩</string>
|
||||
<string name="sort_desc">反序</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user