diff --git a/app/src/main/java/com/akdev/nofbeventscraper/FbScraper.java b/app/src/main/java/com/akdev/nofbeventscraper/FbScraper.java index f05b67b..295d86d 100644 --- a/app/src/main/java/com/akdev/nofbeventscraper/FbScraper.java +++ b/app/src/main/java/com/akdev/nofbeventscraper/FbScraper.java @@ -131,9 +131,14 @@ public class FbScraper { * cancel vestigial async tasks */ void killAllTasks() { - for (AsyncTask task : tasks) { - task.cancel(true); - task = null; + + try { + for (AsyncTask task : tasks) { + task.cancel(true); + task = null; + } + } catch (Exception e) { + e.printStackTrace(); } } diff --git a/app/src/main/java/com/akdev/nofbeventscraper/MainActivity.java b/app/src/main/java/com/akdev/nofbeventscraper/MainActivity.java index cc48272..113d575 100644 --- a/app/src/main/java/com/akdev/nofbeventscraper/MainActivity.java +++ b/app/src/main/java/com/akdev/nofbeventscraper/MainActivity.java @@ -172,7 +172,9 @@ public class MainActivity extends AppCompatActivity { public void onClick(View view) { input_helper(getString(R.string.helper_add_link), true); edit_text_uri_input.setText(null); - scraper.killAllTasks(); + if (scraper != null) { + scraper.killAllTasks(); + } input_helper(getString(R.string.helper_add_link), false); } };