优化
This commit is contained in:
@@ -96,14 +96,16 @@ interface BookSourceDao {
|
|||||||
@Query(
|
@Query(
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
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>>
|
fun flowLogin(): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
"""select bookSourceUrl, bookSourceName, bookSourceGroup, customOrder, enabled, enabledExplore,
|
||||||
trim(loginUrl) <> '' hasLoginUrl, lastUpdateTime, respondTime, weight, trim(exploreUrl) <> '' hasExploreUrl
|
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>>
|
fun flowNoGroup(): Flow<List<BookSourcePart>>
|
||||||
|
|
||||||
@@ -144,7 +146,7 @@ interface BookSourceDao {
|
|||||||
)
|
)
|
||||||
fun flowExploreGroupsUnProcessed(): Flow<List<String>>
|
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>
|
fun getByGroup(group: String): List<BookSource>
|
||||||
|
|
||||||
@Query(
|
@Query(
|
||||||
@@ -153,11 +155,12 @@ interface BookSourceDao {
|
|||||||
and (bookSourceGroup = :group
|
and (bookSourceGroup = :group
|
||||||
or bookSourceGroup like :group || ',%'
|
or bookSourceGroup like :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>
|
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>
|
fun getEnabledByType(type: Int): List<BookSource>
|
||||||
|
|
||||||
@Query("select * from book_sources where enabled = 1 and bookSourceUrl = :baseUrl")
|
@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 {
|
override fun onPrepareOptionsMenu(menu: Menu): Boolean {
|
||||||
groupMenu = menu.findItem(R.id.menu_group)?.subMenu
|
val sortSubMenu = menu.findItem(R.id.action_sort).subMenu!!
|
||||||
groupMenu?.findItem(R.id.action_sort)?.subMenu
|
sortSubMenu.findItem(R.id.menu_sort_desc).isChecked = !sortAscending
|
||||||
?.setGroupCheckable(R.id.menu_group_sort, true, true)
|
sortSubMenu.setGroupCheckable(R.id.menu_group_sort, true, true)
|
||||||
upGroupMenu()
|
upGroupMenu()
|
||||||
return super.onPrepareOptionsMenu(menu)
|
return super.onPrepareOptionsMenu(menu)
|
||||||
}
|
}
|
||||||
@@ -146,45 +146,52 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
|
|||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_import_onLine -> showImportDialog()
|
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 -> {
|
R.id.menu_sort_manual -> {
|
||||||
item.isChecked = true
|
item.isChecked = true
|
||||||
sortCheck(Sort.Default)
|
sort = Sort.Default
|
||||||
upBookSource(searchView.query?.toString())
|
upBookSource(searchView.query?.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_sort_auto -> {
|
R.id.menu_sort_auto -> {
|
||||||
item.isChecked = true
|
item.isChecked = true
|
||||||
sortCheck(Sort.Weight)
|
sort = Sort.Weight
|
||||||
upBookSource(searchView.query?.toString())
|
upBookSource(searchView.query?.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_sort_name -> {
|
R.id.menu_sort_name -> {
|
||||||
item.isChecked = true
|
item.isChecked = true
|
||||||
sortCheck(Sort.Name)
|
sort = Sort.Name
|
||||||
upBookSource(searchView.query?.toString())
|
upBookSource(searchView.query?.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_sort_url -> {
|
R.id.menu_sort_url -> {
|
||||||
item.isChecked = true
|
item.isChecked = true
|
||||||
sortCheck(Sort.Url)
|
sort = Sort.Url
|
||||||
upBookSource(searchView.query?.toString())
|
upBookSource(searchView.query?.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_sort_time -> {
|
R.id.menu_sort_time -> {
|
||||||
item.isChecked = true
|
item.isChecked = true
|
||||||
sortCheck(Sort.Update)
|
sort = Sort.Update
|
||||||
upBookSource(searchView.query?.toString())
|
upBookSource(searchView.query?.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_sort_respondTime -> {
|
R.id.menu_sort_respondTime -> {
|
||||||
item.isChecked = true
|
item.isChecked = true
|
||||||
sortCheck(Sort.Respond)
|
sort = Sort.Respond
|
||||||
upBookSource(searchView.query?.toString())
|
upBookSource(searchView.query?.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.menu_sort_enable -> {
|
R.id.menu_sort_enable -> {
|
||||||
item.isChecked = true
|
item.isChecked = true
|
||||||
sortCheck(Sort.Enable)
|
sort = Sort.Enable
|
||||||
upBookSource(searchView.query?.toString())
|
upBookSource(searchView.query?.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,15 +328,6 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
|
|||||||
showDialogFragment(TextDialog(getString(R.string.help), text, TextDialog.Mode.MD))
|
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() {
|
private fun initLiveDataGroup() {
|
||||||
launch {
|
launch {
|
||||||
appDb.bookSourceDao.flowGroups().conflate().collect {
|
appDb.bookSourceDao.flowGroups().conflate().collect {
|
||||||
|
|||||||
@@ -16,11 +16,44 @@
|
|||||||
android:id="@+id/menu_group_manage"
|
android:id="@+id/menu_group_manage"
|
||||||
android:title="@string/group_manage" />
|
android:title="@string/group_manage" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_enabled_group"
|
||||||
|
android:title="@string/enabled" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_disabled_group"
|
||||||
|
android:title="@string/disabled" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_group_login"
|
||||||
|
android:title="@string/need_login" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_group_null"
|
||||||
|
android:title="@string/no_group" />
|
||||||
|
|
||||||
|
<group android:id="@+id/source_group">
|
||||||
|
|
||||||
|
</group>
|
||||||
|
|
||||||
|
</menu>
|
||||||
|
|
||||||
|
</item>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_sort"
|
android:id="@+id/action_sort"
|
||||||
android:title="@string/sort">
|
android:title="@string/sort"
|
||||||
|
android:icon="@drawable/ic_sort"
|
||||||
|
app:showAsAction="always"
|
||||||
|
tools:ignore="AlwaysShowAction">
|
||||||
|
|
||||||
<menu>
|
<menu>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_sort_desc"
|
||||||
|
android:checkable="true"
|
||||||
|
android:title="@string/sort_desc" />
|
||||||
|
|
||||||
<group
|
<group
|
||||||
android:id="@+id/menu_group_sort"
|
android:id="@+id/menu_group_sort"
|
||||||
android:checkableBehavior="single">
|
android:checkableBehavior="single">
|
||||||
@@ -67,30 +100,6 @@
|
|||||||
|
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_enabled_group"
|
|
||||||
android:title="@string/enabled" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_disabled_group"
|
|
||||||
android:title="@string/disabled" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_group_login"
|
|
||||||
android:title="@string/need_login" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/menu_group_null"
|
|
||||||
android:title="@string/no_group" />
|
|
||||||
|
|
||||||
<group android:id="@+id/source_group">
|
|
||||||
|
|
||||||
</group>
|
|
||||||
|
|
||||||
</menu>
|
|
||||||
|
|
||||||
</item>
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_add_book_source"
|
android:id="@+id/menu_add_book_source"
|
||||||
android:icon="@drawable/ic_add"
|
android:icon="@drawable/ic_add"
|
||||||
|
|||||||
@@ -1113,4 +1113,5 @@
|
|||||||
<string name="shrink_database">压缩数据库</string>
|
<string name="shrink_database">压缩数据库</string>
|
||||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||||
<string name="is_compress">是否压缩</string>
|
<string name="is_compress">是否压缩</string>
|
||||||
|
<string name="sort_desc">反序</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1116,4 +1116,5 @@
|
|||||||
<string name="shrink_database">压缩数据库</string>
|
<string name="shrink_database">压缩数据库</string>
|
||||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||||
<string name="is_compress">是否压缩</string>
|
<string name="is_compress">是否压缩</string>
|
||||||
|
<string name="sort_desc">反序</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1116,4 +1116,5 @@
|
|||||||
<string name="shrink_database">压缩数据库</string>
|
<string name="shrink_database">压缩数据库</string>
|
||||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||||
<string name="is_compress">是否压缩</string>
|
<string name="is_compress">是否压缩</string>
|
||||||
|
<string name="sort_desc">反序</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1113,4 +1113,5 @@
|
|||||||
<string name="shrink_database">压缩数据库</string>
|
<string name="shrink_database">压缩数据库</string>
|
||||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||||
<string name="is_compress">是否压缩</string>
|
<string name="is_compress">是否压缩</string>
|
||||||
|
<string name="sort_desc">反序</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1115,4 +1115,5 @@
|
|||||||
<string name="shrink_database">压缩数据库</string>
|
<string name="shrink_database">压缩数据库</string>
|
||||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||||
<string name="is_compress">是否压缩</string>
|
<string name="is_compress">是否压缩</string>
|
||||||
|
<string name="sort_desc">反序</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1115,4 +1115,5 @@
|
|||||||
<string name="shrink_database">压缩数据库</string>
|
<string name="shrink_database">压缩数据库</string>
|
||||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||||
<string name="is_compress">是否压缩</string>
|
<string name="is_compress">是否压缩</string>
|
||||||
|
<string name="sort_desc">反序</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1116,4 +1116,5 @@
|
|||||||
<string name="shrink_database">压缩数据库</string>
|
<string name="shrink_database">压缩数据库</string>
|
||||||
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
<string name="shrink_database_summary">减小数据库文件的大小</string>
|
||||||
<string name="is_compress">是否压缩</string>
|
<string name="is_compress">是否压缩</string>
|
||||||
|
<string name="sort_desc">反序</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user