mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +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
8295edeb0a
commit
97037858a3
2 changed files with 21 additions and 3 deletions
|
|
@ -68,7 +68,21 @@ class BottomSheetAdapter(
|
|||
item.imageResourceId == R.drawable.ic_round_star_border_24px
|
||||
) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2145,6 +2145,10 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
);
|
||||
}
|
||||
|
||||
private void toggleBookmarkButtonImage() {
|
||||
bottomSheetAdapter.toggleBookmarkIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(final Context context) {
|
||||
super.onAttach(context);
|
||||
|
|
@ -2304,11 +2308,11 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
switch (item.getImageResourceId()) {
|
||||
case R.drawable.ic_round_star_border_24px:
|
||||
presenter.toggleBookmarkedStatus(selectedPlace, scope);
|
||||
updateBookmarkButtonImage(selectedPlace);
|
||||
toggleBookmarkButtonImage();
|
||||
break;
|
||||
case R.drawable.ic_round_star_filled_24px:
|
||||
presenter.toggleBookmarkedStatus(selectedPlace, scope);
|
||||
updateBookmarkButtonImage(selectedPlace);
|
||||
toggleBookmarkButtonImage();
|
||||
break;
|
||||
case R.drawable.ic_directions_black_24dp:
|
||||
Utils.handleGeoCoordinates(this.getContext(), selectedPlace.getLocation());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue