This commit is contained in:
Madhur Gupta 2019-02-27 01:58:15 +05:30 committed by Vivek Maskara
parent 5dffea4242
commit ef6fd9f292
3 changed files with 34 additions and 31 deletions

View file

@ -378,8 +378,8 @@ public class NearbyMapFragment extends DaggerFragment {
directionsButtonText = ((NearbyFragment)getParentFragment()).view.findViewById(R.id.directionsButtonText);
commonsButtonText = ((NearbyFragment)getParentFragment()).view.findViewById(R.id.commonsButtonText);
bookmarkButton = getActivity().findViewById(R.id.bookmarkButton);
bookmarkButtonImage = getActivity().findViewById(R.id.bookmarkButtonImage);
bookmarkButton = ((NearbyFragment)getParentFragment()).view.findViewById(R.id.bookmarkButton);
bookmarkButtonImage = ((NearbyFragment)getParentFragment()).view.findViewById(R.id.bookmarkButtonImage);
searchThisAreaButton = ((NearbyFragment)getParentFragment()).view.findViewById(R.id.search_this_area_button);
searchThisAreaButtonProgressBar = ((NearbyFragment)getParentFragment()).view.findViewById(R.id.search_this_area_button_progress_bar);
@ -825,32 +825,25 @@ public class NearbyMapFragment extends DaggerFragment {
}
/**
* Same botom sheet carries information for all nearby places, so we need to pass information
* Same bottom sheet carries information for all nearby places, so we need to pass information
* (title, description, distance and links) to view on nearby marker click
* @param place Place of clicked nearby marker
*/
private void passInfoToSheet(Place place) {
this.place = place;
updateBookmarkButtonImage(this.place);
int bookmarkIcon;
if (bookmarkLocationDao.findBookmarkLocation(place)) {
bookmarkIcon = R.drawable.ic_round_star_filled_24px;
} else {
bookmarkIcon = R.drawable.ic_round_star_border_24px;
}
bookmarkButtonImage.setImageResource(bookmarkIcon);
bookmarkButton.setOnClickListener(view -> {
boolean isBookmarked = bookmarkLocationDao.updateBookmarkLocation(place);
int updatedIcon = isBookmarked ? R.drawable.ic_round_star_filled_24px : R.drawable.ic_round_star_border_24px;
bookmarkButtonImage.setImageResource(updatedIcon);
updateMarker(isBookmarked, place);
boolean isBookmarked = bookmarkLocationDao.updateBookmarkLocation(this.place);
updateBookmarkButtonImage(this.place);
updateMarker(isBookmarked, this.place);
});
wikipediaButton.setEnabled(place.hasWikipediaLink());
wikipediaButton.setOnClickListener(view -> openWebView(place.siteLinks.getWikipediaLink()));
wikipediaButton.setOnClickListener(view -> openWebView(this.place.siteLinks.getWikipediaLink()));
wikidataButton.setEnabled(place.hasWikidataLink());
wikidataButton.setOnClickListener(view -> openWebView(place.siteLinks.getWikidataLink()));
wikidataButton.setOnClickListener(view -> openWebView(this.place.siteLinks.getWikidataLink()));
directionsButton.setOnClickListener(view -> {
//Open map app at given position
@ -860,20 +853,18 @@ public class NearbyMapFragment extends DaggerFragment {
}
});
commonsButton.setEnabled(place.hasCommonsLink());
commonsButton.setOnClickListener(view -> openWebView(place.siteLinks.getCommonsLink()));
commonsButton.setEnabled(this.place.hasCommonsLink());
commonsButton.setOnClickListener(view -> openWebView(this.place.siteLinks.getCommonsLink()));
icon.setImageResource(place.getLabel().getIcon());
icon.setImageResource(this.place.getLabel().getIcon());
title.setText(place.name);
distance.setText(place.distance);
description.setText(place.getLongDescription());
title.setText(place.name.toString());
distance.setText(place.distance.toString());
title.setText(this.place.name);
distance.setText(this.place.distance);
description.setText(this.place.getLongDescription());
fabCamera.setOnClickListener(view -> {
if (fabCamera.isShown()) {
Timber.d("Camera button tapped. Place: %s", place.toString());
Timber.d("Camera button tapped. Place: %s", this.place.toString());
storeSharedPrefs();
controller.initiateCameraPick(getActivity());
}
@ -881,13 +872,25 @@ public class NearbyMapFragment extends DaggerFragment {
fabGallery.setOnClickListener(view -> {
if (fabGallery.isShown()) {
Timber.d("Gallery button tapped. Place: %s", place.toString());
Timber.d("Gallery button tapped. Place: %s", this.place.toString());
storeSharedPrefs();
controller.initiateGalleryPick(getActivity(), false);
}
});
}
public void updateBookmarkButtonImage(Place place) {
int bookmarkIcon;
if (bookmarkLocationDao.findBookmarkLocation(place)) {
bookmarkIcon = R.drawable.ic_round_star_filled_24px;
} else {
bookmarkIcon = R.drawable.ic_round_star_border_24px;
}
if (bookmarkButtonImage != null) {
bookmarkButtonImage.setImageResource(bookmarkIcon);
}
}
void storeSharedPrefs() {
Timber.d("Store place object %s", place.toString());
directKvStore.putJson(PLACE_OBJECT, place);
@ -1033,7 +1036,7 @@ public class NearbyMapFragment extends DaggerFragment {
getContext().getResources(), R.drawable.ic_custom_map_marker, getContext().getTheme()
);
}
for(Marker marker: mapboxMap.getMarkers()){
for(Marker marker: mapboxMap.getMarkers()){
if(marker.getTitle()!=null && marker.getTitle().equals(place.getName())){
Bitmap icon = UiUtils.getBitmap(vectorDrawable);

View file

@ -55,9 +55,9 @@ public class PlaceRenderer extends Renderer<Place> {
@BindView(R.id.iconOverflow) LinearLayout iconOverflow;
@BindView(R.id.cameraButtonText) TextView cameraButtonText;
@BindView(R.id.galleryButtonText) TextView galleryButtonText;
@BindView(R.id.bookmarkButton) LinearLayout bookmarkButton;
@BindView(R.id.bookmarkRowButton) LinearLayout bookmarkButton;
@BindView(R.id.bookmarkButtonText) TextView bookmarkButtonText;
@BindView(R.id.bookmarkButtonImage) ImageView bookmarkButtonImage;
@BindView(R.id.bookmarkRowButtonImage) ImageView bookmarkButtonImage;
@BindView(R.id.directionsButtonText) TextView directionsButtonText;
@BindView(R.id.iconOverflowText) TextView iconOverflowText;

View file

@ -11,7 +11,7 @@
>
<LinearLayout
android:id="@+id/bookmarkButton"
android:id="@+id/bookmarkRowButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -21,7 +21,7 @@
android:background="@drawable/button_background_selector"
>
<ImageView
android:id="@+id/bookmarkButtonImage"
android:id="@+id/bookmarkRowButtonImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"