pull/2274/head
kunfei 2 years ago
parent c4a6151e60
commit 9fee4f4025
  1. 8
      app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt
  2. 7
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt
  3. 7
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt
  4. 7
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt

@ -89,7 +89,7 @@ interface BookSourceDao {
fun flowGroupsUnProcessed(): Flow<List<String>> fun flowGroupsUnProcessed(): Flow<List<String>>
@Query("select distinct bookSourceGroup from book_sources where enabled = 1 and trim(bookSourceGroup) <> ''") @Query("select distinct bookSourceGroup from book_sources where enabled = 1 and trim(bookSourceGroup) <> ''")
fun flowGroupEnabled(): Flow<List<String>> fun flowEnabledGroupsUnProcessed(): Flow<List<String>>
@Query( @Query(
"""select distinct bookSourceGroup from book_sources """select distinct bookSourceGroup from book_sources
@ -186,4 +186,10 @@ interface BookSourceDao {
dealGroups(list) dealGroups(list)
} }
} }
fun flowEnabledGroups(): Flow<List<String>> {
return flowEnabledGroupsUnProcessed().map { list ->
dealGroups(list)
}
}
} }

@ -14,7 +14,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseDialogFragment
import io.legado.app.constant.AppPattern
import io.legado.app.constant.EventBus import io.legado.app.constant.EventBus
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
@ -188,11 +187,9 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
} }
} }
launch { launch {
appDb.bookSourceDao.flowGroupEnabled().conflate().collect { appDb.bookSourceDao.flowEnabledGroups().conflate().collect {
groups.clear() groups.clear()
it.map { group -> groups.addAll(it)
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
}
upGroupMenu() upGroupMenu()
} }
} }

@ -14,7 +14,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseDialogFragment
import io.legado.app.constant.AppPattern
import io.legado.app.constant.EventBus import io.legado.app.constant.EventBus
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
@ -210,11 +209,9 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
} }
} }
launch { launch {
appDb.bookSourceDao.flowGroupEnabled().conflate().collect { appDb.bookSourceDao.flowEnabledGroups().conflate().collect {
groups.clear() groups.clear()
it.map { group -> groups.addAll(it)
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
}
upGroupMenu() upGroupMenu()
} }
} }

@ -16,7 +16,6 @@ import androidx.recyclerview.widget.RecyclerView
import com.google.android.flexbox.FlexboxLayoutManager import com.google.android.flexbox.FlexboxLayoutManager
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.AppPattern
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
@ -245,11 +244,9 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
} }
} }
launch { launch {
appDb.bookSourceDao.flowGroupEnabled().conflate().collect { appDb.bookSourceDao.flowEnabledGroups().conflate().collect {
groups.clear() groups.clear()
it.map { group -> groups.addAll(it)
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
}
upGroupMenu() upGroupMenu()
} }
} }

Loading…
Cancel
Save