From bf552a92193e646d7ce9f74a52a639eeb1f6b4e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rom=C3=A1n=20Mart=C3=ADnez?= Date: Sun, 25 Apr 2021 17:28:43 +0200 Subject: [PATCH] Bugfix: crash deleting when activity restarts. Fixes #705. --- .../opentracks/TrackDeleteActivity.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/dennisguse/opentracks/TrackDeleteActivity.java b/src/main/java/de/dennisguse/opentracks/TrackDeleteActivity.java index 3ccbbd74a9..5ed156b236 100644 --- a/src/main/java/de/dennisguse/opentracks/TrackDeleteActivity.java +++ b/src/main/java/de/dennisguse/opentracks/TrackDeleteActivity.java @@ -64,12 +64,21 @@ public void onCreate(Bundle savedInstanceState) { runOnUiThread(TrackDeleteActivity.this::onAsyncTaskCompleted); }); + deleteThread.start(); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + viewBinding = null; } @Override protected void onStart() { super.onStart(); - deleteThread.start(); + if (deleteThread.getState() == Thread.State.TERMINATED) { + onAsyncTaskCompleted(); + } } @Override @@ -78,12 +87,6 @@ protected void onStop() { deleteThread.interrupt(); } - @Override - protected void onDestroy() { - super.onDestroy(); - viewBinding = null; - } - @Override protected View getRootView() { viewBinding = TrackDeleteBinding.inflate(getLayoutInflater());