We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
class Model( override var itemPosition: Int = 0, var text: String = "测试" ) : ItemPosition class RefreshFragment : EngineFragment<FragmentRefreshBinding>(R.layout.fragment_refresh) { private val total = 2 override fun initView() { setHasOptionsMenu(true) binding.rv.linear().setup { addType<Model>(R.layout.item_multi_type_simple) onBind { val binding = getBinding<ItemMultiTypeSimpleBinding>() binding.item.setOnClickListener { Log.d("RefreshFragment","Click") this.getModel<Model>().text = "哈哈哈" bindingAdapter?.notifyItemChanged(modelPosition) } } } binding.page.onRefresh { Log.d("RefreshFragment","onRefresh") val runnable = { // 模拟网络请求, 创建假的数据集 //上方item每次点击,都会触发onRefresh //在通过scope作用域里面设置binding.rv.models = getData()也会造成这样问题 val data = getData() addData(data) // //加上index < 1控制 上方item每次点击,则触发onRefresh // val data = getData() // addData(data) { // index < 1 // } } postDelayed(runnable, 1000) }.autoRefresh() } private fun getData(): List<Any> { return mutableListOf<Any>().apply { for (i in 0..2) { add(Model()) } } } override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { inflater.inflate(R.menu.menu_refresh, menu) } override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.menu_loading -> binding.page.showLoading() // 加载中 R.id.menu_pull_refresh -> binding.page.autoRefresh() // 下拉刷新 R.id.menu_refresh -> binding.page.refresh() // 静默刷新 R.id.menu_content -> binding.page.showContent() // 加载成功 R.id.menu_error -> binding.page.showError(force = true) // 强制加载错误 R.id.menu_empty -> binding.page.showEmpty() // 空数据 R.id.menu_refresh_success -> binding.page.finish() // 刷新成功 R.id.menu_refresh_fail -> binding.page.finish(false) // 刷新失败 R.id.menu_no_load_more -> binding.page.finishLoadMoreWithNoMoreData() // 没有更多数据 } return super.onOptionsItemSelected(item) } override fun initData() { } }
The text was updated successfully, but these errors were encountered:
Duplicate of #250
Sorry, something went wrong.
notifyItemChanged回调onBindViewHolder导致的触发预加载导致的问题
onBindViewHolder
8872750
No branches or pull requests
The text was updated successfully, but these errors were encountered: