@@ -57,7 +57,7 @@ public void start(Stage stage) {
5757 StackPane stackPane = new StackPane ();
5858 Scene scene = new Scene (stackPane );
5959 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 ());
6161
6262 // set title, size, and add scene to stage
6363 stage .setTitle ("Apply Scheduled Updates to Preplanned Map Area" );
@@ -122,7 +122,7 @@ private void checkForScheduledUpdates() {
122122 long updateSize = offlineMapUpdatesInfo .getScheduledUpdatesDownloadSize ();
123123
124124 // 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?" );
126126 alert .setTitle ("Updates Available" );
127127 alert .setHeaderText ("An update is available for this preplanned map area." );
128128
@@ -136,7 +136,7 @@ private void checkForScheduledUpdates() {
136136
137137 } else {
138138 // 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." );
140140 alert .setTitle ("Up to Date" );
141141 alert .setHeaderText ("No updates available." );
142142 alert .show ();
@@ -173,20 +173,20 @@ private void applyScheduledUpdates() {
173173 if (offlineMapSyncJob .getStatus () == Job .Status .SUCCEEDED ) {
174174 OfflineMapSyncResult offlineMapSyncResult = offlineMapSyncJob .getResult ();
175175
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
177177 if (offlineMapSyncResult .isMobileMapPackageReopenRequired ()) {
178178 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 ));
186185 } else {
187186 new Alert (Alert .AlertType .ERROR , "Failed to load the mobile map package." ).show ();
188187 }
189188 });
189+ updatedMobileMapPackage .loadAsync ();
190190 }
191191
192192 // perform another check for updates, to make sure that the newest update was applied
0 commit comments