From 128a1b6a0ba7596739ec4700987aa11aa952cc9a Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 6 Sep 2019 21:32:57 +0800 Subject: [PATCH] up --- .../legado/app/ui/changesource/ChangeSourceDialog.kt | 10 ++++++++-- .../app/ui/changesource/ChangeSourceViewModel.kt | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt index b4ff6b8ba..dcb1398cd 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt @@ -37,7 +37,11 @@ class ChangeSourceDialog : DialogFragment(), private lateinit var viewModel: ChangeSourceViewModel private lateinit var changeSourceAdapter: ChangeSourceAdapter - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { viewModel = getViewModel(ChangeSourceViewModel::class.java) return inflater.inflate(R.layout.dialog_change_source, container) } @@ -75,7 +79,9 @@ class ChangeSourceDialog : DialogFragment(), private fun initRecyclerView() { changeSourceAdapter = ChangeSourceAdapter(requireContext(), this) recycler_view.layoutManager = LinearLayoutManager(context) - recycler_view.addItemDecoration(DividerItemDecoration(requireContext(), LinearLayout.VERTICAL)) + recycler_view.addItemDecoration( + DividerItemDecoration(requireContext(), LinearLayout.VERTICAL) + ) recycler_view.adapter = changeSourceAdapter viewModel.callBack = this } diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt index df0caee90..533813a73 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt @@ -35,7 +35,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio callBack?.adapter()?.let { val books = searchBooks.toList() books.sorted() - val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), searchBooks.toList())) + val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), books)) withContext(Main) { synchronized(this) { it.setItemsNoNotify(books)