pull/341/head
gedoor 4 years ago
parent fdd625cd33
commit 21a792f209
  1. 5
      app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
  2. 5
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceActivity.kt
  3. 5
      app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleActivity.kt
  4. 5
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceActivity.kt
  5. 5
      app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt
  6. 5
      app/src/main/java/io/legado/app/ui/book/arrange/ArrangeBookActivity.kt
  7. 5
      app/src/main/java/io/legado/app/ui/book/changecover/ChangeCoverDialog.kt
  8. 5
      app/src/main/java/io/legado/app/ui/book/changesource/ChangeSourceDialog.kt
  9. 5
      app/src/main/java/io/legado/app/ui/book/chapterlist/BookmarkFragment.kt
  10. 5
      app/src/main/java/io/legado/app/ui/book/chapterlist/ChapterListFragment.kt
  11. 5
      app/src/main/java/io/legado/app/ui/book/download/DownloadActivity.kt
  12. 3
      app/src/main/java/io/legado/app/ui/book/explore/ExploreShowActivity.kt
  13. 3
      app/src/main/java/io/legado/app/ui/book/group/GroupManageDialog.kt
  14. 3
      app/src/main/java/io/legado/app/ui/book/group/GroupSelectDialog.kt
  15. 5
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  16. 3
      app/src/main/java/io/legado/app/ui/book/info/edit/BookInfoEditActivity.kt
  17. 3
      app/src/main/java/io/legado/app/ui/book/local/ImportBookActivity.kt
  18. 3
      app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt
  19. 11
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.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. 3
      app/src/main/java/io/legado/app/ui/main/bookshelf/books/BooksFragment.kt
  23. 3
      app/src/main/java/io/legado/app/ui/main/rss/RssFragment.kt
  24. 3
      app/src/main/java/io/legado/app/ui/replacerule/GroupManageDialog.kt
  25. 5
      app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt
  26. 3
      app/src/main/java/io/legado/app/ui/replacerule/edit/ReplaceEditDialog.kt
  27. 5
      app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt
  28. 5
      app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt
  29. 3
      app/src/main/java/io/legado/app/ui/rss/favorites/RssFavoritesActivity.kt
  30. 5
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  31. 3
      app/src/main/java/io/legado/app/ui/rss/source/manage/GroupManageDialog.kt
  32. 5
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt

@ -2,7 +2,6 @@ package io.legado.app.ui.association
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import androidx.lifecycle.Observer
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.Theme import io.legado.app.constant.Theme
@ -23,12 +22,12 @@ class FileAssociationActivity : VMBaseActivity<FileAssociationViewModel>(
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
rotate_loading.show() rotate_loading.show()
viewModel.errorLiveData.observe(this, Observer { viewModel.errorLiveData.observe(this, {
rotate_loading.hide() rotate_loading.hide()
toast(it) toast(it)
finish() finish()
}) })
viewModel.successLiveData.observe(this, Observer { viewModel.successLiveData.observe(this, {
rotate_loading.hide() rotate_loading.hide()
startActivity(it) startActivity(it)
finish() finish()

@ -9,7 +9,6 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseDialogFragment
@ -41,11 +40,11 @@ class ImportBookSourceActivity : VMBaseActivity<ImportBookSourceViewModel>(
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
rotate_loading.show() rotate_loading.show()
viewModel.errorLiveData.observe(this, Observer { viewModel.errorLiveData.observe(this, {
rotate_loading.hide() rotate_loading.hide()
errorDialog(it) errorDialog(it)
}) })
viewModel.successLiveData.observe(this, Observer { viewModel.successLiveData.observe(this, {
rotate_loading.hide() rotate_loading.hide()
if (it > 0) { if (it > 0) {
successDialog() successDialog()

@ -1,7 +1,6 @@
package io.legado.app.ui.association package io.legado.app.ui.association
import android.os.Bundle import android.os.Bundle
import androidx.lifecycle.Observer
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
@ -26,11 +25,11 @@ class ImportReplaceRuleActivity : VMBaseActivity<ImportReplaceRuleViewModel>(
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
rotate_loading.show() rotate_loading.show()
viewModel.errorLiveData.observe(this, Observer { viewModel.errorLiveData.observe(this, {
rotate_loading.hide() rotate_loading.hide()
errorDialog(it) errorDialog(it)
}) })
viewModel.successLiveData.observe(this, Observer { viewModel.successLiveData.observe(this, {
rotate_loading.hide() rotate_loading.hide()
if (it.size > 0) { if (it.size > 0) {
successDialog(it) successDialog(it)

@ -9,7 +9,6 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseDialogFragment
@ -41,11 +40,11 @@ class ImportRssSourceActivity : VMBaseActivity<ImportRssSourceViewModel>(
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
rotate_loading.show() rotate_loading.show()
viewModel.errorLiveData.observe(this, Observer { viewModel.errorLiveData.observe(this, {
rotate_loading.hide() rotate_loading.hide()
errorDialog(it) errorDialog(it)
}) })
viewModel.successLiveData.observe(this, Observer { viewModel.successLiveData.observe(this, {
rotate_loading.hide() rotate_loading.hide()
if (it > 0) { if (it > 0) {
successDialog() successDialog()

@ -8,7 +8,6 @@ import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.widget.SeekBar import android.widget.SeekBar
import androidx.lifecycle.Observer
import com.bumptech.glide.RequestBuilder import com.bumptech.glide.RequestBuilder
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestOptions.bitmapTransform import com.bumptech.glide.request.RequestOptions.bitmapTransform
@ -48,8 +47,8 @@ class AudioPlayActivity :
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
title_bar.transparent() title_bar.transparent()
AudioPlay.titleData.observe(this, Observer { title_bar.title = it }) AudioPlay.titleData.observe(this, { title_bar.title = it })
AudioPlay.coverData.observe(this, Observer { upCover(it) }) AudioPlay.coverData.observe(this, { upCover(it) })
viewModel.initData(intent) viewModel.initData(intent)
initView() initView()
} }

@ -5,7 +5,6 @@ import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.App import io.legado.app.App
@ -94,7 +93,7 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi
private fun initGroupData() { private fun initGroupData() {
groupLiveData?.removeObservers(this) groupLiveData?.removeObservers(this)
groupLiveData = App.db.bookGroupDao().liveDataAll() groupLiveData = App.db.bookGroupDao().liveDataAll()
groupLiveData?.observe(this, Observer { groupLiveData?.observe(this, {
groupList.clear() groupList.clear()
groupList.addAll(it) groupList.addAll(it)
adapter.notifyDataSetChanged() adapter.notifyDataSetChanged()
@ -112,7 +111,7 @@ class ArrangeBookActivity : VMBaseActivity<ArrangeBookViewModel>(R.layout.activi
AppConst.bookGroupNone.groupId -> App.db.bookDao().observeNoGroup() AppConst.bookGroupNone.groupId -> App.db.bookDao().observeNoGroup()
else -> App.db.bookDao().observeByGroup(groupId) else -> App.db.bookDao().observeByGroup(groupId)
} }
booksLiveData?.observe(this, Observer { list -> booksLiveData?.observe(this, { list ->
val books = when (getPrefInt(PreferKey.bookshelfSort)) { val books = when (getPrefInt(PreferKey.bookshelfSort)) {
1 -> list.sortedByDescending { it.latestChapterTime } 1 -> list.sortedByDescending { it.latestChapterTime }
2 -> list.sortedBy { it.name } 2 -> list.sortedBy { it.name }

@ -8,7 +8,6 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import io.legado.app.R import io.legado.app.R
@ -83,7 +82,7 @@ class ChangeCoverDialog : BaseDialogFragment(),
override fun observeLiveBus() { override fun observeLiveBus() {
super.observeLiveBus() super.observeLiveBus()
viewModel.searchStateData.observe(viewLifecycleOwner, Observer { viewModel.searchStateData.observe(viewLifecycleOwner, {
refresh_progress_bar.isAutoLoading = it refresh_progress_bar.isAutoLoading = it
if (it) { if (it) {
stopMenuItem?.setIcon(R.drawable.ic_stop_black_24dp) stopMenuItem?.setIcon(R.drawable.ic_stop_black_24dp)
@ -92,7 +91,7 @@ class ChangeCoverDialog : BaseDialogFragment(),
} }
tool_bar.menu.applyTint(requireContext(), Theme.getTheme()) tool_bar.menu.applyTint(requireContext(), Theme.getTheme())
}) })
viewModel.searchBooksLiveData.observe(viewLifecycleOwner, Observer { viewModel.searchBooksLiveData.observe(viewLifecycleOwner, {
val diffResult = DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), it)) val diffResult = DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), it))
adapter.setItems(it) adapter.setItems(it)
diffResult.dispatchUpdatesTo(adapter) diffResult.dispatchUpdatesTo(adapter)

@ -9,7 +9,6 @@ import android.view.ViewGroup
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -135,7 +134,7 @@ class ChangeSourceDialog : BaseDialogFragment(),
} }
private fun initLiveData() { private fun initLiveData() {
viewModel.searchStateData.observe(viewLifecycleOwner, Observer { viewModel.searchStateData.observe(viewLifecycleOwner, {
refresh_progress_bar.isAutoLoading = it refresh_progress_bar.isAutoLoading = it
if (it) { if (it) {
stopMenuItem?.setIcon(R.drawable.ic_stop_black_24dp) stopMenuItem?.setIcon(R.drawable.ic_stop_black_24dp)
@ -144,7 +143,7 @@ class ChangeSourceDialog : BaseDialogFragment(),
} }
tool_bar.menu.applyTint(requireContext()) tool_bar.menu.applyTint(requireContext())
}) })
viewModel.searchBooksLiveData.observe(viewLifecycleOwner, Observer { viewModel.searchBooksLiveData.observe(viewLifecycleOwner, {
val diffResult = DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), it)) val diffResult = DiffUtil.calculateDiff(DiffCallBack(adapter.getItems(), it))
adapter.setItems(it) adapter.setItems(it)
diffResult.dispatchUpdatesTo(adapter) diffResult.dispatchUpdatesTo(adapter)

@ -8,7 +8,6 @@ import android.os.Bundle
import android.view.View import android.view.View
import android.widget.EditText import android.widget.EditText
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.paging.LivePagedListBuilder import androidx.paging.LivePagedListBuilder
import androidx.paging.PagedList import androidx.paging.PagedList
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -59,7 +58,7 @@ class BookmarkFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_
LivePagedListBuilder( LivePagedListBuilder(
App.db.bookmarkDao().observeByBook(book.bookUrl, book.name, book.author), 20 App.db.bookmarkDao().observeByBook(book.bookUrl, book.name, book.author), 20
).build() ).build()
bookmarkLiveData?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) }) bookmarkLiveData?.observe(viewLifecycleOwner, { adapter.submitList(it) })
} }
} }
@ -74,7 +73,7 @@ class BookmarkFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_
newText newText
), 20 ), 20
).build() ).build()
bookmarkLiveData?.observe(viewLifecycleOwner, Observer { adapter.submitList(it) }) bookmarkLiveData?.observe(viewLifecycleOwner, { adapter.submitList(it) })
} }
} }

@ -6,7 +6,6 @@ import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseFragment import io.legado.app.base.VMBaseFragment
@ -89,7 +88,7 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme
private fun initDoc() { private fun initDoc() {
tocLiveData?.removeObservers(this@ChapterListFragment) tocLiveData?.removeObservers(this@ChapterListFragment)
tocLiveData = App.db.bookChapterDao().observeByBook(viewModel.bookUrl) tocLiveData = App.db.bookChapterDao().observeByBook(viewModel.bookUrl)
tocLiveData?.observe(viewLifecycleOwner, Observer { tocLiveData?.observe(viewLifecycleOwner, {
adapter.setItems(it) adapter.setItems(it)
if (!scrollToDurChapter) { if (!scrollToDurChapter) {
mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0) mLayoutManager.scrollToPositionWithOffset(durChapterIndex, 0)
@ -124,7 +123,7 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme
} else { } else {
tocLiveData?.removeObservers(this) tocLiveData?.removeObservers(this)
tocLiveData = App.db.bookChapterDao().liveDataSearch(viewModel.bookUrl, newText) tocLiveData = App.db.bookChapterDao().liveDataSearch(viewModel.bookUrl, newText)
tocLiveData?.observe(viewLifecycleOwner, Observer { tocLiveData?.observe(viewLifecycleOwner, {
adapter.setItems(it) adapter.setItems(it)
}) })
} }

@ -6,7 +6,6 @@ import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import io.legado.app.App import io.legado.app.App
@ -129,7 +128,7 @@ class DownloadActivity : VMBaseActivity<DownloadViewModel>(R.layout.activity_dow
AppConst.bookGroupNone.groupId -> App.db.bookDao().observeNoGroup() AppConst.bookGroupNone.groupId -> App.db.bookDao().observeNoGroup()
else -> App.db.bookDao().observeByGroup(groupId) else -> App.db.bookDao().observeByGroup(groupId)
} }
booksLiveData?.observe(this, Observer { list -> booksLiveData?.observe(this, { list ->
val booksDownload = list.filter { val booksDownload = list.filter {
it.isOnLineTxt() it.isOnLineTxt()
} }
@ -147,7 +146,7 @@ class DownloadActivity : VMBaseActivity<DownloadViewModel>(R.layout.activity_dow
private fun initGroupData() { private fun initGroupData() {
groupLiveData?.removeObservers(this) groupLiveData?.removeObservers(this)
groupLiveData = App.db.bookGroupDao().liveDataAll() groupLiveData = App.db.bookGroupDao().liveDataAll()
groupLiveData?.observe(this, Observer { groupLiveData?.observe(this, {
groupList.clear() groupList.clear()
groupList.addAll(it) groupList.addAll(it)
adapter.notifyDataSetChanged() adapter.notifyDataSetChanged()

@ -1,7 +1,6 @@
package io.legado.app.ui.book.explore package io.legado.app.ui.book.explore
import android.os.Bundle import android.os.Bundle
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager 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
@ -27,7 +26,7 @@ class ExploreShowActivity : VMBaseActivity<ExploreShowViewModel>(R.layout.activi
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
title_bar.title = intent.getStringExtra("exploreName") title_bar.title = intent.getStringExtra("exploreName")
initRecyclerView() initRecyclerView()
viewModel.booksData.observe(this, Observer { upData(it) }) viewModel.booksData.observe(this, { upData(it) })
viewModel.initData(intent) viewModel.initData(intent)
} }

@ -10,7 +10,6 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.EditText import android.widget.EditText
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -78,7 +77,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
tv_ok.setTextColor(requireContext().accentColor) tv_ok.setTextColor(requireContext().accentColor)
tv_ok.visible() tv_ok.visible()
tv_ok.onClick { dismiss() } tv_ok.onClick { dismiss() }
App.db.bookGroupDao().liveDataAll().observe(viewLifecycleOwner, Observer { App.db.bookGroupDao().liveDataAll().observe(viewLifecycleOwner, {
val diffResult = val diffResult =
DiffUtil.calculateDiff(GroupDiffCallBack(ArrayList(adapter.getItems()), it)) DiffUtil.calculateDiff(GroupDiffCallBack(ArrayList(adapter.getItems()), it))
adapter.setItems(it, diffResult) adapter.setItems(it, diffResult)

@ -11,7 +11,6 @@ import android.view.ViewGroup
import android.widget.EditText import android.widget.EditText
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -113,7 +112,7 @@ class GroupSelectDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
} }
private fun initData() { private fun initData() {
App.db.bookGroupDao().liveDataAll().observe(viewLifecycleOwner, Observer { App.db.bookGroupDao().liveDataAll().observe(viewLifecycleOwner, {
adapter.setItems(it) adapter.setItems(it)
}) })
} }

@ -9,7 +9,6 @@ import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.widget.CheckBox import android.widget.CheckBox
import android.widget.LinearLayout import android.widget.LinearLayout
import androidx.lifecycle.Observer
import com.bumptech.glide.RequestBuilder import com.bumptech.glide.RequestBuilder
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestOptions.bitmapTransform import com.bumptech.glide.request.RequestOptions.bitmapTransform
@ -66,8 +65,8 @@ class BookInfoActivity :
scroll_view.setBackgroundColor(backgroundColor) scroll_view.setBackgroundColor(backgroundColor)
fl_action.setBackgroundColor(bottomBackground) fl_action.setBackgroundColor(bottomBackground)
tv_shelf.setTextColor(getPrimaryTextColor(ColorUtils.isColorLight(bottomBackground))) tv_shelf.setTextColor(getPrimaryTextColor(ColorUtils.isColorLight(bottomBackground)))
viewModel.bookData.observe(this, Observer { showBook(it) }) viewModel.bookData.observe(this, { showBook(it) })
viewModel.chapterListData.observe(this, Observer { upLoading(false, it) }) viewModel.chapterListData.observe(this, { upLoading(false, it) })
viewModel.initData(intent) viewModel.initData(intent)
initOnClick() initOnClick()
} }

@ -7,7 +7,6 @@ import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.Observer
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.data.entities.Book import io.legado.app.data.entities.Book
@ -30,7 +29,7 @@ class BookInfoEditActivity :
get() = getViewModel(BookInfoEditViewModel::class.java) get() = getViewModel(BookInfoEditViewModel::class.java)
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
viewModel.bookData.observe(this, Observer { upView(it) }) viewModel.bookData.observe(this, { upView(it) })
if (viewModel.bookData.value == null) { if (viewModel.bookData.value == null) {
intent.getStringExtra("bookUrl")?.let { intent.getStringExtra("bookUrl")?.let {
viewModel.loadBook(it) viewModel.loadBook(it)

@ -12,7 +12,6 @@ import android.view.View
import androidx.appcompat.widget.PopupMenu import androidx.appcompat.widget.PopupMenu
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
@ -114,7 +113,7 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity
private fun initData() { private fun initData() {
localUriLiveData?.removeObservers(this) localUriLiveData?.removeObservers(this)
localUriLiveData = App.db.bookDao().observeLocalUri() localUriLiveData = App.db.bookDao().observeLocalUri()
localUriLiveData?.observe(this, Observer { localUriLiveData?.observe(this, {
adapter.upBookHas(it) adapter.upBookHas(it)
}) })
} }

@ -11,7 +11,6 @@ import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -104,7 +103,7 @@ class TocRegexDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
private fun initData() { private fun initData() {
tocRegexLiveData?.removeObservers(viewLifecycleOwner) tocRegexLiveData?.removeObservers(viewLifecycleOwner)
tocRegexLiveData = App.db.txtTocRule().observeAll() tocRegexLiveData = App.db.txtTocRule().observeAll()
tocRegexLiveData?.observe(viewLifecycleOwner, Observer { tocRules -> tocRegexLiveData?.observe(viewLifecycleOwner, { tocRules ->
initSelectedName(tocRules) initSelectedName(tocRules)
adapter.setItems(tocRules) adapter.setItems(tocRules)
}) })

@ -7,7 +7,6 @@ import android.view.View.GONE
import android.view.View.VISIBLE import android.view.View.VISIBLE
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.google.android.flexbox.FlexboxLayoutManager import com.google.android.flexbox.FlexboxLayoutManager
@ -176,17 +175,17 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
} }
private fun initLiveData() { private fun initLiveData() {
App.db.bookSourceDao().liveGroupEnabled().observe(this, Observer { App.db.bookSourceDao().liveGroupEnabled().observe(this, {
groups.clear() groups.clear()
it.map { group -> it.map { group ->
groups.addAll(group.splitNotBlank(",", ";")) groups.addAll(group.splitNotBlank(",", ";"))
} }
upGroupMenu() upGroupMenu()
}) })
viewModel.searchBookLiveData.observe(this, Observer { viewModel.searchBookLiveData.observe(this, {
upSearchItems(it) upSearchItems(it)
}) })
viewModel.isSearchLiveData.observe(this, Observer { viewModel.isSearchLiveData.observe(this, {
if (it) { if (it) {
startSearch() startSearch()
} else { } else {
@ -254,7 +253,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
rv_bookshelf_search.gone() rv_bookshelf_search.gone()
} else { } else {
bookData = App.db.bookDao().liveDataSearch(key) bookData = App.db.bookDao().liveDataSearch(key)
bookData?.observe(this, Observer { bookData?.observe(this, {
if (it.isEmpty()) { if (it.isEmpty()) {
tv_book_show.gone() tv_book_show.gone()
rv_bookshelf_search.gone() rv_bookshelf_search.gone()
@ -272,7 +271,7 @@ class SearchActivity : VMBaseActivity<SearchViewModel>(R.layout.activity_book_se
} else { } else {
App.db.searchKeywordDao().liveDataSearch(key) App.db.searchKeywordDao().liveDataSearch(key)
} }
historyData?.observe(this, Observer { historyData?.observe(this, {
historyKeyAdapter.setItems(it) historyKeyAdapter.setItems(it)
if (it.isEmpty()) { if (it.isEmpty()) {
tv_clear_history.invisible() tv_clear_history.invisible()

@ -11,7 +11,6 @@ import androidx.appcompat.widget.PopupMenu
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -164,7 +163,7 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
App.db.bookSourceDao().liveDataSearch("%$searchKey%") App.db.bookSourceDao().liveDataSearch("%$searchKey%")
} }
} }
bookSourceLiveDate?.observe(this, Observer { data -> bookSourceLiveDate?.observe(this, { data ->
val sourceList = when (sort) { val sourceList = when (sort) {
1 -> data.sortedBy { it.weight } 1 -> data.sortedBy { it.weight }
2 -> data.sortedBy { it.bookSourceName } 2 -> data.sortedBy { it.bookSourceName }
@ -179,7 +178,7 @@ class BookSourceActivity : VMBaseActivity<BookSourceViewModel>(R.layout.activity
} }
private fun initLiveDataGroup() { private fun initLiveDataGroup() {
App.db.bookSourceDao().liveGroup().observe(this, Observer { App.db.bookSourceDao().liveGroup().observe(this, {
groups.clear() groups.clear()
it.map { group -> it.map { group ->
groups.addAll(group.splitNotBlank(",", ";")) groups.addAll(group.splitNotBlank(",", ";"))

@ -11,7 +11,6 @@ import android.view.ViewGroup
import android.widget.EditText import android.widget.EditText
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
@ -69,7 +68,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
} }
private fun initData() { private fun initData() {
App.db.bookSourceDao().liveGroup().observe(viewLifecycleOwner, Observer { App.db.bookSourceDao().liveGroup().observe(viewLifecycleOwner, {
val groups = linkedSetOf<String>() val groups = linkedSetOf<String>()
it.map { group -> it.map { group ->
groups.addAll(group.splitNotBlank(",", ";")) groups.addAll(group.splitNotBlank(",", ";"))

@ -3,7 +3,6 @@ package io.legado.app.ui.main.bookshelf.books
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -106,7 +105,7 @@ class BooksFragment : BaseFragment(R.layout.fragment_books),
AppConst.bookGroupNone.groupId -> App.db.bookDao().observeNoGroup() AppConst.bookGroupNone.groupId -> App.db.bookDao().observeNoGroup()
else -> App.db.bookDao().observeByGroup(groupId) else -> App.db.bookDao().observeByGroup(groupId)
} }
bookshelfLiveData?.observe(this, Observer { list -> bookshelfLiveData?.observe(this, { list ->
val books = when (getPrefInt(PreferKey.bookshelfSort)) { val books = when (getPrefInt(PreferKey.bookshelfSort)) {
1 -> list.sortedByDescending { it.latestChapterTime } 1 -> list.sortedByDescending { it.latestChapterTime }
2 -> list.sortedBy { it.name } 2 -> list.sortedBy { it.name }

@ -4,7 +4,6 @@ import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
@ -56,7 +55,7 @@ class RssFragment : VMBaseFragment<RssSourceViewModel>(R.layout.fragment_rss),
} }
private fun initData() { private fun initData() {
App.db.rssSourceDao().liveEnabled().observe(viewLifecycleOwner, Observer { App.db.rssSourceDao().liveEnabled().observe(viewLifecycleOwner, {
if (it.isEmpty()) { if (it.isEmpty()) {
getViewModelOfActivity(MainViewModel::class.java).initRss() getViewModelOfActivity(MainViewModel::class.java).initRss()
} }

@ -11,7 +11,6 @@ import android.view.ViewGroup
import android.widget.EditText import android.widget.EditText
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
@ -69,7 +68,7 @@ class GroupManageDialog : DialogFragment(), Toolbar.OnMenuItemClickListener {
recycler_view.layoutManager = LinearLayoutManager(requireContext()) recycler_view.layoutManager = LinearLayoutManager(requireContext())
recycler_view.addItemDecoration(VerticalDivider(requireContext())) recycler_view.addItemDecoration(VerticalDivider(requireContext()))
recycler_view.adapter = adapter recycler_view.adapter = adapter
App.db.replaceRuleDao().liveGroup().observe(viewLifecycleOwner, Observer { App.db.replaceRuleDao().liveGroup().observe(viewLifecycleOwner, {
val groups = linkedSetOf<String>() val groups = linkedSetOf<String>()
it.map { group -> it.map { group ->
groups.addAll(group.splitNotBlank(",", ";")) groups.addAll(group.splitNotBlank(",", ";"))

@ -11,7 +11,6 @@ import androidx.appcompat.widget.PopupMenu
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -133,7 +132,7 @@ class ReplaceRuleActivity : VMBaseActivity<ReplaceRuleViewModel>(R.layout.activi
} else { } else {
App.db.replaceRuleDao().liveDataSearch(key) App.db.replaceRuleDao().liveDataSearch(key)
} }
replaceRuleLiveData?.observe(this, Observer { replaceRuleLiveData?.observe(this, {
if (dataInit) { if (dataInit) {
setResult(Activity.RESULT_OK) setResult(Activity.RESULT_OK)
} }
@ -146,7 +145,7 @@ class ReplaceRuleActivity : VMBaseActivity<ReplaceRuleViewModel>(R.layout.activi
} }
private fun observeGroupData() { private fun observeGroupData() {
App.db.replaceRuleDao().liveGroup().observe(this, Observer { App.db.replaceRuleDao().liveGroup().observe(this, {
groups.clear() groups.clear()
it.map { group -> it.map { group ->
groups.addAll(group.splitNotBlank(",", ";")) groups.addAll(group.splitNotBlank(",", ";"))

@ -11,7 +11,6 @@ import android.widget.EditText
import android.widget.PopupWindow import android.widget.PopupWindow
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Observer
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.AppConst import io.legado.app.constant.AppConst
@ -71,7 +70,7 @@ class ReplaceEditDialog : BaseDialogFragment(),
tool_bar.inflateMenu(R.menu.replace_edit) tool_bar.inflateMenu(R.menu.replace_edit)
tool_bar.menu.applyTint(requireContext()) tool_bar.menu.applyTint(requireContext())
tool_bar.setOnMenuItemClickListener(this) tool_bar.setOnMenuItemClickListener(this)
viewModel.replaceRuleData.observe(viewLifecycleOwner, Observer { viewModel.replaceRuleData.observe(viewLifecycleOwner, {
upReplaceView(it) upReplaceView(it)
}) })
arguments?.let { arguments?.let {

@ -3,7 +3,6 @@ package io.legado.app.ui.rss.article
import android.os.Bundle import android.os.Bundle
import android.view.View import android.view.View
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
@ -87,7 +86,7 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
activityViewModel.url?.let { activityViewModel.url?.let {
rssArticlesData?.removeObservers(this) rssArticlesData?.removeObservers(this)
rssArticlesData = App.db.rssArticleDao().liveByOriginSort(it, viewModel.sortName) rssArticlesData = App.db.rssArticleDao().liveByOriginSort(it, viewModel.sortName)
rssArticlesData?.observe(viewLifecycleOwner, Observer { list -> rssArticlesData?.observe(viewLifecycleOwner, { list ->
adapter.setItems(list) adapter.setItems(list)
}) })
} }
@ -104,7 +103,7 @@ class RssArticlesFragment : VMBaseFragment<RssArticlesViewModel>(R.layout.fragme
} }
override fun observeLiveBus() { override fun observeLiveBus() {
viewModel.loadFinally.observe(viewLifecycleOwner, Observer { viewModel.loadFinally.observe(viewLifecycleOwner, {
refresh_recycler_view.stopLoading() refresh_recycler_view.stopLoading()
if (it) { if (it) {
loadMoreView.startLoad() loadMoreView.startLoad()

@ -8,7 +8,6 @@ import android.view.MenuItem
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.lifecycle.Observer
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.ui.rss.source.edit.RssSourceEditActivity import io.legado.app.ui.rss.source.edit.RssSourceEditActivity
@ -30,7 +29,7 @@ class RssSortActivity : VMBaseActivity<RssSortViewModel>(R.layout.activity_rss_a
adapter = TabFragmentPageAdapter(supportFragmentManager) adapter = TabFragmentPageAdapter(supportFragmentManager)
tab_layout.setupWithViewPager(view_pager) tab_layout.setupWithViewPager(view_pager)
view_pager.adapter = adapter view_pager.adapter = adapter
viewModel.titleLiveData.observe(this, Observer { viewModel.titleLiveData.observe(this, {
title_bar.title = it title_bar.title = it
}) })
viewModel.initData(intent) { viewModel.initData(intent) {
@ -85,7 +84,7 @@ class RssSortActivity : VMBaseActivity<RssSortViewModel>(R.layout.activity_rss_a
} }
} }
private inner class TabFragmentPageAdapter internal constructor(fm: FragmentManager) : private inner class TabFragmentPageAdapter(fm: FragmentManager) :
FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
override fun getItemPosition(`object`: Any): Int { override fun getItemPosition(`object`: Any): Int {

@ -2,7 +2,6 @@ package io.legado.app.ui.rss.favorites
import android.os.Bundle import android.os.Bundle
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
@ -37,7 +36,7 @@ class RssFavoritesActivity : BaseActivity(R.layout.activity_rss_favorites),
private fun initData() { private fun initData() {
liveData?.removeObservers(this) liveData?.removeObservers(this)
liveData = App.db.rssStarDao().liveAll() liveData = App.db.rssStarDao().liveAll()
liveData?.observe(this, Observer { liveData?.observe(this, {
adapter.setItems(it) adapter.setItems(it)
}) })
} }

@ -8,7 +8,6 @@ import android.os.Bundle
import android.view.* import android.view.*
import android.webkit.* import android.webkit.*
import androidx.core.view.size import androidx.core.view.size
import androidx.lifecycle.Observer
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.lib.theme.DrawableUtils import io.legado.app.lib.theme.DrawableUtils
@ -155,7 +154,7 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
@SuppressLint("SetJavaScriptEnabled") @SuppressLint("SetJavaScriptEnabled")
private fun initLiveData() { private fun initLiveData() {
viewModel.contentLiveData.observe(this, Observer { content -> viewModel.contentLiveData.observe(this, { content ->
viewModel.rssArticle?.let { viewModel.rssArticle?.let {
upJavaScriptEnable() upJavaScriptEnable()
val url = NetworkUtils.getAbsoluteURL(it.origin, it.link) val url = NetworkUtils.getAbsoluteURL(it.origin, it.link)
@ -179,7 +178,7 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
} }
} }
}) })
viewModel.urlLiveData.observe(this, Observer { viewModel.urlLiveData.observe(this, {
upJavaScriptEnable() upJavaScriptEnable()
web_view.loadUrl(it.url, it.headerMap) web_view.loadUrl(it.url, it.headerMap)
}) })

@ -10,7 +10,6 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.EditText import android.widget.EditText
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
@ -63,7 +62,7 @@ class GroupManageDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener
tv_ok.setTextColor(requireContext().accentColor) tv_ok.setTextColor(requireContext().accentColor)
tv_ok.visible() tv_ok.visible()
tv_ok.onClick { dismiss() } tv_ok.onClick { dismiss() }
App.db.rssSourceDao().liveGroup().observe(viewLifecycleOwner, Observer { App.db.rssSourceDao().liveGroup().observe(viewLifecycleOwner, {
val groups = linkedSetOf<String>() val groups = linkedSetOf<String>()
it.map { group -> it.map { group ->
groups.addAll(group.splitNotBlank(",", ";")) groups.addAll(group.splitNotBlank(",", ";"))

@ -11,7 +11,6 @@ import androidx.appcompat.widget.PopupMenu
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.documentfile.provider.DocumentFile import androidx.documentfile.provider.DocumentFile
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -142,7 +141,7 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
} }
private fun initLiveDataGroup() { private fun initLiveDataGroup() {
App.db.rssSourceDao().liveGroup().observe(this, Observer { App.db.rssSourceDao().liveGroup().observe(this, {
groups.clear() groups.clear()
it.map { group -> it.map { group ->
groups.addAll(group.splitNotBlank(",", ";")) groups.addAll(group.splitNotBlank(",", ";"))
@ -195,7 +194,7 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
} else { } else {
App.db.rssSourceDao().liveSearch("%$key%") App.db.rssSourceDao().liveSearch("%$key%")
} }
sourceLiveData?.observe(this, Observer { sourceLiveData?.observe(this, {
val diffResult = DiffUtil val diffResult = DiffUtil
.calculateDiff(DiffCallBack(adapter.getItems(), it)) .calculateDiff(DiffCallBack(adapter.getItems(), it))
adapter.setItems(it, diffResult) adapter.setItems(it, diffResult)

Loading…
Cancel
Save