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