mirror of
https://github.com/akaessens/NoFbEventScraper
synced 2025-06-05 23:29:13 +02:00
fix nullptr crash on killing asyncs
This commit is contained in:
@ -131,10 +131,15 @@ public class FbScraper {
|
||||
* cancel vestigial async tasks
|
||||
*/
|
||||
void killAllTasks() {
|
||||
|
||||
try {
|
||||
for (AsyncTask task : tasks) {
|
||||
task.cancel(true);
|
||||
task = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
void scrapePage(String page_url) {
|
||||
|
@ -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);
|
||||
if (scraper != null) {
|
||||
scraper.killAllTasks();
|
||||
}
|
||||
input_helper(getString(R.string.helper_add_link), false);
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user