pull/1652/head
kunfei 3 years ago
parent 77291fb8ab
commit 196843350e
  1. 12
      app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt
  2. 12
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeBookSourceDialog.kt
  3. 12
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeChapterSourceDialog.kt
  4. 3
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt

@ -6,6 +6,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.viewModels
import androidx.lifecycle.whenStarted
import androidx.recyclerview.widget.GridLayoutManager
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
@ -14,6 +15,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.utils.applyTint
import io.legado.app.utils.setLayout
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.launch
@ -66,10 +68,12 @@ class ChangeCoverDialog() : BaseDialogFragment(R.layout.dialog_change_cover),
}
private fun initData() {
launch {
viewModel.dataFlow.conflate().collect {
adapter.setItems(it)
delay(1000)
launch(Dispatchers.Default) {
whenStarted {
viewModel.dataFlow.conflate().collect {
adapter.setItems(it)
delay(1000)
}
}
}
}

@ -9,6 +9,7 @@ import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.Toolbar
import androidx.core.os.bundleOf
import androidx.fragment.app.viewModels
import androidx.lifecycle.whenStarted
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
@ -28,6 +29,7 @@ import io.legado.app.ui.book.source.manage.BookSourceActivity
import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.launch
@ -144,10 +146,12 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
}
binding.toolBar.menu.applyTint(requireContext())
}
launch {
viewModel.searchDataFlow.conflate().collect {
adapter.setItems(it)
delay(1000)
launch(Dispatchers.Default) {
whenStarted {
viewModel.searchDataFlow.conflate().collect {
adapter.setItems(it)
delay(1000)
}
}
}
launch {

@ -9,6 +9,7 @@ import androidx.appcompat.widget.Toolbar
import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.fragment.app.viewModels
import androidx.lifecycle.whenStarted
import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
@ -30,6 +31,7 @@ import io.legado.app.ui.book.source.manage.BookSourceActivity
import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.launch
@ -176,10 +178,12 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
}
binding.toolBar.menu.applyTint(requireContext())
}
launch {
viewModel.searchDataFlow.conflate().collect {
searchBookAdapter.setItems(it)
delay(1000)
launch(Dispatchers.Default) {
whenStarted {
viewModel.searchDataFlow.conflate().collect {
searchBookAdapter.setItems(it)
delay(1000)
}
}
}
launch {

@ -29,6 +29,7 @@ import io.legado.app.ui.book.source.manage.BookSourceActivity
import io.legado.app.ui.widget.recycler.LoadMoreView
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Dispatchers.Default
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
@ -198,7 +199,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
}
private fun initData() {
lifecycleScope.launch {
lifecycleScope.launch(Default) {
whenStarted {
viewModel.searchDataFlow.conflate().collect {
adapter.setItems(it)

Loading…
Cancel
Save