restart scraping on activity restore

This commit is contained in:
akaessens 2020-09-05 17:58:13 +02:00
parent 56300d78a3
commit 85e0d1ff24
1 changed files with 20 additions and 3 deletions

View File

@ -52,6 +52,25 @@ public class MainActivity extends AppCompatActivity {
EventAdapter adapter;
LinearLayoutManager linear_layout_manager;
@Override
public void onRestoreInstanceState(Bundle state) {
super.onRestoreInstanceState(state);
if (! state.getBoolean("events_empty") ) {
startScraping();
}
}
@Override
public void onSaveInstanceState(Bundle state) {
super.onSaveInstanceState(state);
state.putBoolean("events_empty", events.isEmpty());
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -214,11 +233,9 @@ public class MainActivity extends AppCompatActivity {
layout_uri_input.setError(null);
}
try {
if (scraper != null) {
scraper.cancel(true);
scraper = null;
} catch (Exception e) {
e.printStackTrace();
}
this.events.clear();