fix nullptr crash on killing asyncs
This commit is contained in:
parent
5e7d9bc4dc
commit
2e1b20051a
|
@ -131,9 +131,14 @@ public class FbScraper {
|
||||||
* cancel vestigial async tasks
|
* cancel vestigial async tasks
|
||||||
*/
|
*/
|
||||||
void killAllTasks() {
|
void killAllTasks() {
|
||||||
for (AsyncTask task : tasks) {
|
|
||||||
task.cancel(true);
|
try {
|
||||||
task = null;
|
for (AsyncTask task : tasks) {
|
||||||
|
task.cancel(true);
|
||||||
|
task = null;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,9 @@ public class MainActivity extends AppCompatActivity {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
input_helper(getString(R.string.helper_add_link), true);
|
input_helper(getString(R.string.helper_add_link), true);
|
||||||
edit_text_uri_input.setText(null);
|
edit_text_uri_input.setText(null);
|
||||||
scraper.killAllTasks();
|
if (scraper != null) {
|
||||||
|
scraper.killAllTasks();
|
||||||
|
}
|
||||||
input_helper(getString(R.string.helper_add_link), false);
|
input_helper(getString(R.string.helper_add_link), false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue