Skip to content

Commit 3c31278

Browse files
author
bennsimon
committed
update error message when fetching structures
1 parent f943a1f commit 3c31278

File tree

3 files changed

+30
-36
lines changed

3 files changed

+30
-36
lines changed

opensrp-eusm/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ android {
5151
minSdkVersion androidMinSdkVersion
5252
targetSdkVersion androidTargetSdkVersion
5353
versionCode 1
54-
versionName "0.1.2"
54+
versionName "0.1.3"
5555
multiDexEnabled true
5656
buildConfigField "long", "MAX_SERVER_TIME_DIFFERENCE", "1800000l"
5757
buildConfigField "boolean", "TIME_CHECK", "false"

opensrp-eusm/src/main/java/org/smartregister/eusm/interactor/EusmTaskingMapInteractor.java

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -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

opensrp-eusm/src/main/res/values/strings.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797

9898
<string name="next_page"><![CDATA[NEXT >>]]></string>
9999
<string name="previous_page"><![CDATA[<< Previous]]></string>
100-
<string name="product_serial_n_quantity">%s &#183; %s %s</string>
100+
<string name="product_serial_n_quantity" translatable="false">%s &#183; %s %s</string>
101101
<string name="product_serial_text">Serial # </string>
102102
<string name="product_quantity_text">Qty: </string>
103103
<string name="product_serial">Serial # %s</string>
@@ -146,8 +146,8 @@
146146
<string name="stock_type_id_key" translatable="false">identifier</string>
147147
<string name="ok_text">OK</string>
148148
<string name="new_assignment_dialog_title">New Mission Assigned</string>
149-
<string name="no_structures_found">There are no structures mapped to this operational area. Please add a point to begin</string>
150-
<string name="fetch_location_and_structures_failed">This operational area has not been defined in the system. Please try to sync your device. Please contact the system administrator if that doesn\'t solve the issue noting the operational area number %1$s.</string>
149+
<string name="no_structures_found">There are no active service points in this district.</string>
150+
<string name="fetch_location_and_structures_failed">There are no active service points in this district.</string>
151151
<string name="account_disabled">Account Disabled</string>
152152
<string name="fetching_structure_title">Fetching Structure Details</string>
153153
<string name="fetching_structure_message">Fetching Structure Details. Please wait</string>

0 commit comments

Comments
 (0)