Fix POI edit activity
This commit is contained in:
parent
ddc62db00e
commit
d195ebc054
3 changed files with 26 additions and 8 deletions
|
@ -171,6 +171,13 @@ public class PoiFiltersHelper {
|
|||
cacheUserDefinedFilters = new ArrayList<PoiFilter>();
|
||||
PoiFilterDbHelper helper = openDbHelper();
|
||||
List<PoiFilter> userDefined = helper.getFilters(helper.getReadableDatabase());
|
||||
sortListOfFiltersByName(userDefined);
|
||||
cacheUserDefinedFilters.addAll(userDefined);
|
||||
helper.close();
|
||||
}
|
||||
return Collections.unmodifiableList(cacheUserDefinedFilters);
|
||||
}
|
||||
private void sortListOfFiltersByName(List<PoiFilter> userDefined) {
|
||||
final Collator instance = Collator.getInstance();
|
||||
Collections.sort(userDefined, new Comparator<PoiFilter>() {
|
||||
@Override
|
||||
|
@ -178,10 +185,6 @@ public class PoiFiltersHelper {
|
|||
return instance.compare(object1.getName(), object2.getName());
|
||||
}
|
||||
});
|
||||
cacheUserDefinedFilters.addAll(userDefined);
|
||||
helper.close();
|
||||
}
|
||||
return Collections.unmodifiableList(cacheUserDefinedFilters);
|
||||
}
|
||||
|
||||
public List<PoiFilter> getTopStandardFilters() {
|
||||
|
@ -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;
|
||||
|
|
|
@ -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<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_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<PoiFilter> filters = new ArrayList<PoiFilter>() ;
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue