Toggle bookmark icon in BottomSheetAdapter instead of finding the location each time in the bookmark

* Update bookmark button image in `BottomSheetAdapter`
* Add new toggle function to `BottomSheetAdapter`
* Call the toggle function in `NearbyParentFragment`
This commit is contained in:
Saifuddin 2025-01-17 18:26:42 +05:30
parent 442e72dcb1
commit 8a41b3db1b

View file

@ -68,7 +68,21 @@ class BottomSheetAdapter(
item.imageResourceId == R.drawable.ic_round_star_border_24px item.imageResourceId == R.drawable.ic_round_star_border_24px
) { ) {
item.imageResourceId = icon item.imageResourceId = icon
this.notifyItemChanged(index) notifyItemChanged(index)
return
}
}
}
fun toggleBookmarkIcon() {
itemList.forEachIndexed { index, item ->
if(item.imageResourceId == R.drawable.ic_round_star_filled_24px) {
item.imageResourceId = R.drawable.ic_round_star_border_24px
notifyItemChanged(index)
return
} else if(item.imageResourceId == R.drawable.ic_round_star_border_24px){
item.imageResourceId = R.drawable.ic_round_star_filled_24px
notifyItemChanged(index)
return return
} }
} }