@@ -378,8 +378,8 @@ private void initViews() {
378378 directionsButtonText = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .directionsButtonText );
379379 commonsButtonText = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .commonsButtonText );
380380
381- bookmarkButton = getActivity () .findViewById (R .id .bookmarkButton );
382- bookmarkButtonImage = getActivity () .findViewById (R .id .bookmarkButtonImage );
381+ bookmarkButton = (( NearbyFragment ) getParentFragment ()). view .findViewById (R .id .bookmarkButton );
382+ bookmarkButtonImage = (( NearbyFragment ) getParentFragment ()). view .findViewById (R .id .bookmarkButtonImage );
383383
384384 searchThisAreaButton = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .search_this_area_button );
385385 searchThisAreaButtonProgressBar = ((NearbyFragment )getParentFragment ()).view .findViewById (R .id .search_this_area_button_progress_bar );
@@ -825,32 +825,25 @@ private void addAnchorToSmallFABs(FloatingActionButton floatingActionButton, int
825825 }
826826
827827 /**
828- * Same botom sheet carries information for all nearby places, so we need to pass information
828+ * Same bottom sheet carries information for all nearby places, so we need to pass information
829829 * (title, description, distance and links) to view on nearby marker click
830830 * @param place Place of clicked nearby marker
831831 */
832832 private void passInfoToSheet (Place place ) {
833833 this .place = place ;
834+ updateBookmarkButtonImage (this .place );
834835
835- int bookmarkIcon ;
836- if (bookmarkLocationDao .findBookmarkLocation (place )) {
837- bookmarkIcon = R .drawable .ic_round_star_filled_24px ;
838- } else {
839- bookmarkIcon = R .drawable .ic_round_star_border_24px ;
840- }
841- bookmarkButtonImage .setImageResource (bookmarkIcon );
842836 bookmarkButton .setOnClickListener (view -> {
843- boolean isBookmarked = bookmarkLocationDao .updateBookmarkLocation (place );
844- int updatedIcon = isBookmarked ? R .drawable .ic_round_star_filled_24px : R .drawable .ic_round_star_border_24px ;
845- bookmarkButtonImage .setImageResource (updatedIcon );
846- updateMarker (isBookmarked , place );
837+ boolean isBookmarked = bookmarkLocationDao .updateBookmarkLocation (this .place );
838+ updateBookmarkButtonImage (this .place );
839+ updateMarker (isBookmarked , this .place );
847840 });
848841
849842 wikipediaButton .setEnabled (place .hasWikipediaLink ());
850- wikipediaButton .setOnClickListener (view -> openWebView (place .siteLinks .getWikipediaLink ()));
843+ wikipediaButton .setOnClickListener (view -> openWebView (this . place .siteLinks .getWikipediaLink ()));
851844
852845 wikidataButton .setEnabled (place .hasWikidataLink ());
853- wikidataButton .setOnClickListener (view -> openWebView (place .siteLinks .getWikidataLink ()));
846+ wikidataButton .setOnClickListener (view -> openWebView (this . place .siteLinks .getWikidataLink ()));
854847
855848 directionsButton .setOnClickListener (view -> {
856849 //Open map app at given position
@@ -860,34 +853,44 @@ private void passInfoToSheet(Place place) {
860853 }
861854 });
862855
863- commonsButton .setEnabled (place .hasCommonsLink ());
864- commonsButton .setOnClickListener (view -> openWebView (place .siteLinks .getCommonsLink ()));
856+ commonsButton .setEnabled (this . place .hasCommonsLink ());
857+ commonsButton .setOnClickListener (view -> openWebView (this . place .siteLinks .getCommonsLink ()));
865858
866- icon .setImageResource (place .getLabel ().getIcon ());
859+ icon .setImageResource (this . place .getLabel ().getIcon ());
867860
868- title .setText (place .name );
869- distance .setText (place .distance );
870- description .setText (place .getLongDescription ());
871- title .setText (place .name .toString ());
872- distance .setText (place .distance .toString ());
861+ title .setText (this .place .name );
862+ distance .setText (this .place .distance );
863+ description .setText (this .place .getLongDescription ());
873864
874865 fabCamera .setOnClickListener (view -> {
875866 if (fabCamera .isShown ()) {
876- Timber .d ("Camera button tapped. Place: %s" , place .toString ());
867+ Timber .d ("Camera button tapped. Place: %s" , this . place .toString ());
877868 storeSharedPrefs ();
878869 controller .initiateCameraPick (getActivity ());
879870 }
880871 });
881872
882873 fabGallery .setOnClickListener (view -> {
883874 if (fabGallery .isShown ()) {
884- Timber .d ("Gallery button tapped. Place: %s" , place .toString ());
875+ Timber .d ("Gallery button tapped. Place: %s" , this . place .toString ());
885876 storeSharedPrefs ();
886877 controller .initiateGalleryPick (getActivity (), false );
887878 }
888879 });
889880 }
890881
882+ public void updateBookmarkButtonImage (Place place ) {
883+ int bookmarkIcon ;
884+ if (bookmarkLocationDao .findBookmarkLocation (place )) {
885+ bookmarkIcon = R .drawable .ic_round_star_filled_24px ;
886+ } else {
887+ bookmarkIcon = R .drawable .ic_round_star_border_24px ;
888+ }
889+ if (bookmarkButtonImage != null ) {
890+ bookmarkButtonImage .setImageResource (bookmarkIcon );
891+ }
892+ }
893+
891894 void storeSharedPrefs () {
892895 Timber .d ("Store place object %s" , place .toString ());
893896 directKvStore .putJson (PLACE_OBJECT , place );
@@ -1033,7 +1036,7 @@ public void updateMarker(boolean isBookmarked, Place place) {
10331036 getContext ().getResources (), R .drawable .ic_custom_map_marker , getContext ().getTheme ()
10341037 );
10351038 }
1036- for (Marker marker : mapboxMap .getMarkers ()){
1039+ for (Marker marker : mapboxMap .getMarkers ()){
10371040 if (marker .getTitle ()!=null && marker .getTitle ().equals (place .getName ())){
10381041
10391042 Bitmap icon = UiUtils .getBitmap (vectorDrawable );
0 commit comments