mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Fix modification on bottom sheet's data when coming from Nearby Banner and clicked on other pins (#5937)
* refactor getIconFor method and remove call to highlightNearestPlace() It ensures single responsibility on getIconFor method * refactor and fix icon issue when coming from nearby banner --------- Co-authored-by: Nicolas Raoul <nicolas.raoul@gmail.com>
This commit is contained in:
parent
0c969c365b
commit
794dbb8f92
2 changed files with 26 additions and 19 deletions
|
|
@ -965,6 +965,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
lastPlaceToCenter.location.getLatitude() - cameraShift,
|
||||
lastPlaceToCenter.getLocation().getLongitude(), 0));
|
||||
}
|
||||
highlightNearestPlace(place);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2001,7 +2002,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
*
|
||||
* @param nearestPlace nearest place, which has to be highlighted
|
||||
*/
|
||||
private void highlightNearestPlace(Place nearestPlace) {
|
||||
private void highlightNearestPlace(final Place nearestPlace) {
|
||||
binding.bottomSheetDetails.icon.setVisibility(View.VISIBLE);
|
||||
passInfoToSheet(nearestPlace);
|
||||
hideBottomSheet();
|
||||
bottomSheetDetailsBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
|
||||
|
|
@ -2015,32 +2017,37 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
* @return returns the drawable of marker according to the place information
|
||||
*/
|
||||
private @DrawableRes int getIconFor(Place place, Boolean isBookmarked) {
|
||||
if (nearestPlace != null) {
|
||||
if (place.name.equals(nearestPlace.name)) {
|
||||
// Highlight nearest place only when user clicks on the home nearby banner
|
||||
highlightNearestPlace(place);
|
||||
return (isBookmarked ?
|
||||
R.drawable.ic_custom_map_marker_purple_bookmarked :
|
||||
R.drawable.ic_custom_map_marker_purple);
|
||||
}
|
||||
if (nearestPlace != null && place.name.equals(nearestPlace.name)) {
|
||||
// Highlight nearest place only when user clicks on the home nearby banner
|
||||
// highlightNearestPlace(place);
|
||||
return (isBookmarked ?
|
||||
R.drawable.ic_custom_map_marker_purple_bookmarked :
|
||||
R.drawable.ic_custom_map_marker_purple
|
||||
);
|
||||
}
|
||||
|
||||
if (place.isMonument()) {
|
||||
return R.drawable.ic_custom_map_marker_monuments;
|
||||
} else if (!place.pic.trim().isEmpty()) {
|
||||
}
|
||||
if (!place.pic.trim().isEmpty()) {
|
||||
return (isBookmarked ?
|
||||
R.drawable.ic_custom_map_marker_green_bookmarked :
|
||||
R.drawable.ic_custom_map_marker_green);
|
||||
} else if (!place.exists) { // Means that the topic of the Wikidata item does not exist in the real world anymore, for instance it is a past event, or a place that was destroyed
|
||||
R.drawable.ic_custom_map_marker_green
|
||||
);
|
||||
}
|
||||
if (!place.exists) { // Means that the topic of the Wikidata item does not exist in the real world anymore, for instance it is a past event, or a place that was destroyed
|
||||
return (R.drawable.ic_clear_black_24dp);
|
||||
}else if (place.name == "") {
|
||||
}
|
||||
if (place.name.isEmpty()) {
|
||||
return (isBookmarked ?
|
||||
R.drawable.ic_custom_map_marker_grey_bookmarked :
|
||||
R.drawable.ic_custom_map_marker_grey);
|
||||
} else {
|
||||
return (isBookmarked ?
|
||||
R.drawable.ic_custom_map_marker_red_bookmarked :
|
||||
R.drawable.ic_custom_map_marker_red);
|
||||
R.drawable.ic_custom_map_marker_grey
|
||||
);
|
||||
}
|
||||
return (isBookmarked ?
|
||||
R.drawable.ic_custom_map_marker_red_bookmarked :
|
||||
R.drawable.ic_custom_map_marker_red
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
android:layout_width="@dimen/dimen_40"
|
||||
android:layout_height="@dimen/dimen_40"
|
||||
android:layout_marginLeft="@dimen/standard_gap"
|
||||
android:visibility="gone"></ImageView>
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/wikiDataLl"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue