Fix sortign favorites

This commit is contained in:
Victor Shcherb 2015-08-25 23:14:01 +02:00
parent 42705f7a5a
commit 6822805739
2 changed files with 56 additions and 50 deletions

View file

@ -477,13 +477,17 @@ public class FavouritesDbHelper {
String s2 = o2.getName();
int i1 = Algorithms.extractIntegerNumber(s1);
int i2 = Algorithms.extractIntegerNumber(s2);
if(i1 == i2) {
String ot1 = Algorithms.extractIntegerPrefix(s1);
String ot2 = Algorithms.extractIntegerPrefix(s2);
return collator.compare(ot1, ot2);
String ot1 = Algorithms.extractIntegerPrefix(s1);
String ot2 = Algorithms.extractIntegerPrefix(s2);
int res = collator.compare(ot1, ot2);
if (res == 0) {
res = i1 - i2;
}
return i1 - i2;
if (res == 0) {
res = collator.compare(s1, s2);
}
return res;
}
};
return favoritesComparator;

View file

@ -1,5 +1,37 @@
package net.osmand.plus.activities;
import gnu.trove.list.array.TIntArrayList;
import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.osmand.access.AccessibleToast;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.ColorDialogs;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.util.MapUtils;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
@ -37,39 +69,6 @@ import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.access.AccessibleToast;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.ColorDialogs;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.util.MapUtils;
import java.io.File;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import gnu.trove.list.array.TIntArrayList;
public class FavoritesTreeFragment extends OsmandExpandableListFragment {
@ -605,6 +604,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
class FavouritesAdapter extends OsmandBaseExpandableListAdapter implements Filterable {
private static final boolean showOptionsButton = false;
Map<FavoriteGroup, List<FavouritePoint>> favoriteGroups = new LinkedHashMap<FavoriteGroup, List<FavouritePoint>>();
List<FavoriteGroup> groups = new ArrayList<FavoriteGroup>();
Filter myFilter;
@ -764,17 +764,19 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
final FavouritePoint model = (FavouritePoint) getChild(groupPosition, childPosition);
row.setTag(model);
ImageView options = (ImageView) row.findViewById(R.id.options);
options.setFocusable(false);
options.setImageDrawable(getMyApplication().getIconsCache()
.getContentIcon(R.drawable.ic_overflow_menu_white));
options.setVisibility(View.VISIBLE);
options.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showItemPopupOptionsMenu(model, v);
}
});
if (showOptionsButton) {
ImageView options = (ImageView) row.findViewById(R.id.options);
options.setFocusable(false);
options.setImageDrawable(getMyApplication().getIconsCache().getContentIcon(
R.drawable.ic_overflow_menu_white));
options.setVisibility(View.VISIBLE);
options.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showItemPopupOptionsMenu(model, v);
}
});
}
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), model.getColor(), 0));
LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(),