pull/32/head
kunfei 5 years ago
parent b71d317eeb
commit 128a1b6a0b
  1. 10
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt
  2. 2
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.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
}

@ -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)

Loading…
Cancel
Save