Skip to content

Commit

Permalink
fix: MultiListBottomSheet returns different items than the user selected
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakariaJawas committed Mar 6, 2022
1 parent bbc357e commit 4ae29d5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class MainActivity : AppCompatActivity() {
.setActionButtonTitle("Continue")
.setOnActionCallback {
sheet, selectedItems ->

Toast.makeText(this, "On Action Button Clicked With ${selectedItems.size} items selected", Toast.LENGTH_SHORT).show()
sheet.dismiss()
}
Expand Down
4 changes: 2 additions & 2 deletions listbottomsheet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 31
versionCode 12
versionName "1.3.8"
versionCode 13
versionName "1.3.9"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ class MultiListBottomSheet<T : Any> private constructor(
setOnClickListener {
//return list of the selected items
val selectedItems = (recyclerView?.adapter as MultiListAdapter).selectedItemsList.toList()
Log.d("##items in sheet", "size ${selectedItems.size}")

val resultList = mutableListOf<T>()
repeat(selectedItems.size) {
resultList.add(mList[it])
resultList.add(mList[selectedItems[it].position])
}
callback(this@MultiListBottomSheet, resultList)
}
Expand Down

0 comments on commit 4ae29d5

Please sign in to comment.