Skip to content

Commit

Permalink
add try/catch for RejectedExecutionException (related to #8402)
Browse files Browse the repository at this point in the history
  • Loading branch information
moving-bits committed Oct 8, 2020
1 parent 5e624c1 commit d08a9e4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions main/src/cgeo/geocaching/maps/CGeoMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -908,10 +909,14 @@ private void routingModeChanged() {
Toast.makeText(activity, R.string.brouter_recalculating, Toast.LENGTH_SHORT).show();
manualRoute.reloadRoute(overlayPositionAndScale);
if (null != tracks) {
AndroidRxUtils.andThenOnUi(Schedulers.computation(), () -> {
tracks.calculateNavigationRoute();
((GooglePositionAndHistory) overlayPositionAndScale).updateRoute(tracks);
}, () -> mapView.repaintRequired(overlayPositionAndScale instanceof GeneralOverlay ? ((GeneralOverlay) overlayPositionAndScale) : null));
try {
AndroidRxUtils.andThenOnUi(Schedulers.computation(), () -> {
tracks.calculateNavigationRoute();
((GooglePositionAndHistory) overlayPositionAndScale).updateRoute(tracks);
}, () -> mapView.repaintRequired(overlayPositionAndScale instanceof GeneralOverlay ? ((GeneralOverlay) overlayPositionAndScale) : null));
} catch (RejectedExecutionException e) {
Log.e("CGeoMap.routingModeChanged: RejectedExecutionException: " + e.getMessage());
}
}
mapView.repaintRequired(overlayPositionAndScale instanceof GeneralOverlay ? ((GeneralOverlay) overlayPositionAndScale) : null);
}
Expand Down
13 changes: 9 additions & 4 deletions main/src/cgeo/geocaching/maps/mapsforge/v6/NewMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.RejectedExecutionException;

import io.reactivex.rxjava3.disposables.CompositeDisposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
Expand Down Expand Up @@ -507,10 +508,14 @@ private void routingModeChanged() {
Toast.makeText(this, R.string.brouter_recalculating, Toast.LENGTH_SHORT).show();
manualRoute.reloadRoute(routeLayer);
if (null != tracks) {
AndroidRxUtils.andThenOnUi(Schedulers.computation(), () -> {
tracks.calculateNavigationRoute();
trackLayer.updateRoute(tracks);
}, () -> trackLayer.requestRedraw());
try {
AndroidRxUtils.andThenOnUi(Schedulers.computation(), () -> {
tracks.calculateNavigationRoute();
trackLayer.updateRoute(tracks);
}, () -> trackLayer.requestRedraw());
} catch (RejectedExecutionException e) {
Log.e("NewMap.routingModeChanged: RejectedExecutionException: " + e.getMessage());
}
}
navigationLayer.requestRedraw();
}
Expand Down

0 comments on commit d08a9e4

Please sign in to comment.