Add bookmark from list fragment

This commit is contained in:
neslihanturan 2019-09-17 11:58:49 +03:00
parent 9f8becc581
commit 4304e3d018
3 changed files with 12 additions and 7 deletions

View file

@ -33,9 +33,11 @@ import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
import fr.free.nrw.commons.contributions.ContributionController; import fr.free.nrw.commons.contributions.ContributionController;
import fr.free.nrw.commons.di.ApplicationlessInjection; import fr.free.nrw.commons.di.ApplicationlessInjection;
import fr.free.nrw.commons.kvstore.JsonKvStore; import fr.free.nrw.commons.kvstore.JsonKvStore;
import fr.free.nrw.commons.nearby.mvp.fragments.NearbyMapFragment;
import fr.free.nrw.commons.nearby.mvp.fragments.NearbyParentFragment; import fr.free.nrw.commons.nearby.mvp.fragments.NearbyParentFragment;
import timber.log.Timber; import timber.log.Timber;
import static fr.free.nrw.commons.nearby.mvp.fragments.NearbyParentFragment.TAG_RETAINED_MAP_FRAGMENT;
import static fr.free.nrw.commons.theme.NavigationBaseActivity.startActivityWithFlags; import static fr.free.nrw.commons.theme.NavigationBaseActivity.startActivityWithFlags;
import static fr.free.nrw.commons.wikidata.WikidataConstants.PLACE_OBJECT; import static fr.free.nrw.commons.wikidata.WikidataConstants.PLACE_OBJECT;
@ -191,8 +193,9 @@ public class PlaceRenderer extends Renderer<Place> {
onBookmarkClick.onClick(); onBookmarkClick.onClick();
} }
else { else {
// TODO nesli ((NearbyMapFragment)(fragment.getParentFragment()).getChildFragmentManager().
//((NearbyMapFragment)((NearbyFragment)((NearbyListFragment)fragment).getParentFragment()).getChildFragmentManager().findFragmentByTag(NearbyMapFragment.class.getSimpleName())).updateMarker(isBookmarked, place); findFragmentByTag(TAG_RETAINED_MAP_FRAGMENT)).
updateMarker(isBookmarked, place, null);
} }
} }
}); });

View file

@ -405,7 +405,7 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment
}); });
} }
public void updateMarker(boolean isBookmarked, Place place, LatLng curLatLng) { public void updateMarker(boolean isBookmarked, Place place, @Nullable LatLng curLatLng) {
VectorDrawableCompat vectorDrawable; VectorDrawableCompat vectorDrawable;
if (isBookmarked) { if (isBookmarked) {
@ -421,8 +421,10 @@ public class NearbyMapFragment extends CommonsDaggerSupportFragment
if (marker.getTitle() != null && marker.getTitle().equals(place.getName())) { if (marker.getTitle() != null && marker.getTitle().equals(place.getName())) {
Bitmap icon = UiUtils.getBitmap(vectorDrawable); Bitmap icon = UiUtils.getBitmap(vectorDrawable);
String distance = formatDistanceBetween(curLatLng, place.location); if (curLatLng != null) {
place.setDistance(distance); String distance = formatDistanceBetween(curLatLng, place.location);
place.setDistance(distance);
}
NearbyBaseMarker nearbyBaseMarker = new NearbyBaseMarker(); NearbyBaseMarker nearbyBaseMarker = new NearbyBaseMarker();
nearbyBaseMarker.title(place.name); nearbyBaseMarker.title(place.name);

View file

@ -206,8 +206,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
NearbyMapFragment nearbyMapFragment; NearbyMapFragment nearbyMapFragment;
private fr.free.nrw.commons.nearby.NearbyListFragment nearbyListFragment; private fr.free.nrw.commons.nearby.NearbyListFragment nearbyListFragment;
private static final String TAG_RETAINED_MAP_FRAGMENT = com.mapbox.mapboxsdk.maps.SupportMapFragment.class.getSimpleName(); public static final String TAG_RETAINED_MAP_FRAGMENT = NearbyMapFragment.class.getSimpleName();
private static final String TAG_RETAINED_LIST_FRAGMENT = NearbyListFragment.class.getSimpleName(); public static final String TAG_RETAINED_LIST_FRAGMENT = NearbyListFragment.class.getSimpleName();
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,