Fix non-transitive comparision https://github.com/osmandapp/OsmAnd/issues/10626
This commit is contained in:
parent
d7828b4bf0
commit
6906b04a53
1 changed files with 13 additions and 10 deletions
|
@ -954,14 +954,12 @@ public class SearchUICore {
|
|||
break;
|
||||
}
|
||||
case COMPARE_AMENITY_TYPE_ADDITIONAL: {
|
||||
if(o1.object instanceof AbstractPoiType && o2.object instanceof AbstractPoiType ) {
|
||||
boolean additional1 = ((AbstractPoiType) o1.object).isAdditional();
|
||||
boolean additional2 = ((AbstractPoiType) o2.object).isAdditional();
|
||||
boolean additional1 = o1.object instanceof AbstractPoiType && ((AbstractPoiType) o1.object).isAdditional();
|
||||
boolean additional2 = o2.object instanceof AbstractPoiType && ((AbstractPoiType) o2.object).isAdditional();
|
||||
if (additional1 != additional2) {
|
||||
// -1 - means 1st is less than 2nd
|
||||
return additional1 ? 1 : -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case COMPARE_DISTANCE_TO_PARENT_SEARCH_RESULT:
|
||||
|
@ -1042,12 +1040,17 @@ public class SearchUICore {
|
|||
|
||||
@Override
|
||||
public int compare(SearchResult o1, SearchResult o2) {
|
||||
List<ResultCompareStep> steps = new ArrayList<>();
|
||||
for (ResultCompareStep step : ResultCompareStep.values()) {
|
||||
int r = step.compare(o1, o2, this);
|
||||
steps.add(step);
|
||||
if (r != 0) {
|
||||
// debug crashes and identify non-transitive comparision
|
||||
// LOG.debug(String.format("%d: %s o1='%s' o2='%s'", r, steps, o1, o2));
|
||||
return r;
|
||||
}
|
||||
}
|
||||
// LOG.debug(String.format("EQUAL: o1='%s' o2='%s'", o1, o2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue