Search in sources :

Example 1 with MarkerPlaceGroup

use of fr.free.nrw.commons.nearby.MarkerPlaceGroup in project apps-android-commons by commons-app.

the class NearbyParentFragmentPresenter method updateMapMarkersToController.

@Override
@MainThread
public void updateMapMarkersToController(List<NearbyBaseMarker> nearbyBaseMarkers) {
    NearbyController.markerExistsMap = new HashMap<>();
    NearbyController.markerNeedPicMap = new HashMap<>();
    NearbyController.markerLabelList.clear();
    for (int i = 0; i < nearbyBaseMarkers.size(); i++) {
        NearbyBaseMarker nearbyBaseMarker = nearbyBaseMarkers.get(i);
        NearbyController.markerLabelList.add(new MarkerPlaceGroup(nearbyBaseMarker.getMarker(), bookmarkLocationDao.findBookmarkLocation(nearbyBaseMarker.getPlace()), nearbyBaseMarker.getPlace()));
        // TODO: fix bookmark location
        NearbyController.markerExistsMap.put((nearbyBaseMarkers.get(i).getPlace().hasWikidataLink()), nearbyBaseMarkers.get(i).getMarker());
        NearbyController.markerNeedPicMap.put(((nearbyBaseMarkers.get(i).getPlace().pic == null) ? true : false), nearbyBaseMarkers.get(i).getMarker());
    }
}
Also used : NearbyBaseMarker(fr.free.nrw.commons.nearby.NearbyBaseMarker) MarkerPlaceGroup(fr.free.nrw.commons.nearby.MarkerPlaceGroup) MainThread(androidx.annotation.MainThread)

Example 2 with MarkerPlaceGroup

use of fr.free.nrw.commons.nearby.MarkerPlaceGroup in project apps-android-commons by commons-app.

the class NearbyParentFragment method filterMarkersByLabels.

/**
 * Filters markers based on selectedLabels and chips
 * @param selectedLabels label list that user clicked
 * @param displayExists chip for displaying only existing places
 * @param displayNeedsPhoto chip for displaying only places need photos
 * @param filterForPlaceState true if we filter places for place state
 * @param filterForAllNoneType true if we filter places with all none button
 */
@Override
public void filterMarkersByLabels(final List<Label> selectedLabels, final boolean displayExists, final boolean displayNeedsPhoto, final boolean displayWlm, final boolean filterForPlaceState, final boolean filterForAllNoneType) {
    // Remove the previous markers before updating them
    hideAllMarkers();
    filteredMarkers = new ArrayList<>();
    for (final MarkerPlaceGroup markerPlaceGroup : NearbyController.markerLabelList) {
        final Place place = markerPlaceGroup.getPlace();
        // then compare it against place's label
        if (selectedLabels != null && (selectedLabels.size() != 0 || !filterForPlaceState) && (!selectedLabels.contains(place.getLabel()) && !(selectedLabels.contains(Label.BOOKMARKS) && markerPlaceGroup.getIsBookmarked()))) {
            continue;
        }
        if (!displayWlm && place.isMonument()) {
            continue;
        }
        boolean shouldUpdateMarker = false;
        if (displayWlm && place.isMonument()) {
            shouldUpdateMarker = true;
        } else if (displayExists && displayNeedsPhoto) {
            // Exists and needs photo
            if (place.exists && place.pic.trim().isEmpty()) {
                shouldUpdateMarker = true;
            }
        } else if (displayExists && !displayNeedsPhoto) {
            // Exists and all included needs and doesn't needs photo
            if (place.exists) {
                shouldUpdateMarker = true;
            }
        } else if (!displayExists && displayNeedsPhoto) {
            // All and only needs photo
            if (place.pic.trim().isEmpty()) {
                shouldUpdateMarker = true;
            }
        } else if (!displayExists && !displayNeedsPhoto) {
            // all
            shouldUpdateMarker = true;
        }
        if (shouldUpdateMarker) {
            updateMarker(markerPlaceGroup.getIsBookmarked(), place, NearbyController.currentLocation);
        }
    }
    mapBox.clear();
    mapBox.addMarkers(filteredMarkers);
}
Also used : MarkerPlaceGroup(fr.free.nrw.commons.nearby.MarkerPlaceGroup) Place(fr.free.nrw.commons.nearby.Place)

Aggregations

MarkerPlaceGroup (fr.free.nrw.commons.nearby.MarkerPlaceGroup)2 MainThread (androidx.annotation.MainThread)1 NearbyBaseMarker (fr.free.nrw.commons.nearby.NearbyBaseMarker)1 Place (fr.free.nrw.commons.nearby.Place)1