diff --git a/OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java b/OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java index 9a34c67f27..9fa956284e 100644 --- a/OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java +++ b/OsmAnd/src/net/osmand/plus/PoiFiltersHelper.java @@ -171,18 +171,21 @@ public class PoiFiltersHelper { cacheUserDefinedFilters = new ArrayList(); PoiFilterDbHelper helper = openDbHelper(); List userDefined = helper.getFilters(helper.getReadableDatabase()); - final Collator instance = Collator.getInstance(); - Collections.sort(userDefined, new Comparator() { - @Override - public int compare(PoiFilter object1, PoiFilter object2) { - return instance.compare(object1.getName(), object2.getName()); - } - }); + sortListOfFiltersByName(userDefined); cacheUserDefinedFilters.addAll(userDefined); helper.close(); } return Collections.unmodifiableList(cacheUserDefinedFilters); } + private void sortListOfFiltersByName(List userDefined) { + final Collator instance = Collator.getInstance(); + Collections.sort(userDefined, new Comparator() { + @Override + public int compare(PoiFilter object1, PoiFilter object2) { + return instance.compare(object1.getName(), object2.getName()); + } + }); + } public List getTopStandardFilters() { if (cacheTopStandardFilters == null) { @@ -257,6 +260,7 @@ public class PoiFiltersHelper { boolean res = helper.addFilter(filter, helper.getWritableDatabase(), false); if(res){ cacheUserDefinedFilters.add(filter); + sortListOfFiltersByName(cacheUserDefinedFilters); } helper.close(); return res; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java index 118df3c684..df43fdb69e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchActivity.java @@ -236,6 +236,15 @@ public class SearchActivity extends SherlockFragmentActivity implements OsmAndLo } else { updateSearchPoint(latLon, getString(R.string.search_position_fixed), true); } + } else if (requestCode == SearchPoiFilterActivity.REQUEST_POI_EDIT) { + for(WeakReference ref : fragList) { + Fragment f = ref.get(); + if(f instanceof SearchPoiFilterActivity) { + if(!f.isDetached()) { + ((SearchPoiFilterActivity) f).refreshPoiListAdapter(); + } + } + } } } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterActivity.java index c6e23dd985..ca834214dd 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPoiFilterActivity.java @@ -38,6 +38,7 @@ public class SearchPoiFilterActivity extends SherlockListFragment implements Se public static final String SEARCH_LAT = SearchActivity.SEARCH_LAT; public static final String SEARCH_LON = SearchActivity.SEARCH_LON; + public static final int REQUEST_POI_EDIT = 55; @Override @@ -59,6 +60,10 @@ public class SearchPoiFilterActivity extends SherlockListFragment implements Se } }); + refreshPoiListAdapter(); + } + + public void refreshPoiListAdapter() { PoiFiltersHelper poiFilters = getApp().getPoiFilters(); List filters = new ArrayList() ; filters.addAll(poiFilters.getTopStandardFilters()); @@ -95,7 +100,7 @@ public class SearchPoiFilterActivity extends SherlockListFragment implements Se // folder selected newIntent.putExtra(EditPOIFilterActivity.AMENITY_FILTER, poi.getFilterId()); updateIntentToLaunch(newIntent); - startActivityForResult(newIntent, 0); + startActivityForResult(newIntent, REQUEST_POI_EDIT); } @Override