Skip to content

Commit c9be0b3

Browse files
committed
update
1 parent c609b3f commit c9be0b3

File tree

1 file changed

+11
-5
lines changed
  • adapterDSL/src/main/java/com/glimmer/dsl/adapter/ext

1 file changed

+11
-5
lines changed

adapterDSL/src/main/java/com/glimmer/dsl/adapter/ext/AdapterExt.kt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,21 @@ class AdapterSetup internal constructor(private val recyclerView: RecyclerView)
4848
}
4949

5050
fun 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
}

0 commit comments

Comments
 (0)