Fix sorting

This commit is contained in:
PavelRatushny 2017-09-26 13:15:05 +03:00
parent e580a0d193
commit d852ec728e
4 changed files with 12 additions and 2 deletions

View file

@ -3158,12 +3158,17 @@ public class OsmandSettings {
}
public enum MapMarkersOrderByMode {
CUSTOM,
DISTANCE_DESC,
DISTANCE_ASC,
NAME,
DATE_ADDED_DESC,
DATE_ADDED_ASC;
public boolean isCustom() {
return this == CUSTOM;
}
public boolean isDistanceDescending() {
return this == DISTANCE_DESC;
}

View file

@ -18,6 +18,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MapViewTrackingUtilities;
import net.osmand.plus.dashboard.DashLocationFragment;
@ -77,6 +78,7 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
hideSnackbar();
mapActivity.getMyApplication().getMapMarkersHelper().checkAndFixActiveMarkersOrderIfNeeded();
adapter.notifyDataSetChanged();
mapActivity.getMyApplication().getSettings().MAP_MARKERS_ORDER_BY_MODE.set(OsmandSettings.MapMarkersOrderByMode.CUSTOM);
}
}
});

View file

@ -290,8 +290,10 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
}
private void setOrderByMode(MapMarkersOrderByMode orderByMode) {
getMyApplication().getMapMarkersHelper().orderMarkers(orderByMode);
activeFragment.updateAdapter();
if (orderByMode != MapMarkersOrderByMode.CUSTOM) {
getMyApplication().getMapMarkersHelper().orderMarkers(orderByMode);
activeFragment.updateAdapter();
}
}
private MapActivity getMapActivity() {

View file

@ -496,6 +496,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
public void setSelectedObject(Object o) {
if (o instanceof MapMarker) {
map.getMyApplication().getMapMarkersHelper().moveMarkerToTop((MapMarker) o);
map.getMyApplication().getSettings().MAP_MARKERS_ORDER_BY_MODE.set(OsmandSettings.MapMarkersOrderByMode.CUSTOM);
}
}