92
92
import fr .free .nrw .commons .nearby .NearbyFilterState ;
93
93
import fr .free .nrw .commons .nearby .Place ;
94
94
import fr .free .nrw .commons .nearby .PlacesRepository ;
95
+ import fr .free .nrw .commons .nearby .Sitelinks ;
95
96
import fr .free .nrw .commons .nearby .WikidataFeedback ;
96
97
import fr .free .nrw .commons .nearby .contract .NearbyParentFragmentContract ;
97
98
import fr .free .nrw .commons .nearby .fragments .AdvanceQueryFragment .Callback ;
@@ -1173,27 +1174,7 @@ public void populatePlaces(final LatLng currentLatLng,
1173
1174
}
1174
1175
1175
1176
/**
1176
- * Reloads the Nearby map
1177
- * Clears all location markers, refreshes them, reinserts them into the map.
1178
- *
1179
- */
1180
- private void reloadMap () {
1181
- clearAllMarkers (); // Clear the list of markers
1182
- binding .map .getController ().setZoom (ZOOM_LEVEL ); // Reset the zoom level
1183
- binding .map .getController ().setCenter (lastMapFocus ); // Recenter the focus
1184
- if (locationPermissionsHelper .checkLocationPermission (getActivity ())) {
1185
- locationPermissionGranted (); // Reload map with user's location
1186
- } else {
1187
- startMapWithoutPermission (); // Reload map without user's location
1188
- }
1189
- binding .map .invalidate (); // Invalidate the map
1190
- presenter .updateMapAndList (LOCATION_SIGNIFICANTLY_CHANGED ); // Restart the map
1191
- Timber .d ("Reloaded Map Successfully" );
1192
- }
1193
-
1194
-
1195
- /**
1196
- * Clears the Nearby local cache and then calls for the map to be reloaded
1177
+ * Clears the Nearby local cache and then calls for pin details to be fetched afresh.
1197
1178
*
1198
1179
*/
1199
1180
private void emptyCache () {
@@ -1202,7 +1183,22 @@ private void emptyCache() {
1202
1183
placesRepository .clearCache ()
1203
1184
.subscribeOn (Schedulers .io ())
1204
1185
.observeOn (AndroidSchedulers .mainThread ())
1205
- .andThen (Completable .fromAction (this ::reloadMap ))
1186
+ .andThen (Completable .fromAction (() -> {
1187
+ // reload only the pin details, by making all loaded pins gray:
1188
+ ArrayList <MarkerPlaceGroup > newPlaceGroups = new ArrayList <>(
1189
+ NearbyController .markerLabelList .size ());
1190
+ for (final MarkerPlaceGroup placeGroup : NearbyController .markerLabelList ) {
1191
+ final Place place = new Place ("" , "" , placeGroup .getPlace ().getLabel (), "" ,
1192
+ placeGroup .getPlace ().getLocation (), "" ,
1193
+ placeGroup .getPlace ().siteLinks , "" , placeGroup .getPlace ().exists ,
1194
+ placeGroup .getPlace ().entityID );
1195
+ place .setDistance (placeGroup .getPlace ().distance );
1196
+ place .setMonument (placeGroup .getPlace ().isMonument ());
1197
+ newPlaceGroups .add (
1198
+ new MarkerPlaceGroup (placeGroup .getIsBookmarked (), place ));
1199
+ }
1200
+ presenter .loadPlacesDataAsync (newPlaceGroups , scope );
1201
+ }))
1206
1202
.subscribe (
1207
1203
() -> {
1208
1204
Timber .d ("Nearby Cache cleared successfully." );
0 commit comments