File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
adapterDSL/src/main/java/com/glimmer/dsl/adapter/ext Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -48,15 +48,21 @@ class AdapterSetup internal constructor(private val recyclerView: RecyclerView)
4848}
4949
5050fun RecyclerView.submitDataSource (items : List <Any >, append : Boolean = false) {
51- val list: List <Any > = if (append) {
51+ val listAdapter = adapter as ? CommonListAdapterDsl
52+ if (append) {
5253 val list: ArrayList <Any > = arrayListOf ()
53- (adapter as ? CommonListAdapterDsl ) ?.currentList?.apply {
54+ listAdapter ?.currentList?.apply {
5455 list.addAll(this )
5556 }
5657 list.addAll(items)
57- list
58+ listAdapter?.submitList( list)
5859 } else {
59- arrayListOf<Any >().apply { addAll(items) }
60+ if (listAdapter?.currentList.isNullOrEmpty()) {
61+ listAdapter?.notifyDataSetChanged()
62+ } else {
63+ val list = arrayListOf<Any >().apply { addAll(items) }
64+ listAdapter?.submitList(list)
65+ }
6066 }
61- (adapter as ? CommonListAdapterDsl )?.submitList(list)
67+
6268}
You can’t perform that action at this time.
0 commit comments