@@ -36,43 +36,37 @@ public EusmTaskingMapInteractor(TaskingMapActivityContract.Presenter presenter)
3636
3737 @ Override
3838 public void fetchLocations (String plan , String operationalArea , String point , Boolean locationComponentActive ) {
39- appExecutors .diskIO ().execute (new Runnable () {
40- @ Override
41- public void run () {
42- Set <Location > operationalAreaLocations = getOperationalAreaLocations (new HashSet <>(Arrays .asList (operationalArea .split (PreferencesUtil .OPERATIONAL_AREA_SEPARATOR ))));
39+ appExecutors .diskIO ().execute (() -> {
40+ Set <Location > operationalAreaLocations = getOperationalAreaLocations (new HashSet <>(Arrays .asList (operationalArea .split (PreferencesUtil .OPERATIONAL_AREA_SEPARATOR ))));
4341
44- JSONObject featureCollection = null ;
45- try {
46- featureCollection = createFeatureCollection ();
47- if (!operationalAreaLocations .isEmpty ()) {
48- List <StructureDetail > structureDetails = appStructureRepository
49- .fetchStructureDetails (null , operationalAreaLocations .stream ().filter (location -> location .getId () != null ).map (location -> location .getId ()).collect (Collectors .toSet ()), null , true , plan );
42+ JSONObject featureCollection = null ;
43+ try {
44+ featureCollection = createFeatureCollection ();
45+ if (!operationalAreaLocations .isEmpty ()) {
46+ List <StructureDetail > structureDetails = appStructureRepository
47+ .fetchStructureDetails (null , operationalAreaLocations .stream ().filter (location -> location .getId () != null ).map (location -> location .getId ()).collect (Collectors .toSet ()), null , true , plan );
5048
51- if (structureDetails != null && !structureDetails .isEmpty ()) {
52- String features = geoJsonUtils .getGeoJsonFromStructureDetail (structureDetails );
53- featureCollection .put (TaskingConstants .GeoJSON .FEATURES , new JSONArray (features ));
54- }
49+ if (structureDetails != null && !structureDetails .isEmpty ()) {
50+ String features = geoJsonUtils .getGeoJsonFromStructureDetail (structureDetails );
51+ featureCollection .put (TaskingConstants .GeoJSON .FEATURES , new JSONArray (features ));
5552 }
56- } catch (Exception e ) {
57- Timber .e (e );
5853 }
59- JSONObject finalFeatureCollection = featureCollection ;
60- appExecutors .mainThread ().execute (new Runnable () {
61- @ Override
62- public void run () {
63- if (!operationalAreaLocations .isEmpty ()) {
64- Feature operationalAreaFeature = Feature .fromJson (gson .toJson (operationalAreaLocations .stream ().findFirst ().orElse (null )));
65- if (locationComponentActive != null ) {
66- getPresenter ().onStructuresFetched (finalFeatureCollection , operationalAreaFeature , null , point , locationComponentActive );
67- } else {
68- getPresenter ().onStructuresFetched (finalFeatureCollection , operationalAreaFeature , null );
69- }
70- } else {
71- getPresenter ().onStructuresFetched (finalFeatureCollection , null , null );
72- }
73- }
74- });
54+ } catch (Exception e ) {
55+ Timber .e (e );
7556 }
57+ JSONObject finalFeatureCollection = featureCollection ;
58+ appExecutors .mainThread ().execute (() -> {
59+ if (!operationalAreaLocations .isEmpty ()) {
60+ Feature operationalAreaFeature = Feature .fromJson (gson .toJson (operationalAreaLocations .stream ().findFirst ().orElse (null )));
61+ if (locationComponentActive != null ) {
62+ getPresenter ().onStructuresFetched (finalFeatureCollection , operationalAreaFeature , null , point , locationComponentActive );
63+ } else {
64+ getPresenter ().onStructuresFetched (finalFeatureCollection , operationalAreaFeature , null );
65+ }
66+ } else {
67+ getPresenter ().onStructuresFetched (finalFeatureCollection , null , null );
68+ }
69+ });
7670 });
7771 }
7872
0 commit comments