|
|
@ -28,33 +28,24 @@ class RemoteBookActivity : VMBaseActivity<ActivityRemoteBookBinding,RemoteBookVi |
|
|
|
|
|
|
|
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
initView() |
|
|
|
initView() |
|
|
|
// initEvent() |
|
|
|
|
|
|
|
initData() |
|
|
|
initData() |
|
|
|
// toastOnUi("远程书籍") |
|
|
|
|
|
|
|
onFinally() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun initView() { |
|
|
|
private fun initView() { |
|
|
|
binding.recyclerView.layoutManager = LinearLayoutManager(this) |
|
|
|
binding.recyclerView.layoutManager = LinearLayoutManager(this) |
|
|
|
binding.recyclerView.adapter = adapter |
|
|
|
binding.recyclerView.adapter = adapter |
|
|
|
} |
|
|
|
} |
|
|
|
private fun initData() { |
|
|
|
private fun initData() { |
|
|
|
binding.refreshProgressBar.isAutoLoading = true |
|
|
|
binding.refreshProgressBar.isAutoLoading = true |
|
|
|
viewModel.loadRemoteBookList() |
|
|
|
|
|
|
|
launch { |
|
|
|
launch { |
|
|
|
viewModel.dataFlow.conflate().collect { remoteBooks -> |
|
|
|
viewModel.dataFlow.conflate().collect { remoteBooks -> |
|
|
|
adapter.setItems(remoteBooks) |
|
|
|
adapter.setItems(remoteBooks) |
|
|
|
} |
|
|
|
} |
|
|
|
binding.refreshProgressBar.isAutoLoading = false |
|
|
|
binding.refreshProgressBar.isAutoLoading = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
viewModel.loadRemoteBookList() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun onFinally() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@SuppressLint("NotifyDataSetChanged") |
|
|
|
@SuppressLint("NotifyDataSetChanged") |
|
|
|
override fun addToBookshelf(remoteBook: RemoteBook) { |
|
|
|
override fun addToBookshelf(remoteBook: RemoteBook) { |
|
|
|
viewModel.addToBookshelf(remoteBook){ |
|
|
|
viewModel.addToBookshelf(remoteBook){ |
|
|
|