remove possibly fragile task counter dependent output
This commit is contained in:
parent
a8baabdb5f
commit
8335ffeada
|
@ -20,7 +20,6 @@ public class FbScraper {
|
||||||
|
|
||||||
protected List<FbEvent> events;
|
protected List<FbEvent> events;
|
||||||
protected List<AsyncTask> tasks;
|
protected List<AsyncTask> tasks;
|
||||||
int remaining_events = 0;
|
|
||||||
url_type_enum url_type = url_type_enum.EVENT;
|
url_type_enum url_type = url_type_enum.EVENT;
|
||||||
private String input_url;
|
private String input_url;
|
||||||
private WeakReference<MainActivity> main; // no context leak with WeakReference
|
private WeakReference<MainActivity> main; // no context leak with WeakReference
|
||||||
|
@ -107,24 +106,12 @@ public class FbScraper {
|
||||||
|
|
||||||
void scrapeEventResultCallback(FbEvent event, int error) {
|
void scrapeEventResultCallback(FbEvent event, int error) {
|
||||||
|
|
||||||
if (url_type == url_type_enum.EVENT) {
|
|
||||||
if (event != null) {
|
if (event != null) {
|
||||||
main.get().addEvent(event);
|
main.get().addEvent(event);
|
||||||
main.get().input_helper(main.get().getString(R.string.done), false);
|
main.get().input_helper(main.get().getString(R.string.done), false);
|
||||||
} else {
|
} else if (url_type == url_type_enum.EVENT) {
|
||||||
main.get().input_helper(main.get().getString(error), true);
|
main.get().input_helper(main.get().getString(error), true);
|
||||||
}
|
}
|
||||||
killAllTasks();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
main.get().addEvent(event);
|
|
||||||
remaining_events--;
|
|
||||||
|
|
||||||
if (remaining_events <= 0) {
|
|
||||||
main.get().input_helper(main.get().getString(R.string.done), false);
|
|
||||||
killAllTasks();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,8 +139,7 @@ public class FbScraper {
|
||||||
protected void scrapePageResultCallback(List<String> event_urls, int error) {
|
protected void scrapePageResultCallback(List<String> event_urls, int error) {
|
||||||
|
|
||||||
if (event_urls.size() > 0) {
|
if (event_urls.size() > 0) {
|
||||||
remaining_events = event_urls.size();
|
|
||||||
main.get().input_helper(main.get().getString(R.string.found_events, event_urls.size()), false);
|
|
||||||
for (String event_url : event_urls) {
|
for (String event_url : event_urls) {
|
||||||
try {
|
try {
|
||||||
String url = getEventUrl(event_url);
|
String url = getEventUrl(event_url);
|
||||||
|
@ -162,7 +148,7 @@ public class FbScraper {
|
||||||
// ignore this event
|
// ignore this event
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (url_type == url_type_enum.PAGE) {
|
} else {
|
||||||
main.get().input_helper(main.get().getString(error), true);
|
main.get().input_helper(main.get().getString(error), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,5 +19,4 @@
|
||||||
<string name="preferences_event_setting">Veranstaltungsliste löschen</string>
|
<string name="preferences_event_setting">Veranstaltungsliste löschen</string>
|
||||||
<string name="preferences_event_snackbar">"Veranstaltungen gelöscht "</string>
|
<string name="preferences_event_snackbar">"Veranstaltungen gelöscht "</string>
|
||||||
<string name="done">Fertig</string>
|
<string name="done">Fertig</string>
|
||||||
<string name="found_events">%1$d Veranstaltungen gefunden</string>
|
|
||||||
</resources>
|
</resources>
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
<!-- Input hints -->
|
<!-- Input hints -->
|
||||||
<string name="hint_add_link">Event link</string>
|
<string name="hint_add_link">Event link</string>
|
||||||
|
<string name="done">Done</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="helper_add_link">Paste Facebook link to the event</string>
|
<string name="helper_add_link">Paste Facebook link to the event</string>
|
||||||
|
@ -21,6 +22,8 @@
|
||||||
<string name="error_connection">Error: Unable to connect</string>
|
<string name="error_connection">Error: Unable to connect</string>
|
||||||
<string name="error_unknown">Error: Unknown Error</string>
|
<string name="error_unknown">Error: Unknown Error</string>
|
||||||
|
|
||||||
|
<string name="event_placeholder" translatable="false">Placeholder</string>
|
||||||
|
|
||||||
<!-- Preferences -->
|
<!-- Preferences -->
|
||||||
<string name="preferences_scraper_header" translatable="false">Scraper</string>
|
<string name="preferences_scraper_header" translatable="false">Scraper</string>
|
||||||
<string name="preferences_url_setting">Which URL prefix to use</string>
|
<string name="preferences_url_setting">Which URL prefix to use</string>
|
||||||
|
@ -29,8 +32,5 @@
|
||||||
<string name="preferences_events_header">Events</string>
|
<string name="preferences_events_header">Events</string>
|
||||||
<string name="preferences_event_setting">Clear event list</string>
|
<string name="preferences_event_setting">Clear event list</string>
|
||||||
<string name="preferences_event_snackbar">Events list cleared</string>
|
<string name="preferences_event_snackbar">Events list cleared</string>
|
||||||
<string name="event_placeholder" translatable="false">Placeholder</string>
|
|
||||||
<string name="done">Done</string>
|
|
||||||
<string name="found_events">Found %1$d events</string>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue