@@ -57,7 +57,7 @@ public void start(Stage stage) {
57
57
StackPane stackPane = new StackPane ();
58
58
Scene scene = new Scene (stackPane );
59
59
scene .getStylesheets ().add (getClass ().getResource (
60
- "/apply_scheduled_updates_to_preplanned_map_area/style.css" ).toExternalForm ());
60
+ "/apply_scheduled_updates_to_preplanned_map_area/style.css" ).toExternalForm ());
61
61
62
62
// set title, size, and add scene to stage
63
63
stage .setTitle ("Apply Scheduled Updates to Preplanned Map Area" );
@@ -122,7 +122,7 @@ private void checkForScheduledUpdates() {
122
122
long updateSize = offlineMapUpdatesInfo .getScheduledUpdatesDownloadSize ();
123
123
124
124
// create a dialog to show the update information
125
- Alert alert = new Alert (Alert .AlertType .CONFIRMATION , "Update size: " + updateSize + " bytes. Apply the update?" );
125
+ var alert = new Alert (Alert .AlertType .CONFIRMATION , "Update size: " + updateSize + " bytes. Apply the update?" );
126
126
alert .setTitle ("Updates Available" );
127
127
alert .setHeaderText ("An update is available for this preplanned map area." );
128
128
@@ -136,7 +136,7 @@ private void checkForScheduledUpdates() {
136
136
137
137
} else {
138
138
// show a dialog that no updates are available
139
- Alert alert = new Alert (Alert .AlertType .INFORMATION , "The preplanned map area is up to date." );
139
+ var alert = new Alert (Alert .AlertType .INFORMATION , "The preplanned map area is up to date." );
140
140
alert .setTitle ("Up to Date" );
141
141
alert .setHeaderText ("No updates available." );
142
142
alert .show ();
@@ -173,20 +173,20 @@ private void applyScheduledUpdates() {
173
173
if (offlineMapSyncJob .getStatus () == Job .Status .SUCCEEDED ) {
174
174
OfflineMapSyncResult offlineMapSyncResult = offlineMapSyncJob .getResult ();
175
175
176
- // if mobile map package reopen is required, close the existing mobile map package and load it again
176
+ // if mobile map package reopen is required, close the existing mobile map package
177
177
if (offlineMapSyncResult .isMobileMapPackageReopenRequired ()) {
178
178
mobileMapPackage .close ();
179
- mobileMapPackage .loadAsync ();
180
- mobileMapPackage .addDoneLoadingListener (() -> {
181
- if (mobileMapPackage .getLoadStatus () == LoadStatus .LOADED && !mobileMapPackage .getMaps ().isEmpty ()) {
182
-
183
- // add the map from the mobile map package to the map view
184
- mapView .setMap (mobileMapPackage .getMaps ().get (0 ));
185
-
179
+ // create a new instance of the now updated mobile map package and load it
180
+ var updatedMobileMapPackage = new MobileMapPackage (tempMobileMapPackageDirectory .toString ());
181
+ updatedMobileMapPackage .addDoneLoadingListener (() -> {
182
+ if (updatedMobileMapPackage .getLoadStatus () == LoadStatus .LOADED && !updatedMobileMapPackage .getMaps ().isEmpty ()) {
183
+ // add the map from the updated mobile map package to the map view
184
+ mapView .setMap (updatedMobileMapPackage .getMaps ().get (0 ));
186
185
} else {
187
186
new Alert (Alert .AlertType .ERROR , "Failed to load the mobile map package." ).show ();
188
187
}
189
188
});
189
+ updatedMobileMapPackage .loadAsync ();
190
190
}
191
191
192
192
// perform another check for updates, to make sure that the newest update was applied
0 commit comments