pull/1625/head
kunfei 3 years ago
parent 0b720d084e
commit 78c310b1f0
  1. 8
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/toc/BookmarkFragment.kt
  3. 10
      app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt
  4. 5
      app/src/main/java/io/legado/app/ui/main/bookshelf/style1/books/BooksFragment.kt
  5. 5
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt
  6. 8
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt
  7. 8
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt

@ -42,7 +42,10 @@ import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
/**
* 书源管理界面
@ -269,8 +272,9 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
}
}.catch {
AppLog.put("书源界面更新书源出错", it)
}.collectLatest { data ->
}.collect { data ->
adapter.setItems(data, adapter.diffItemCallback)
delay(500)
}
}
}

@ -17,7 +17,8 @@ import io.legado.app.utils.setEdgeEffectColor
import io.legado.app.utils.showDialogFragment
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.launch
@ -51,8 +52,9 @@ class BookmarkFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_bookmark
when {
searchKey.isNullOrBlank() -> appDb.bookmarkDao.flowByBook(book.name, book.author)
else -> appDb.bookmarkDao.flowSearch(book.name, book.author, searchKey)
}.collectLatest {
}.conflate().collect {
adapter.setItems(it)
delay(100)
}
}
}

@ -21,13 +21,10 @@ import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.observeEvent
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.coroutines.flow.conflate
class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapter_list),
ChapterListAdapter.Callback,
@ -111,7 +108,7 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
when {
searchKey.isNullOrBlank() -> appDb.bookChapterDao.flowByBook(viewModel.bookUrl)
else -> appDb.bookChapterDao.flowSearch(viewModel.bookUrl, searchKey)
}.collectLatest {
}.conflate().collect {
if (!(searchKey.isNullOrBlank() && it.isEmpty())) {
adapter.setItems(it, adapter.diffCallBack)
adapter.upDisplayTile()
@ -119,6 +116,7 @@ class ChapterListFragment : VMBaseFragment<TocViewModel>(R.layout.fragment_chapt
mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0)
}
}
delay(100)
}
}
}

@ -24,8 +24,8 @@ import io.legado.app.ui.main.MainViewModel
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
@ -121,9 +121,10 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
}
}.catch {
AppLog.put("书架更新出错", it)
}.collectLatest { list ->
}.collect { list ->
binding.tvEmptyMsg.isGone = list.isNotEmpty()
booksAdapter.setItems(list)
delay(100)
}
}
}

@ -26,8 +26,8 @@ import io.legado.app.ui.main.bookshelf.BaseBookshelfFragment
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
@ -140,10 +140,11 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
}
}.catch {
AppLog.put("书架更新出错", it)
}.collectLatest { list ->
}.collect { list ->
books = list
booksAdapter.notifyDataSetChanged()
binding.tvEmptyMsg.isGone = getItemCount() > 0
delay(100)
}
}
}

@ -38,8 +38,9 @@ import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.launch
/**
@ -193,14 +194,15 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
else -> {
appDb.replaceRuleDao.flowSearch("%$searchKey%")
}
}.catch {
}.conflate().catch {
AppLog.put("替换规则管理界面更新数据出错", it)
}.collectLatest {
}.collect {
if (dataInit) {
setResult(Activity.RESULT_OK)
}
adapter.setItems(it, adapter.diffItemCallBack)
dataInit = true
delay(100)
}
}
}

@ -33,8 +33,9 @@ import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.*
import io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.conflate
import kotlinx.coroutines.launch
/**
@ -246,10 +247,11 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
else -> {
appDb.rssSourceDao.flowSearch("%$searchKey%")
}
}.catch {
}.conflate().catch {
AppLog.put("订阅源管理界面更新数据出错", it)
}.collectLatest {
}.collect {
adapter.setItems(it, adapter.diffItemCallback)
delay(100)
}
}
}

Loading…
Cancel
Save