Fix nearest wiki
This commit is contained in:
parent
416bedc121
commit
7a59047a5d
2 changed files with 33 additions and 15 deletions
|
@ -29,12 +29,14 @@ import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.view.ContextThemeWrapper;
|
import androidx.appcompat.view.ContextThemeWrapper;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.graphics.drawable.DrawableCompat;
|
import androidx.core.graphics.drawable.DrawableCompat;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.Amenity;
|
import net.osmand.data.Amenity;
|
||||||
|
@ -44,7 +46,12 @@ import net.osmand.data.QuadRect;
|
||||||
import net.osmand.osm.PoiCategory;
|
import net.osmand.osm.PoiCategory;
|
||||||
import net.osmand.osm.PoiType;
|
import net.osmand.osm.PoiType;
|
||||||
import net.osmand.osm.io.NetworkUtils;
|
import net.osmand.osm.io.NetworkUtils;
|
||||||
import net.osmand.plus.*;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandPlugin;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.ActivityResultListener;
|
import net.osmand.plus.activities.ActivityResultListener;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
|
@ -68,6 +75,7 @@ import net.osmand.plus.widgets.TextViewEx;
|
||||||
import net.osmand.plus.widgets.tools.ClickableSpanTouchListener;
|
import net.osmand.plus.widgets.tools.ClickableSpanTouchListener;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.openplacereviews.opendb.util.exception.FailedVerificationException;
|
import org.openplacereviews.opendb.util.exception.FailedVerificationException;
|
||||||
|
|
||||||
|
@ -75,7 +83,13 @@ import java.io.BufferedInputStream;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener;
|
import static net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask.GetImageCardsListener;
|
||||||
|
|
||||||
|
@ -1217,27 +1231,31 @@ public class MenuBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean processNearestWiki() {
|
protected boolean processNearestWiki() {
|
||||||
if (showNearestWiki && latLon != null) {
|
if (showNearestWiki && latLon != null && amenity != null) {
|
||||||
nearestWiki = getSortedAmenities(app.getPoiFilters().getTopWikiPoiFilter());
|
PoiUIFilter filter = app.getPoiFilters().getTopWikiPoiFilter();
|
||||||
|
if (filter != null) {
|
||||||
|
nearestWiki = getSortedAmenities(filter, latLon);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean processNearestPoi() {
|
protected boolean processNearestPoi() {
|
||||||
if (showNearestPoi && latLon != null) {
|
if (showNearestPoi && latLon != null && amenity != null) {
|
||||||
PoiCategory pc = amenity.getType();
|
PoiCategory pc = amenity.getType();
|
||||||
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
|
PoiType pt = pc.getPoiTypeByKeyName(amenity.getSubType());
|
||||||
nearestPoi = getSortedAmenities(app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + pt.getKeyName()));
|
PoiUIFilter filter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + pt.getKeyName());
|
||||||
|
if (filter != null) {
|
||||||
|
nearestPoi = getSortedAmenities(filter, latLon);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Amenity> getSortedAmenities(PoiUIFilter filter) {
|
private List<Amenity> getSortedAmenities(PoiUIFilter filter, final LatLon latLon) {
|
||||||
final LatLon latLon = getLatLon();
|
QuadRect rect = MapUtils.calculateLatLonBbox(latLon.getLatitude(), latLon.getLongitude(), 250);
|
||||||
QuadRect rect = MapUtils.calculateLatLonBbox(
|
|
||||||
latLon.getLatitude(), latLon.getLongitude(), 250);
|
|
||||||
|
|
||||||
List<Amenity> nearestAmenities = getAmenities(rect, filter);
|
List<Amenity> nearestAmenities = getAmenities(rect, filter);
|
||||||
nearestAmenities.remove(amenity);
|
nearestAmenities.remove(amenity);
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
||||||
this.amenity = amenity;
|
this.amenity = amenity;
|
||||||
setAmenity(amenity);
|
setAmenity(amenity);
|
||||||
setShowNearestWiki(true);
|
setShowNearestWiki(true);
|
||||||
setShowNearestPoi(true);
|
setShowNearestPoi(!amenity.getType().isWiki());
|
||||||
metricSystem = mapActivity.getMyApplication().getSettings().METRIC_SYSTEM.get();
|
metricSystem = mapActivity.getMyApplication().getSettings().METRIC_SYSTEM.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue