优化
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user