Skip to content

Commit 4304e3d

Browse files
committed
Add bookmark from list fragment
1 parent 9f8becc commit 4304e3d

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/PlaceRenderer.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@
3333
import fr.free.nrw.commons.contributions.ContributionController;
3434
import fr.free.nrw.commons.di.ApplicationlessInjection;
3535
import fr.free.nrw.commons.kvstore.JsonKvStore;
36+
import fr.free.nrw.commons.nearby.mvp.fragments.NearbyMapFragment;
3637
import fr.free.nrw.commons.nearby.mvp.fragments.NearbyParentFragment;
3738
import timber.log.Timber;
3839

40+
import static fr.free.nrw.commons.nearby.mvp.fragments.NearbyParentFragment.TAG_RETAINED_MAP_FRAGMENT;
3941
import static fr.free.nrw.commons.theme.NavigationBaseActivity.startActivityWithFlags;
4042
import static fr.free.nrw.commons.wikidata.WikidataConstants.PLACE_OBJECT;
4143

@@ -191,8 +193,9 @@ protected void hookListeners(View view) {
191193
onBookmarkClick.onClick();
192194
}
193195
else {
194-
// TODO nesli
195-
//((NearbyMapFragment)((NearbyFragment)((NearbyListFragment)fragment).getParentFragment()).getChildFragmentManager().findFragmentByTag(NearbyMapFragment.class.getSimpleName())).updateMarker(isBookmarked, place);
196+
((NearbyMapFragment)(fragment.getParentFragment()).getChildFragmentManager().
197+
findFragmentByTag(TAG_RETAINED_MAP_FRAGMENT)).
198+
updateMarker(isBookmarked, place, null);
196199
}
197200
}
198201
});

app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyMapFragment.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ void setMapMarkerActions(Marker selected, NearbyParentFragmentPresenter nearbyPa
405405
});
406406
}
407407

408-
public void updateMarker(boolean isBookmarked, Place place, LatLng curLatLng) {
408+
public void updateMarker(boolean isBookmarked, Place place, @Nullable LatLng curLatLng) {
409409

410410
VectorDrawableCompat vectorDrawable;
411411
if (isBookmarked) {
@@ -421,8 +421,10 @@ public void updateMarker(boolean isBookmarked, Place place, LatLng curLatLng) {
421421
if (marker.getTitle() != null && marker.getTitle().equals(place.getName())) {
422422

423423
Bitmap icon = UiUtils.getBitmap(vectorDrawable);
424-
String distance = formatDistanceBetween(curLatLng, place.location);
425-
place.setDistance(distance);
424+
if (curLatLng != null) {
425+
String distance = formatDistanceBetween(curLatLng, place.location);
426+
place.setDistance(distance);
427+
}
426428

427429
NearbyBaseMarker nearbyBaseMarker = new NearbyBaseMarker();
428430
nearbyBaseMarker.title(place.name);

app/src/main/java/fr/free/nrw/commons/nearby/mvp/fragments/NearbyParentFragment.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
206206
NearbyMapFragment nearbyMapFragment;
207207

208208
private fr.free.nrw.commons.nearby.NearbyListFragment nearbyListFragment;
209-
private static final String TAG_RETAINED_MAP_FRAGMENT = com.mapbox.mapboxsdk.maps.SupportMapFragment.class.getSimpleName();
210-
private static final String TAG_RETAINED_LIST_FRAGMENT = NearbyListFragment.class.getSimpleName();
209+
public static final String TAG_RETAINED_MAP_FRAGMENT = NearbyMapFragment.class.getSimpleName();
210+
public static final String TAG_RETAINED_LIST_FRAGMENT = NearbyListFragment.class.getSimpleName();
211211

212212
@Override
213213
public View onCreateView(LayoutInflater inflater, ViewGroup container,

0 commit comments

Comments
 (0)