This commit is contained in:
veliymolfar 2020-07-02 19:21:45 +03:00
parent 4dda9e0784
commit a3ade0f57e

View file

@ -352,19 +352,15 @@ public class FavoritesSearchFragment extends DialogFragment {
Collections.sort(points, new Comparator<FavouritePoint>() { Collections.sort(points, new Comparator<FavouritePoint>() {
@Override @Override
public int compare(FavouritePoint p1, FavouritePoint p2) { public int compare(FavouritePoint p1, FavouritePoint p2) {
int d1 = (int) (MapUtils.getDistance(p1.getLatitude(), p1.getLongitude(), if (p1.isVisible() && p2.isVisible() || !p1.isVisible() && !p2.isVisible()) {
location.getLatitude(), location.getLongitude())); int d1 = (int) (MapUtils.getDistance(p1.getLatitude(), p1.getLongitude(),
int d2 = (int) (MapUtils.getDistance(p2.getLatitude(), p2.getLongitude(), location.getLatitude(), location.getLongitude()));
location.getLatitude(), location.getLongitude())); int d2 = (int) (MapUtils.getDistance(p2.getLatitude(), p2.getLongitude(),
return d1 < d2 ? -1 : (d1 == d2 ? 0 : 1); location.getLatitude(), location.getLongitude()));
} return d1 < d2 ? -1 : (d1 == d2 ? 0 : 1);
}); } else {
Collections.sort(points, new Comparator<FavouritePoint>() { return (p1.isVisible() == p2.isVisible()) ? 0 : (p1.isVisible() ? -1 : 1);
@Override }
public int compare(FavouritePoint p1, FavouritePoint p2) {
int v1 = p1.isVisible() ? 1 : 0;
int v2 = p2.isVisible() ? 1 : 0;
return v1 < v2 ? 1 : (v1 == v2 ? 0 : -1);
} }
}); });
notifyDataSetChanged(); notifyDataSetChanged();