mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
parent
70f28b1dcf
commit
6d687c3efb
3 changed files with 71 additions and 56 deletions
|
|
@ -41,4 +41,17 @@ public class NearbyAdapterFactory {
|
|||
rendererAdapter.notifyDataSetChanged();
|
||||
rendererAdapter.diffUpdate(newPlaceList);
|
||||
}
|
||||
|
||||
public void clear(RVRendererAdapter<Place> rendererAdapter){
|
||||
rendererAdapter.clear();
|
||||
}
|
||||
|
||||
public void add(Place place, RVRendererAdapter<Place> rendererAdapter){
|
||||
rendererAdapter.add(place);
|
||||
}
|
||||
|
||||
public void update(RVRendererAdapter<Place> rendererAdapter){
|
||||
rendererAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -628,6 +628,18 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
adapterFactory.updateAdapterData(placeList, (RVRendererAdapter<Place>) rvNearbyList.getAdapter());
|
||||
}
|
||||
|
||||
public void clearNearbyList() {
|
||||
adapterFactory.clear((RVRendererAdapter<Place>) rvNearbyList.getAdapter());
|
||||
}
|
||||
|
||||
public void updateNearbyList() {
|
||||
adapterFactory.update((RVRendererAdapter<Place>) rvNearbyList.getAdapter());
|
||||
}
|
||||
|
||||
public void addPlaceToNearbyList(Place place) {
|
||||
adapterFactory.add(place, (RVRendererAdapter<Place>) rvNearbyList.getAdapter());
|
||||
}
|
||||
|
||||
@Override
|
||||
public fr.free.nrw.commons.location.LatLng getLastLocation() {
|
||||
return lastKnownLocation;
|
||||
|
|
@ -1082,7 +1094,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
|
||||
@Override
|
||||
public void filterOutAllMarkers() {
|
||||
hideAllMArkers();
|
||||
hideAllMarkers();
|
||||
updateNearbyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1093,6 +1106,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
for (MarkerPlaceGroup markerPlaceGroup : NearbyController.markerLabelList) {
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), markerPlaceGroup.getPlace(), NearbyController.currentLocation);
|
||||
}
|
||||
updateNearbyList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1104,65 +1118,46 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
* @param filterForAllNoneType true if we filter places with all none button
|
||||
*/
|
||||
@Override
|
||||
public void filterMarkersByLabels(List<Label> selectedLabels, boolean displayExists,
|
||||
boolean displayNeedsPhoto,
|
||||
boolean filterForPlaceState,
|
||||
boolean filterForAllNoneType) {
|
||||
if (selectedLabels.size() == 0 && filterForPlaceState) { // If nothing is selected, display all
|
||||
// remove the previous markers before updating them
|
||||
hideAllMArkers();
|
||||
for (MarkerPlaceGroup markerPlaceGroup : NearbyController.markerLabelList) {
|
||||
if (displayExists && displayNeedsPhoto) {
|
||||
// Exists and needs photo
|
||||
if (markerPlaceGroup.getPlace().destroyed.trim().isEmpty() && markerPlaceGroup.getPlace().pic.trim().isEmpty()) {
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), markerPlaceGroup.getPlace(), NearbyController.currentLocation);
|
||||
}
|
||||
} else if (displayExists && !displayNeedsPhoto) {
|
||||
// Exists and all included needs and doesn't needs photo
|
||||
if (markerPlaceGroup.getPlace().destroyed.trim().isEmpty()) {
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), markerPlaceGroup.getPlace(), NearbyController.currentLocation);
|
||||
}
|
||||
} else if (!displayExists && displayNeedsPhoto) {
|
||||
// All and only needs photo
|
||||
if (markerPlaceGroup.getPlace().pic.trim().isEmpty()) {
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), markerPlaceGroup.getPlace(), NearbyController.currentLocation);
|
||||
}
|
||||
} else if (!displayExists && !displayNeedsPhoto) {
|
||||
// all
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), markerPlaceGroup.getPlace(), NearbyController.currentLocation);
|
||||
}
|
||||
public void filterMarkersByLabels(List<Label> selectedLabels,
|
||||
boolean displayExists,
|
||||
boolean displayNeedsPhoto,
|
||||
boolean filterForPlaceState,
|
||||
boolean filterForAllNoneType) {
|
||||
|
||||
// Remove the previous markers before updating them
|
||||
hideAllMarkers();
|
||||
|
||||
for (MarkerPlaceGroup markerPlaceGroup : NearbyController.markerLabelList) {
|
||||
Place place = markerPlaceGroup.getPlace();
|
||||
|
||||
// When label filter is engaged
|
||||
// then compare it against place's label
|
||||
if (selectedLabels != null && (selectedLabels.size() != 0 || !filterForPlaceState)
|
||||
&& !selectedLabels.contains(place.getLabel())) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// First remove all the markers
|
||||
hideAllMArkers();
|
||||
for (MarkerPlaceGroup markerPlaceGroup : NearbyController.markerLabelList) {
|
||||
for (Label label : selectedLabels) {
|
||||
if (markerPlaceGroup.getPlace().getLabel().toString().equals(label.toString())) {
|
||||
|
||||
if (displayExists && displayNeedsPhoto) {
|
||||
// Exists and needs photo
|
||||
if (markerPlaceGroup.getPlace().destroyed.trim().isEmpty() && markerPlaceGroup.getPlace().pic.trim().isEmpty()) {
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), markerPlaceGroup.getPlace(), NearbyController.currentLocation);
|
||||
}
|
||||
} else if (displayExists && !displayNeedsPhoto) {
|
||||
// Exists and all included needs and doesn't needs photo
|
||||
if (markerPlaceGroup.getPlace().destroyed.trim().isEmpty()) {
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), markerPlaceGroup.getPlace(), NearbyController.currentLocation);
|
||||
}
|
||||
} else if (!displayExists && displayNeedsPhoto) {
|
||||
// All and only needs photo
|
||||
if (markerPlaceGroup.getPlace().pic.trim().isEmpty()) {
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), markerPlaceGroup.getPlace(), NearbyController.currentLocation);
|
||||
}
|
||||
} else if (!displayExists && !displayNeedsPhoto) {
|
||||
// all
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), markerPlaceGroup.getPlace(), NearbyController.currentLocation);
|
||||
}
|
||||
}
|
||||
if (displayExists && displayNeedsPhoto) {
|
||||
// Exists and needs photo
|
||||
if (place.destroyed.trim().isEmpty() && place.pic.trim().isEmpty()) {
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), place, NearbyController.currentLocation);
|
||||
}
|
||||
} else if (displayExists && !displayNeedsPhoto) {
|
||||
// Exists and all included needs and doesn't needs photo
|
||||
if (place.destroyed.trim().isEmpty()) {
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), place, NearbyController.currentLocation);
|
||||
}
|
||||
} else if (!displayExists && displayNeedsPhoto) {
|
||||
// All and only needs photo
|
||||
if (place.pic.trim().isEmpty()) {
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), place, NearbyController.currentLocation);
|
||||
}
|
||||
} else if (!displayExists && !displayNeedsPhoto) {
|
||||
// all
|
||||
updateMarker(markerPlaceGroup.getIsBookmarked(), place, NearbyController.currentLocation);
|
||||
}
|
||||
}
|
||||
updateNearbyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1177,6 +1172,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
* @param curLatLng current location
|
||||
*/
|
||||
public void updateMarker(boolean isBookmarked, Place place, @Nullable fr.free.nrw.commons.location.LatLng curLatLng) {
|
||||
addPlaceToNearbyList(place);
|
||||
|
||||
VectorDrawableCompat vectorDrawable;
|
||||
if (isBookmarked) {
|
||||
vectorDrawable = VectorDrawableCompat.create(
|
||||
|
|
@ -1223,7 +1220,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
* but it is transparent more than grey(as the name of the icon might suggest)
|
||||
* since grey icon may lead the users to believe that it is disabled or prohibited contribution
|
||||
*/
|
||||
private void hideAllMArkers() {
|
||||
private void hideAllMarkers() {
|
||||
VectorDrawableCompat vectorDrawable;
|
||||
vectorDrawable = VectorDrawableCompat.create(
|
||||
getContext().getResources(), R.drawable.ic_custom_greyed_out_marker, getContext().getTheme());
|
||||
|
|
@ -1234,6 +1231,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
|
|||
}
|
||||
}
|
||||
addCurrentLocationMarker(NearbyController.currentLocation);
|
||||
clearNearbyList();
|
||||
}
|
||||
|
||||
private void addNearbyMarkersToMapBoxMap(List<NearbyBaseMarker> nearbyBaseMarkers, Marker selectedMarker) {
|
||||
|
|
|
|||
|
|
@ -284,7 +284,11 @@ public class NearbyParentFragmentPresenter
|
|||
nearbyParentFragmentView.setRecyclerViewAdapterItemsGreyedOut();
|
||||
break;
|
||||
case CHECKED:
|
||||
nearbyParentFragmentView.displayAllMarkers();
|
||||
// Despite showing all labels NearbyFilterState still should be applied
|
||||
nearbyParentFragmentView.filterMarkersByLabels(selectedLabels,
|
||||
NearbyFilterState.getInstance().isExistsSelected(),
|
||||
NearbyFilterState.getInstance().isNeedPhotoSelected(),
|
||||
filterForPlaceState, false);
|
||||
nearbyParentFragmentView.setRecyclerViewAdapterAllSelected();
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue