Fix POI edit activity
This commit is contained in:
parent
ddc62db00e
commit
d195ebc054
3 changed files with 26 additions and 8 deletions
|
@ -171,18 +171,21 @@ public class PoiFiltersHelper {
|
||||||
cacheUserDefinedFilters = new ArrayList<PoiFilter>();
|
cacheUserDefinedFilters = new ArrayList<PoiFilter>();
|
||||||
PoiFilterDbHelper helper = openDbHelper();
|
PoiFilterDbHelper helper = openDbHelper();
|
||||||
List<PoiFilter> userDefined = helper.getFilters(helper.getReadableDatabase());
|
List<PoiFilter> userDefined = helper.getFilters(helper.getReadableDatabase());
|
||||||
final Collator instance = Collator.getInstance();
|
sortListOfFiltersByName(userDefined);
|
||||||
Collections.sort(userDefined, new Comparator<PoiFilter>() {
|
|
||||||
@Override
|
|
||||||
public int compare(PoiFilter object1, PoiFilter object2) {
|
|
||||||
return instance.compare(object1.getName(), object2.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cacheUserDefinedFilters.addAll(userDefined);
|
cacheUserDefinedFilters.addAll(userDefined);
|
||||||
helper.close();
|
helper.close();
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableList(cacheUserDefinedFilters);
|
return Collections.unmodifiableList(cacheUserDefinedFilters);
|
||||||
}
|
}
|
||||||
|
private void sortListOfFiltersByName(List<PoiFilter> userDefined) {
|
||||||
|
final Collator instance = Collator.getInstance();
|
||||||
|
Collections.sort(userDefined, new Comparator<PoiFilter>() {
|
||||||
|
@Override
|
||||||
|
public int compare(PoiFilter object1, PoiFilter object2) {
|
||||||
|
return instance.compare(object1.getName(), object2.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public List<PoiFilter> getTopStandardFilters() {
|
public List<PoiFilter> getTopStandardFilters() {
|
||||||
if (cacheTopStandardFilters == null) {
|
if (cacheTopStandardFilters == null) {
|
||||||
|
@ -257,6 +260,7 @@ public class PoiFiltersHelper {
|
||||||
boolean res = helper.addFilter(filter, helper.getWritableDatabase(), false);
|
boolean res = helper.addFilter(filter, helper.getWritableDatabase(), false);
|
||||||
if(res){
|
if(res){
|
||||||
cacheUserDefinedFilters.add(filter);
|
cacheUserDefinedFilters.add(filter);
|
||||||
|
sortListOfFiltersByName(cacheUserDefinedFilters);
|
||||||
}
|
}
|
||||||
helper.close();
|
helper.close();
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -236,6 +236,15 @@ public class SearchActivity extends SherlockFragmentActivity implements OsmAndLo
|
||||||
} else {
|
} else {
|
||||||
updateSearchPoint(latLon, getString(R.string.search_position_fixed), true);
|
updateSearchPoint(latLon, getString(R.string.search_position_fixed), true);
|
||||||
}
|
}
|
||||||
|
} else if (requestCode == SearchPoiFilterActivity.REQUEST_POI_EDIT) {
|
||||||
|
for(WeakReference<Fragment> ref : fragList) {
|
||||||
|
Fragment f = ref.get();
|
||||||
|
if(f instanceof SearchPoiFilterActivity) {
|
||||||
|
if(!f.isDetached()) {
|
||||||
|
((SearchPoiFilterActivity) f).refreshPoiListAdapter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_LAT = SearchActivity.SEARCH_LAT;
|
||||||
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
|
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
|
||||||
|
public static final int REQUEST_POI_EDIT = 55;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,6 +60,10 @@ public class SearchPoiFilterActivity extends SherlockListFragment implements Se
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
refreshPoiListAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshPoiListAdapter() {
|
||||||
PoiFiltersHelper poiFilters = getApp().getPoiFilters();
|
PoiFiltersHelper poiFilters = getApp().getPoiFilters();
|
||||||
List<PoiFilter> filters = new ArrayList<PoiFilter>() ;
|
List<PoiFilter> filters = new ArrayList<PoiFilter>() ;
|
||||||
filters.addAll(poiFilters.getTopStandardFilters());
|
filters.addAll(poiFilters.getTopStandardFilters());
|
||||||
|
@ -95,7 +100,7 @@ public class SearchPoiFilterActivity extends SherlockListFragment implements Se
|
||||||
// folder selected
|
// folder selected
|
||||||
newIntent.putExtra(EditPOIFilterActivity.AMENITY_FILTER, poi.getFilterId());
|
newIntent.putExtra(EditPOIFilterActivity.AMENITY_FILTER, poi.getFilterId());
|
||||||
updateIntentToLaunch(newIntent);
|
updateIntentToLaunch(newIntent);
|
||||||
startActivityForResult(newIntent, 0);
|
startActivityForResult(newIntent, REQUEST_POI_EDIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue