mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
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:
parent
442e72dcb1
commit
8a41b3db1b
1 changed files with 15 additions and 1 deletions
|
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue