@@ -628,6 +628,18 @@ public void updateListFragment(List<Place> placeList) {
628
628
adapterFactory .updateAdapterData (placeList , (RVRendererAdapter <Place >) rvNearbyList .getAdapter ());
629
629
}
630
630
631
+ public void clearNearbyList () {
632
+ adapterFactory .clear ((RVRendererAdapter <Place >) rvNearbyList .getAdapter ());
633
+ }
634
+
635
+ public void updateNearbyList () {
636
+ adapterFactory .update ((RVRendererAdapter <Place >) rvNearbyList .getAdapter ());
637
+ }
638
+
639
+ public void addPlaceToNearbyList (Place place ) {
640
+ adapterFactory .add (place , (RVRendererAdapter <Place >) rvNearbyList .getAdapter ());
641
+ }
642
+
631
643
@ Override
632
644
public fr .free .nrw .commons .location .LatLng getLastLocation () {
633
645
return lastKnownLocation ;
@@ -1082,7 +1094,8 @@ public void updateMapMarkers(List<NearbyBaseMarker> nearbyBaseMarkers, Marker se
1082
1094
1083
1095
@ Override
1084
1096
public void filterOutAllMarkers () {
1085
- hideAllMArkers ();
1097
+ hideAllMarkers ();
1098
+ updateNearbyList ();
1086
1099
}
1087
1100
1088
1101
/**
@@ -1093,6 +1106,7 @@ public void displayAllMarkers() {
1093
1106
for (MarkerPlaceGroup markerPlaceGroup : NearbyController .markerLabelList ) {
1094
1107
updateMarker (markerPlaceGroup .getIsBookmarked (), markerPlaceGroup .getPlace (), NearbyController .currentLocation );
1095
1108
}
1109
+ updateNearbyList ();
1096
1110
}
1097
1111
1098
1112
/**
@@ -1104,65 +1118,46 @@ public void displayAllMarkers() {
1104
1118
* @param filterForAllNoneType true if we filter places with all none button
1105
1119
*/
1106
1120
@ Override
1107
- public void filterMarkersByLabels (List <Label > selectedLabels , boolean displayExists ,
1108
- boolean displayNeedsPhoto ,
1109
- boolean filterForPlaceState ,
1110
- boolean filterForAllNoneType ) {
1111
- if (selectedLabels .size () == 0 && filterForPlaceState ) { // If nothing is selected, display all
1112
- // remove the previous markers before updating them
1113
- hideAllMArkers ();
1114
- for (MarkerPlaceGroup markerPlaceGroup : NearbyController .markerLabelList ) {
1115
- if (displayExists && displayNeedsPhoto ) {
1116
- // Exists and needs photo
1117
- if (markerPlaceGroup .getPlace ().destroyed .trim ().isEmpty () && markerPlaceGroup .getPlace ().pic .trim ().isEmpty ()) {
1118
- updateMarker (markerPlaceGroup .getIsBookmarked (), markerPlaceGroup .getPlace (), NearbyController .currentLocation );
1119
- }
1120
- } else if (displayExists && !displayNeedsPhoto ) {
1121
- // Exists and all included needs and doesn't needs photo
1122
- if (markerPlaceGroup .getPlace ().destroyed .trim ().isEmpty ()) {
1123
- updateMarker (markerPlaceGroup .getIsBookmarked (), markerPlaceGroup .getPlace (), NearbyController .currentLocation );
1124
- }
1125
- } else if (!displayExists && displayNeedsPhoto ) {
1126
- // All and only needs photo
1127
- if (markerPlaceGroup .getPlace ().pic .trim ().isEmpty ()) {
1128
- updateMarker (markerPlaceGroup .getIsBookmarked (), markerPlaceGroup .getPlace (), NearbyController .currentLocation );
1129
- }
1130
- } else if (!displayExists && !displayNeedsPhoto ) {
1131
- // all
1132
- updateMarker (markerPlaceGroup .getIsBookmarked (), markerPlaceGroup .getPlace (), NearbyController .currentLocation );
1133
- }
1121
+ public void filterMarkersByLabels (List <Label > selectedLabels ,
1122
+ boolean displayExists ,
1123
+ boolean displayNeedsPhoto ,
1124
+ boolean filterForPlaceState ,
1125
+ boolean filterForAllNoneType ) {
1134
1126
1127
+ // Remove the previous markers before updating them
1128
+ hideAllMarkers ();
1129
+
1130
+ for (MarkerPlaceGroup markerPlaceGroup : NearbyController .markerLabelList ) {
1131
+ Place place = markerPlaceGroup .getPlace ();
1132
+
1133
+ // When label filter is engaged
1134
+ // then compare it against place's label
1135
+ if (selectedLabels != null && (selectedLabels .size () != 0 || !filterForPlaceState )
1136
+ && !selectedLabels .contains (place .getLabel ())) {
1137
+ continue ;
1135
1138
}
1136
- } else {
1137
- // First remove all the markers
1138
- hideAllMArkers ();
1139
- for (MarkerPlaceGroup markerPlaceGroup : NearbyController .markerLabelList ) {
1140
- for (Label label : selectedLabels ) {
1141
- if (markerPlaceGroup .getPlace ().getLabel ().toString ().equals (label .toString ())) {
1142
-
1143
- if (displayExists && displayNeedsPhoto ) {
1144
- // Exists and needs photo
1145
- if (markerPlaceGroup .getPlace ().destroyed .trim ().isEmpty () && markerPlaceGroup .getPlace ().pic .trim ().isEmpty ()) {
1146
- updateMarker (markerPlaceGroup .getIsBookmarked (), markerPlaceGroup .getPlace (), NearbyController .currentLocation );
1147
- }
1148
- } else if (displayExists && !displayNeedsPhoto ) {
1149
- // Exists and all included needs and doesn't needs photo
1150
- if (markerPlaceGroup .getPlace ().destroyed .trim ().isEmpty ()) {
1151
- updateMarker (markerPlaceGroup .getIsBookmarked (), markerPlaceGroup .getPlace (), NearbyController .currentLocation );
1152
- }
1153
- } else if (!displayExists && displayNeedsPhoto ) {
1154
- // All and only needs photo
1155
- if (markerPlaceGroup .getPlace ().pic .trim ().isEmpty ()) {
1156
- updateMarker (markerPlaceGroup .getIsBookmarked (), markerPlaceGroup .getPlace (), NearbyController .currentLocation );
1157
- }
1158
- } else if (!displayExists && !displayNeedsPhoto ) {
1159
- // all
1160
- updateMarker (markerPlaceGroup .getIsBookmarked (), markerPlaceGroup .getPlace (), NearbyController .currentLocation );
1161
- }
1162
- }
1139
+
1140
+ if (displayExists && displayNeedsPhoto ) {
1141
+ // Exists and needs photo
1142
+ if (place .destroyed .trim ().isEmpty () && place .pic .trim ().isEmpty ()) {
1143
+ updateMarker (markerPlaceGroup .getIsBookmarked (), place , NearbyController .currentLocation );
1144
+ }
1145
+ } else if (displayExists && !displayNeedsPhoto ) {
1146
+ // Exists and all included needs and doesn't needs photo
1147
+ if (place .destroyed .trim ().isEmpty ()) {
1148
+ updateMarker (markerPlaceGroup .getIsBookmarked (), place , NearbyController .currentLocation );
1163
1149
}
1150
+ } else if (!displayExists && displayNeedsPhoto ) {
1151
+ // All and only needs photo
1152
+ if (place .pic .trim ().isEmpty ()) {
1153
+ updateMarker (markerPlaceGroup .getIsBookmarked (), place , NearbyController .currentLocation );
1154
+ }
1155
+ } else if (!displayExists && !displayNeedsPhoto ) {
1156
+ // all
1157
+ updateMarker (markerPlaceGroup .getIsBookmarked (), place , NearbyController .currentLocation );
1164
1158
}
1165
1159
}
1160
+ updateNearbyList ();
1166
1161
}
1167
1162
1168
1163
@ Override
@@ -1177,6 +1172,8 @@ public fr.free.nrw.commons.location.LatLng getCameraTarget() {
1177
1172
* @param curLatLng current location
1178
1173
*/
1179
1174
public void updateMarker (boolean isBookmarked , Place place , @ Nullable fr .free .nrw .commons .location .LatLng curLatLng ) {
1175
+ addPlaceToNearbyList (place );
1176
+
1180
1177
VectorDrawableCompat vectorDrawable ;
1181
1178
if (isBookmarked ) {
1182
1179
vectorDrawable = VectorDrawableCompat .create (
@@ -1223,7 +1220,7 @@ public void updateMarker(boolean isBookmarked, Place place, @Nullable fr.free.nr
1223
1220
* but it is transparent more than grey(as the name of the icon might suggest)
1224
1221
* since grey icon may lead the users to believe that it is disabled or prohibited contribution
1225
1222
*/
1226
- private void hideAllMArkers () {
1223
+ private void hideAllMarkers () {
1227
1224
VectorDrawableCompat vectorDrawable ;
1228
1225
vectorDrawable = VectorDrawableCompat .create (
1229
1226
getContext ().getResources (), R .drawable .ic_custom_greyed_out_marker , getContext ().getTheme ());
@@ -1234,6 +1231,7 @@ private void hideAllMArkers() {
1234
1231
}
1235
1232
}
1236
1233
addCurrentLocationMarker (NearbyController .currentLocation );
1234
+ clearNearbyList ();
1237
1235
}
1238
1236
1239
1237
private void addNearbyMarkersToMapBoxMap (List <NearbyBaseMarker > nearbyBaseMarkers , Marker selectedMarker ) {
0 commit comments