Fix NPE
This commit is contained in:
parent
640c3aa5e6
commit
fb0b2c318e
1 changed files with 10 additions and 2 deletions
|
@ -121,7 +121,11 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
|
|||
|
||||
public List<Object> getFilters(String s) {
|
||||
List<Object> filters = new ArrayList<Object>() ;
|
||||
PoiFiltersHelper poiFilters = getApp().getPoiFilters();
|
||||
OsmandApplication app = getApp();
|
||||
if(app == null) {
|
||||
return filters;
|
||||
}
|
||||
PoiFiltersHelper poiFilters = app.getPoiFilters();
|
||||
if (Algorithms.isEmpty(s)) {
|
||||
filters.addAll(poiFilters.getTopDefinedPoiFilters());
|
||||
} else {
|
||||
|
@ -131,7 +135,7 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
|
|||
}
|
||||
}
|
||||
Map<String, AbstractPoiType> res =
|
||||
getApp().getPoiTypes().getAllTypesTranslatedNames(new CollatorStringMatcher(s, StringMatcherMode.CHECK_STARTS_FROM_SPACE));
|
||||
app.getPoiTypes().getAllTypesTranslatedNames(new CollatorStringMatcher(s, StringMatcherMode.CHECK_STARTS_FROM_SPACE));
|
||||
for(AbstractPoiType p : res.values()) {
|
||||
filters.add(p);
|
||||
}
|
||||
|
@ -145,6 +149,10 @@ public class SearchPoiFilterFragment extends OsmAndListFragment implements Searc
|
|||
}
|
||||
|
||||
public OsmandApplication getApp(){
|
||||
FragmentActivity activity = getActivity();
|
||||
if(activity == null) {
|
||||
return null;
|
||||
}
|
||||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue