pull/1238/head
gedoor 3 years ago
parent b5872a98c9
commit 986d6f5d0f
  1. 222
      app/src/main/assets/web/bookSource/index.css
  2. 5
      app/src/main/assets/web/bookSource/index.html
  3. 11
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  4. 20
      app/src/main/java/io/legado/app/base/BaseDialogFragment.kt
  5. 31
      app/src/main/java/io/legado/app/base/BaseFragment.kt
  6. 5
      app/src/main/java/io/legado/app/ui/about/ReadRecordActivity.kt
  7. 7
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt
  8. 9
      app/src/main/java/io/legado/app/ui/book/cache/CacheActivity.kt
  9. 3
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt
  10. 3
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  11. 3
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  12. 3
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  13. 11
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
  14. 5
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  15. 3
      app/src/main/java/io/legado/app/ui/book/read/config/SpeakEngineDialog.kt
  16. 9
      app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt
  17. 9
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt
  18. 5
      app/src/main/java/io/legado/app/ui/book/searchContent/SearchContentActivity.kt
  19. 3
      app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugActivity.kt
  20. 5
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  21. 3
      app/src/main/java/io/legado/app/ui/book/source/manage/GroupManageDialog.kt
  22. 5
      app/src/main/java/io/legado/app/ui/book/toc/BookmarkDialog.kt
  23. 3
      app/src/main/java/io/legado/app/ui/book/toc/BookmarkFragment.kt
  24. 7
      app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt
  25. 3
      app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt
  26. 3
      app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksFragment.kt
  27. 5
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt
  28. 4
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt
  29. 5
      app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt
  30. 9
      app/src/main/java/io/legado/app/ui/replace/GroupManageDialog.kt
  31. 5
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt
  32. 3
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt
  33. 3
      app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesActivity.kt
  34. 3
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  35. 4
      app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugActivity.kt
  36. 3
      app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt
  37. 5
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
  38. 11
      app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt
  39. 3
      app/src/main/java/io/legado/app/ui/widget/dialog/TextDialog.kt
  40. 3
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt

@ -1,148 +1,150 @@
body {
margin: 0;
margin: 0;
}
.editor {
display: flex;
align-items: stretch;
display: flex;
align-items: stretch;
}
.setbox,
.menu,
.outbox {
flex: 1;
display: flex;
flex-flow: column;
max-height: 100vh;
overflow-y: auto;
flex: 1;
display: flex;
flex-flow: column;
max-height: 100vh;
overflow-y: auto;
}
.menu {
justify-content: center;
max-width: 90px;
margin: 0 5px;
justify-content: center;
max-width: 90px;
margin: 0 5px;
}
.menu .button {
width: 90px;
height: 30px;
min-height: 30px;
margin: 5px 0px;
cursor: pointer;
width: 90px;
height: 30px;
min-height: 30px;
margin: 5px 0px;
cursor: pointer;
}
@keyframes stroker {
0% {
stroke-dashoffset: 0
}
100% {
stroke-dashoffset: -240
}
0% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: -240;
}
}
.button rect {
width: 100%;
height: 100%;
fill: transparent;
stroke: #666;
stroke-width: 2px;
width: 100%;
height: 100%;
fill: transparent;
stroke: #666;
stroke-width: 2px;
}
.button rect.busy {
stroke: #fD1850;
stroke-dasharray: 30 90;
animation: stroker 1s linear infinite;
stroke: #fd1850;
stroke-dasharray: 30 90;
animation: stroker 1s linear infinite;
}
.button text {
text-anchor: middle;
dominant-baseline: middle;
text-anchor: middle;
dominant-baseline: middle;
}
.setbox {
min-width: 40em;
min-width: 40em;
}
.rules {
overflow: auto;
}
.rules,
.tabbox {
flex: 1;
display: flex;
flex-flow: column;
flex: 1;
display: flex;
flex-flow: column;
}
.rules>* {
display: flex;
margin: 2px 0;
.rules > * {
display: flex;
margin: 2px 0;
}
.rules textarea {
flex: 1;
margin-left: 5px;
flex: 1;
margin-left: 5px;
}
.rules>*,
.rules>*>div,
.rules > *,
.rules > * > div,
.rules textarea {
min-height: 1em;
min-height: 1em;
}
textarea {
word-break: break-all;
word-break: break-all;
}
.tabtitle {
display: flex;
z-index: 1;
justify-content: flex-end;
display: flex;
z-index: 1;
justify-content: flex-end;
}
.tabtitle>div {
cursor: pointer;
padding: 1px 10px 0 10px;
border-bottom: 3px solid transparent;
font-weight: bold;
.tabtitle > div {
cursor: pointer;
padding: 1px 10px 0 10px;
border-bottom: 3px solid transparent;
font-weight: bold;
}
.tabtitle>.this {
color: #4f9da6;
border-bottom-color: #4EBBE4;
.tabtitle > .this {
color: #4f9da6;
border-bottom-color: #4ebbe4;
}
.tabbody {
flex: 1;
display: flex;
margin-top: -1px;
border: 1px solid #A9A9A9;
height: 0;
}
.tabbody>* {
flex: 1;
flex-flow: column;
display: none;
}
.tabbody>.this {
display: flex;
}
.tabbody>*>.titlebar{
display: flex;
}
.tabbody>*>.titlebar>*{
flex: 1;
margin: 1px 1px 1px 1px;
}
.tabbody>*>.context {
flex: 1;
flex-flow: column;
border: 0;
padding: 5px;
overflow-y: auto;
}
.tabbody>*>.inputbox{
border: 0;
border-bottom: #A9A9A9 solid 1px;
height: 15px;
text-align:center;
}
.link>* {
display: flex;
margin: 5px;
border-bottom: 1px solid;
text-decoration: none;
}
#RuleList>label>* {
background: #eee;
padding-left: 3px;
margin: 2px 0;
cursor: pointer;
}
#RuleList input[type=radio] {
display: none;
}
#RuleList input[type="radio"]:checked+* {
background: #15cda8;
flex: 1;
display: flex;
margin-top: -1px;
border: 1px solid #a9a9a9;
height: 0;
}
.tabbody > * {
flex: 1;
flex-flow: column;
display: none;
}
.tabbody > .this {
display: flex;
}
.tabbody > * > .titlebar {
display: flex;
}
.tabbody > * > .titlebar > * {
flex: 1;
margin: 1px 1px 1px 1px;
}
.tabbody > * > .context {
flex: 1;
flex-flow: column;
border: 0;
padding: 5px;
overflow-y: auto;
}
.tabbody > * > .inputbox {
border: 0;
border-bottom: #a9a9a9 solid 1px;
height: 15px;
text-align: center;
}
.link > * {
display: flex;
margin: 5px;
border-bottom: 1px solid;
text-decoration: none;
}
#RuleList > label > * {
background: #eee;
padding-left: 3px;
margin: 2px 0;
cursor: pointer;
}
#RuleList input[type="radio"] {
display: none;
}
#RuleList input[type="radio"]:checked + * {
background: #15cda8;
}
.isError {
color: #FF0000;
}
color: #ff0000;
}

@ -11,6 +11,9 @@
<body>
<div class="editor">
<div class="setbox">
<div>
<a href="../index.html">←主页</a>
</div>
<div class="rules">
<div><b>基本</b></div>
<div>
@ -395,4 +398,4 @@
<script type="text/javascript" src="index.js"></script>
</body>
</html>
</html>

@ -24,6 +24,9 @@ import io.legado.app.lib.theme.backgroundColor
import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.TitleBar
import io.legado.app.utils.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel
abstract class BaseActivity<VB : ViewBinding>(
@ -32,7 +35,8 @@ abstract class BaseActivity<VB : ViewBinding>(
private val toolBarTheme: Theme = Theme.Auto,
private val transparent: Boolean = false,
private val imageBg: Boolean = true
) : AppCompatActivity() {
) : AppCompatActivity(),
CoroutineScope by MainScope() {
protected abstract val binding: VB
@ -116,6 +120,11 @@ abstract class BaseActivity<VB : ViewBinding>(
setupSystemBar()
}
override fun onDestroy() {
super.onDestroy()
cancel()
}
abstract fun onActivityCreated(savedInstanceState: Bundle?)
final override fun onCreateOptionsMenu(menu: Menu?): Boolean {

@ -4,14 +4,23 @@ import android.os.Bundle
import android.view.View
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.lib.theme.ThemeStore
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlin.coroutines.CoroutineContext
abstract class BaseDialogFragment : DialogFragment() {
abstract class BaseDialogFragment : DialogFragment(), CoroutineScope {
override val coroutineContext: CoroutineContext
get() = job + Dispatchers.Main
private lateinit var job: Job
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
job = Job()
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -30,8 +39,13 @@ abstract class BaseDialogFragment : DialogFragment() {
}
}
override fun onDestroy() {
super.onDestroy()
job.cancel()
}
fun <T> execute(
scope: CoroutineScope = lifecycleScope,
scope: CoroutineScope = this,
context: CoroutineContext = Dispatchers.IO,
block: suspend CoroutineScope.() -> T
) = Coroutine.async(scope, context) { block() }

@ -3,20 +3,22 @@ package io.legado.app.base
import android.annotation.SuppressLint
import android.content.res.Configuration
import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.*
import androidx.appcompat.view.SupportMenuInflater
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
import io.legado.app.R
import io.legado.app.ui.widget.TitleBar
import io.legado.app.utils.applyTint
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlin.coroutines.CoroutineContext
@Suppress("MemberVisibilityCanBePrivate")
abstract class BaseFragment(layoutID: Int) : Fragment(layoutID) {
abstract class BaseFragment(layoutID: Int) : Fragment(layoutID),
CoroutineScope {
lateinit var job: Job
var supportToolbar: Toolbar? = null
private set
@ -24,6 +26,18 @@ abstract class BaseFragment(layoutID: Int) : Fragment(layoutID) {
@SuppressLint("RestrictedApi")
get() = SupportMenuInflater(requireContext())
override val coroutineContext: CoroutineContext
get() = job + Dispatchers.Main
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
job = Job()
return super.onCreateView(inflater, container, savedInstanceState)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
onMultiWindowModeChanged()
@ -50,6 +64,11 @@ abstract class BaseFragment(layoutID: Int) : Fragment(layoutID) {
}
}
override fun onDestroy() {
super.onDestroy()
job.cancel()
}
fun setSupportToolbar(toolbar: Toolbar) {
supportToolbar = toolbar
supportToolbar?.let {

@ -5,7 +5,6 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.ViewGroup
import androidx.lifecycle.lifecycleScope
import io.legado.app.R
import io.legado.app.base.BaseActivity
import io.legado.app.base.adapter.ItemViewHolder
@ -73,7 +72,7 @@ class ReadRecordActivity : BaseActivity<ActivityReadRecordBinding>() {
}
private fun initData() {
lifecycleScope.launch(IO) {
launch(IO) {
val allTime = appDb.readRecordDao.allTime
withContext(Main) {
binding.readRecord.tvReadTime.text = formatDuring(allTime)
@ -116,7 +115,7 @@ class ReadRecordActivity : BaseActivity<ActivityReadRecordBinding>() {
binding.apply {
root.setOnClickListener {
val item = getItem(holder.layoutPosition) ?: return@setOnClickListener
lifecycleScope.launch {
launch {
val book = withContext(IO) {
appDb.bookDao.findByName(item.bookName).firstOrNull()
}

@ -5,7 +5,6 @@ import android.view.Menu
import android.view.MenuItem
import androidx.activity.viewModels
import androidx.appcompat.widget.PopupMenu
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
@ -52,7 +51,7 @@ class ArrangeBookActivity : VMBaseActivity<ActivityArrangeBookBinding, ArrangeBo
override fun onActivityCreated(savedInstanceState: Bundle?) {
groupId = intent.getLongExtra("groupId", -1)
lifecycleScope.launch {
launch {
binding.titleBar.subtitle = withContext(IO) {
appDb.bookGroupDao.getByID(groupId)?.groupName
?: getString(R.string.no_group)
@ -108,7 +107,7 @@ class ArrangeBookActivity : VMBaseActivity<ActivityArrangeBookBinding, ArrangeBo
}
private fun initGroupData() {
lifecycleScope.launch {
launch {
appDb.bookGroupDao.flowAll().collect {
groupList.clear()
groupList.addAll(it)
@ -120,7 +119,7 @@ class ArrangeBookActivity : VMBaseActivity<ActivityArrangeBookBinding, ArrangeBo
private fun initBookData() {
booksFlowJob?.cancel()
booksFlowJob = lifecycleScope.launch {
booksFlowJob = launch {
when (groupId) {
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()

@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.activity.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.snackbar.Snackbar
import io.legado.app.R
@ -67,7 +66,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
override fun onActivityCreated(savedInstanceState: Bundle?) {
groupId = intent.getLongExtra("groupId", -1)
lifecycleScope.launch {
launch {
binding.titleBar.subtitle = withContext(IO) {
appDb.bookGroupDao.getByID(groupId)?.groupName
?: getString(R.string.no_group)
@ -149,7 +148,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
private fun initBookData() {
booksFlowJob?.cancel()
booksFlowJob = lifecycleScope.launch {
booksFlowJob = launch {
when (groupId) {
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
@ -175,7 +174,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
}
private fun initGroupData() {
lifecycleScope.launch {
launch {
appDb.bookGroupDao.flowAll().collect {
groupList.clear()
groupList.addAll(it)
@ -186,7 +185,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
}
private fun initCacheSize(books: List<Book>) {
lifecycleScope.launch(IO) {
launch(IO) {
books.forEach { book ->
val chapterCaches = hashSetOf<String>()
val cacheNames = BookHelp.getChapterFiles(book)

@ -6,7 +6,6 @@ import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
@ -151,7 +150,7 @@ class ChangeSourceDialog : BaseDialogFragment(),
viewModel.searchBooksLiveData.observe(viewLifecycleOwner, {
adapter.setItems(it)
})
lifecycleScope.launch {
launch {
appDb.bookSourceDao.flowGroupEnabled().collect {
groups.clear()
it.map { group ->

@ -9,7 +9,6 @@ import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -80,7 +79,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
}
private fun initData() {
lifecycleScope.launch {
launch {
appDb.bookGroupDao.flowAll().collect {
adapter.setItems(it)
}

@ -10,7 +10,6 @@ import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -108,7 +107,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
}
private fun initData() {
lifecycleScope.launch {
launch {
appDb.bookGroupDao.flowSelect().collect {
adapter.setItems(it)
}

@ -10,7 +10,6 @@ import android.widget.CheckBox
import android.widget.LinearLayout
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import androidx.lifecycle.lifecycleScope
import com.bumptech.glide.RequestBuilder
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestOptions.bitmapTransform
@ -54,7 +53,7 @@ class BookInfoActivity :
private val tocActivityResult = registerForActivityResult(TocActivityResult()) {
it?.let {
viewModel.bookData.value?.let { book ->
lifecycleScope.launch {
launch {
withContext(IO) {
viewModel.durChapterIndex = it.first
book.durChapterIndex = it.first

@ -9,7 +9,6 @@ import android.view.MenuItem
import androidx.activity.viewModels
import androidx.appcompat.widget.PopupMenu
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
@ -125,7 +124,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
}
private fun initData() {
lifecycleScope.launch {
launch {
appDb.bookDao.flowLocalUri().collect {
adapter.upBookHas(it)
}
@ -188,7 +187,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
binding.tvPath.text = path
adapter.selectedUris.clear()
adapter.clearItems()
lifecycleScope.launch(IO) {
launch(IO) {
val docList = DocumentUtils.listFiles(this@ImportBookActivity, lastDoc.uri)
for (i in docList.lastIndex downTo 0) {
val item = docList[i]
@ -252,7 +251,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
adapter.clearItems()
val lastDoc = subDocs.lastOrNull() ?: doc
binding.refreshProgressBar.isAutoLoading = true
lifecycleScope.launch(IO) {
launch(IO) {
viewModel.scanDoc(lastDoc, true, find) {
launch {
binding.refreshProgressBar.isAutoLoading = false
@ -267,7 +266,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
adapter.clearItems()
val file = File(path)
binding.refreshProgressBar.isAutoLoading = true
lifecycleScope.launch(IO) {
launch(IO) {
viewModel.scanFile(file, true, find) {
launch {
binding.refreshProgressBar.isAutoLoading = false
@ -292,7 +291,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
}
private val find: (docItem: DocItem) -> Unit = {
lifecycleScope.launch {
launch {
adapter.addItem(it)
}
}

@ -13,7 +13,6 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.view.get
import androidx.core.view.isVisible
import androidx.core.view.size
import androidx.lifecycle.lifecycleScope
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
import io.legado.app.BuildConfig
import io.legado.app.R
@ -845,7 +844,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
viewModel.searchContentQuery
)
ReadBook.skipToPage(positions[0]) {
lifecycleScope.launch {
launch {
binding.readView.curPage.selectStartMoveIndex(0, positions[1], positions[2])
delay(20L)
when (positions[3]) {
@ -935,7 +934,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
}
}
observeEventSticky<Int>(EventBus.TTS_PROGRESS) { chapterStart ->
lifecycleScope.launch(IO) {
launch(IO) {
if (BaseReadAloudService.isPlay()) {
ReadBook.curTextChapter?.let { textChapter ->
val pageStart = chapterStart - ReadBook.durChapterPos

@ -9,7 +9,6 @@ import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
@ -104,7 +103,7 @@ class SpeakEngineDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
}
private fun initData() {
lifecycleScope.launch {
launch {
appDb.httpTTSDao.flowAll().collect {
adapter.setItems(it)
}

@ -10,7 +10,6 @@ import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.snackbar.Snackbar
@ -92,7 +91,7 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
}
private fun initData() {
lifecycleScope.launch {
launch {
appDb.txtTocRuleDao.observeAll().collect { tocRules ->
initSelectedName(tocRules)
adapter.setItems(tocRules)
@ -222,7 +221,7 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
if (buttonView.isPressed) {
getItem(holder.layoutPosition)?.let {
it.enable = isChecked
lifecycleScope.launch(IO) {
launch(IO) {
appDb.txtTocRuleDao.update(it)
}
}
@ -233,7 +232,7 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
}
ivDelete.setOnClickListener {
getItem(holder.layoutPosition)?.let { item ->
lifecycleScope.launch(IO) {
launch(IO) {
appDb.txtTocRuleDao.delete(item)
}
}
@ -255,7 +254,7 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
for ((index, item) in getItems().withIndex()) {
item.serialNumber = index + 1
}
lifecycleScope.launch(IO) {
launch(IO) {
appDb.txtTocRuleDao.update(*getItems().toTypedArray())
}
}

@ -10,7 +10,6 @@ import android.view.View.VISIBLE
import android.widget.TextView
import androidx.activity.viewModels
import androidx.appcompat.widget.SearchView
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.flexbox.FlexboxLayoutManager
@ -192,7 +191,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
}
private fun initData() {
lifecycleScope.launch {
launch {
appDb.bookSourceDao.flowGroupEnabled().collect {
groups.clear()
it.map { group ->
@ -273,7 +272,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
*/
private fun upHistory(key: String? = null) {
booksFlowJob?.cancel()
booksFlowJob = lifecycleScope.launch {
booksFlowJob = launch {
if (key.isNullOrBlank()) {
binding.tvBookShow.gone()
binding.rvBookshelfSearch.gone()
@ -292,7 +291,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
}
}
historyFlowJob?.cancel()
historyFlowJob = lifecycleScope.launch {
historyFlowJob = launch {
when {
key.isNullOrBlank() -> appDb.searchKeywordDao.flowByUsage()
else -> appDb.searchKeywordDao.flowSearch(key)
@ -359,7 +358,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
* 点击历史关键字
*/
override fun searchHistory(key: String) {
lifecycleScope.launch {
launch {
when {
searchView.query.toString() == key -> {
searchView.setQuery(key, true)

@ -5,7 +5,6 @@ import android.content.Intent
import android.os.Bundle
import androidx.activity.viewModels
import androidx.appcompat.widget.SearchView
import androidx.lifecycle.lifecycleScope
import com.github.liuyueyi.quick.transfer.ChineseUtils
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
@ -116,7 +115,7 @@ class SearchContentActivity :
}
private fun initCacheFileNames(book: Book) {
lifecycleScope.launch(Dispatchers.IO) {
launch(Dispatchers.IO) {
adapter.cacheFileNames.addAll(BookHelp.getChapterFiles(book))
withContext(Dispatchers.Main) {
adapter.notifyItemRangeChanged(0, adapter.itemCount, true)
@ -145,7 +144,7 @@ class SearchContentActivity :
searchResultCounts = 0
viewModel.lastQuery = newText
var searchResults = listOf<SearchResult>()
lifecycleScope.launch(Dispatchers.Main) {
launch(Dispatchers.Main) {
appDb.bookChapterDao.getChapterList(viewModel.bookUrl).map { chapter ->
withContext(Dispatchers.IO) {
if (isLocalBook

@ -5,7 +5,6 @@ import android.view.Menu
import android.view.MenuItem
import androidx.activity.viewModels
import androidx.appcompat.widget.SearchView
import androidx.lifecycle.lifecycleScope
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.databinding.ActivitySourceDebugBinding
@ -37,7 +36,7 @@ class BookSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, BookS
initRecyclerView()
initSearchView()
viewModel.observe { state, msg ->
lifecycleScope.launch {
launch {
adapter.addItem(msg)
if (state == -1 || state == 1000) {
binding.rotateLoading.hide()

@ -10,7 +10,6 @@ import androidx.activity.viewModels
import androidx.appcompat.widget.PopupMenu
import androidx.appcompat.widget.SearchView
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper
import com.google.android.material.snackbar.Snackbar
import io.legado.app.R
@ -198,7 +197,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
private fun upBookSource(searchKey: String? = null) {
sourceFlowJob?.cancel()
sourceFlowJob = lifecycleScope.launch {
sourceFlowJob = launch {
when {
searchKey.isNullOrEmpty() -> {
appDb.bookSourceDao.flowAll()
@ -270,7 +269,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
}
private fun initLiveDataGroup() {
lifecycleScope.launch {
launch {
appDb.bookSourceDao.flowGroup()
.collect {
groups.clear()

@ -9,7 +9,6 @@ import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
@ -67,7 +66,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
}
private fun initData() {
lifecycleScope.launch {
launch {
appDb.bookSourceDao.flowGroup().collect {
val groups = linkedSetOf<String>()
it.map { group ->

@ -5,7 +5,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
import io.legado.app.data.appDb
@ -64,7 +63,7 @@ class BookmarkDialog : BaseDialogFragment() {
tvOk.setOnClickListener {
bookmark.bookText = editBookText.text?.toString() ?: ""
bookmark.content = editContent.text?.toString() ?: ""
lifecycleScope.launch {
launch {
withContext(IO) {
appDb.bookmarkDao.insert(bookmark)
}
@ -72,7 +71,7 @@ class BookmarkDialog : BaseDialogFragment() {
}
}
tvFooterLeft.setOnClickListener {
lifecycleScope.launch {
launch {
withContext(IO) {
appDb.bookmarkDao.delete(bookmark)
}

@ -5,7 +5,6 @@ import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.base.VMBaseFragment
@ -47,7 +46,7 @@ class BookmarkFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_bookmark
override fun upBookmark(searchKey: String?) {
val book = viewModel.bookData.value ?: return
bookmarkFlowJob?.cancel()
bookmarkFlowJob = lifecycleScope.launch {
bookmarkFlowJob = launch {
when {
searchKey.isNullOrBlank() -> appDb.bookmarkDao.flowByBook(book.name, book.author)
else -> appDb.bookmarkDao.flowSearch(book.name, book.author, searchKey)

@ -6,7 +6,6 @@ import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import io.legado.app.R
import io.legado.app.base.VMBaseFragment
import io.legado.app.constant.EventBus
@ -78,7 +77,7 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
@SuppressLint("SetTextI18n")
private fun initBook(book: Book) {
lifecycleScope.launch {
launch {
upChapterList(null)
durChapterIndex = book.durChapterIndex
binding.tvCurrentChapterInfo.text =
@ -88,7 +87,7 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
}
private fun initCacheFileNames(book: Book) {
lifecycleScope.launch(IO) {
launch(IO) {
adapter.cacheFileNames.addAll(BookHelp.getChapterFiles(book))
withContext(Main) {
adapter.notifyItemRangeChanged(0, adapter.itemCount, true)
@ -109,7 +108,7 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
override fun upChapterList(searchKey: String?) {
tocFlowJob?.cancel()
tocFlowJob = lifecycleScope.launch {
tocFlowJob = launch {
when {
searchKey.isNullOrBlank() -> appDb.bookChapterDao.flowByBook(viewModel.bookUrl)
else -> appDb.bookChapterDao.flowSearch(viewModel.bookUrl, searchKey)

@ -10,7 +10,6 @@ import androidx.appcompat.widget.SearchView
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.lifecycle.lifecycleScope
import com.google.android.material.tabs.TabLayout
import io.legado.app.R
import io.legado.app.constant.AppConst
@ -78,7 +77,7 @@ class BookshelfFragment1 : BaseBookshelfFragment(R.layout.fragment_bookshelf),
}
private fun initBookGroupData() {
lifecycleScope.launch {
launch {
appDb.bookGroupDao.flowShow().collect {
viewModel.checkGroup(it)
upGroup(it)

@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.View
import androidx.core.view.isGone
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -105,7 +104,7 @@ class BooksFragment : BaseFragment(R.layout.fragment_books),
private fun upRecyclerData() {
booksFlowJob?.cancel()
booksFlowJob = lifecycleScope.launch {
booksFlowJob = launch {
when (groupId) {
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()

@ -6,7 +6,6 @@ import android.view.View
import androidx.appcompat.widget.SearchView
import androidx.core.view.isGone
import androidx.lifecycle.LiveData
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -122,7 +121,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
}
private fun initGroupData() {
lifecycleScope.launch {
launch {
appDb.bookGroupDao.flowShow().collect {
if (it != bookGroups) {
bookGroups = it
@ -134,7 +133,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
private fun initBooksData() {
booksFlowJob?.cancel()
booksFlowJob = lifecycleScope.launch {
booksFlowJob = launch {
when (groupId) {
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()

@ -102,7 +102,7 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
}
private fun initGroupData() {
lifecycleScope.launch {
launch {
appDb.bookSourceDao.flowExploreGroup()
.collect {
groups.clear()
@ -116,7 +116,7 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
private fun upExploreData(searchKey: String? = null) {
exploreFlowJob?.cancel()
exploreFlowJob = lifecycleScope.launch {
exploreFlowJob = launch {
val exploreFlow = when {
searchKey.isNullOrBlank() -> {
appDb.bookSourceDao.flowExplore()

@ -7,7 +7,6 @@ import android.view.SubMenu
import android.view.View
import androidx.appcompat.widget.SearchView
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import io.legado.app.R
import io.legado.app.base.VMBaseFragment
import io.legado.app.constant.AppPattern
@ -121,7 +120,7 @@ class RssFragment : VMBaseFragment<RssSourceViewModel>(R.layout.fragment_rss),
}
private fun initGroupData() {
lifecycleScope.launch {
launch {
appDb.rssSourceDao.flowGroup().collect {
groups.clear()
it.map { group ->
@ -134,7 +133,7 @@ class RssFragment : VMBaseFragment<RssSourceViewModel>(R.layout.fragment_rss),
private fun upRssFlowJob(searchKey: String? = null) {
rssFlowJob?.cancel()
rssFlowJob = lifecycleScope.launch {
rssFlowJob = launch {
when {
searchKey.isNullOrEmpty() -> appDb.rssSourceDao.flowEnabled()
searchKey.startsWith("group:") -> {

@ -8,11 +8,10 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.constant.AppPattern
@ -30,7 +29,7 @@ import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
private val viewModel: ReplaceRuleViewModel by activityViewModels()
private lateinit var adapter: GroupAdapter
private val binding by viewBinding(DialogRecyclerViewBinding::bind)
@ -49,7 +48,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
return inflater.inflate(R.layout.dialog_recycler_view, container)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
view.setBackgroundColor(backgroundColor)
binding.toolBar.setBackgroundColor(primaryColor)
@ -69,7 +68,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
}
private fun initData() {
lifecycleScope.launch {
launch {
appDb.replaceRuleDao.flowGroup().collect {
val groups = linkedSetOf<String>()
it.map { group ->

@ -11,7 +11,6 @@ import androidx.activity.viewModels
import androidx.appcompat.widget.PopupMenu
import androidx.appcompat.widget.SearchView
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
@ -171,7 +170,7 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
private fun observeReplaceRuleData(searchKey: String? = null) {
dataInit = false
replaceRuleFlowJob?.cancel()
replaceRuleFlowJob = lifecycleScope.launch {
replaceRuleFlowJob = launch {
when {
searchKey.isNullOrEmpty() -> {
appDb.replaceRuleDao.flowAll()
@ -194,7 +193,7 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
}
private fun observeGroupData() {
lifecycleScope.launch {
launch {
appDb.replaceRuleDao.flowGroup().collect {
groups.clear()
it.map { group ->

@ -5,7 +5,6 @@ import android.os.Bundle
import android.view.View
import androidx.fragment.app.activityViewModels
import androidx.fragment.app.viewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -97,7 +96,7 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
private fun initData() {
val rssUrl = activityViewModel.url ?: return
articlesFlowJob?.cancel()
articlesFlowJob = lifecycleScope.launch {
articlesFlowJob = launch {
appDb.rssArticleDao.flowByOriginSort(rssUrl, viewModel.sortName).collect {
adapter.setItems(it)
}

@ -1,7 +1,6 @@
package io.legado.app.ui.rss.favorites
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.base.BaseActivity
import io.legado.app.data.appDb
@ -36,7 +35,7 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>(),
}
private fun initData() {
lifecycleScope.launch {
launch {
appDb.rssStarDao.liveAll().collect {
adapter.setItems(it)
}

@ -11,7 +11,6 @@ import android.view.*
import android.webkit.*
import androidx.activity.viewModels
import androidx.core.view.size
import androidx.lifecycle.lifecycleScope
import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewFeature
import io.legado.app.R
@ -229,7 +228,7 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
}
override fun upTtsMenu(isPlaying: Boolean) {
lifecycleScope.launch {
launch {
if (isPlaying) {
ttsMenuItem?.setIcon(R.drawable.ic_stop_black_24dp)
ttsMenuItem?.setTitle(R.string.aloud_stop)

@ -5,14 +5,12 @@ import android.view.Menu
import android.view.MenuItem
import android.widget.SearchView
import androidx.activity.viewModels
import androidx.lifecycle.lifecycleScope
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.databinding.ActivitySourceDebugBinding
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor
import io.legado.app.ui.widget.dialog.TextDialog
import io.legado.app.utils.gone
import io.legado.app.utils.toastOnUi
import io.legado.app.utils.viewbindingdelegate.viewBinding
@ -30,7 +28,7 @@ class RssSourceDebugActivity : VMBaseActivity<ActivitySourceDebugBinding, RssSou
initRecyclerView()
initSearchView()
viewModel.observe { state, msg ->
lifecycleScope.launch {
launch {
adapter.addItem(msg)
if (state == -1 || state == 1000) {
binding.rotateLoading.hide()

@ -9,7 +9,6 @@ import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
@ -69,7 +68,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
}
private fun initData() {
lifecycleScope.launch {
launch {
appDb.rssSourceDao.flowGroup().collect {
val groups = linkedSetOf<String>()
it.map { group ->

@ -10,7 +10,6 @@ import androidx.activity.viewModels
import androidx.appcompat.widget.PopupMenu
import androidx.appcompat.widget.SearchView
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
@ -173,7 +172,7 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
}
private fun initGroupFlow() {
lifecycleScope.launch {
launch {
appDb.rssSourceDao.flowGroup().collect {
groups.clear()
it.map { group ->
@ -225,7 +224,7 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
private fun upSourceFlow(searchKey: String? = null) {
sourceFlowJob?.cancel()
sourceFlowJob = lifecycleScope.launch {
sourceFlowJob = launch {
when {
searchKey.isNullOrBlank() -> {
appDb.rssSourceDao.flowAll()

@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.core.view.isGone
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.ItemTouchHelper
import io.legado.app.R
import io.legado.app.base.BaseActivity
@ -62,7 +61,7 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(),
}
private fun initData() {
lifecycleScope.launch {
launch {
appDb.ruleSubDao.flowAll().collect {
binding.tvEmptyMsg.isGone = it.isNotEmpty()
adapter.setItems(it)
@ -93,7 +92,7 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(),
}
customView { alertBinding.root }
okButton {
lifecycleScope.launch {
launch {
ruleSub.type = alertBinding.spType.selectedItemPosition
ruleSub.name = alertBinding.etName.text?.toString() ?: ""
ruleSub.url = alertBinding.etUrl.text?.toString() ?: ""
@ -114,19 +113,19 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(),
}
override fun delSubscription(ruleSub: RuleSub) {
lifecycleScope.launch(IO) {
launch(IO) {
appDb.ruleSubDao.delete(ruleSub)
}
}
override fun updateSourceSub(vararg ruleSub: RuleSub) {
lifecycleScope.launch(IO) {
launch(IO) {
appDb.ruleSubDao.update(*ruleSub)
}
}
override fun upOrder() {
lifecycleScope.launch(IO) {
launch(IO) {
val sourceSubs = appDb.ruleSubDao.all
for ((index: Int, ruleSub: RuleSub) in sourceSubs.withIndex()) {
ruleSub.customOrder = index + 1

@ -5,7 +5,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
import io.legado.app.databinding.DialogTextViewBinding
@ -80,7 +79,7 @@ class TextDialog : BaseDialogFragment() {
}
if (time > 0) {
binding.badgeView.setBadgeCount((time / 1000).toInt())
lifecycleScope.launch {
launch {
while (time > 0) {
delay(1000)
time -= 1000

@ -9,7 +9,6 @@ import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
@ -127,7 +126,7 @@ class FontSelectDialog : BaseDialogFragment(),
}
private fun openFolder() {
lifecycleScope.launch(Main) {
launch(Main) {
val defaultPath = "SD${File.separator}Fonts"
selectFontDir.launch(
FilePickerParam(

Loading…
Cancel
Save