prevent nullpointer exception on tests

This commit is contained in:
akaessens 2020-08-28 21:13:21 +02:00
parent ec62cb6347
commit 793a9e3549
1 changed files with 13 additions and 7 deletions

View File

@ -64,8 +64,12 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
if (matcher.find()) { if (matcher.find()) {
SharedPreferences shared_prefs = PreferenceManager.getDefaultSharedPreferences(main.get()); String url_prefix = "https://m.";
String url_prefix = shared_prefs.getString("url_preference", "m.facebook.com"); if (main != null){
SharedPreferences shared_prefs = PreferenceManager.getDefaultSharedPreferences(main.get());
url_prefix = shared_prefs.getString("url_preference", url_prefix);
}
// rewrite url to m.facebook and dismiss any query strings or referrals // rewrite url to m.facebook and dismiss any query strings or referrals
String ret = url_prefix + matcher.group(1); String ret = url_prefix + matcher.group(1);
if (matcher.group(2) != null) { if (matcher.group(2) != null) {
@ -233,11 +237,13 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
protected void onPostExecute(Void aVoid) { protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid); super.onPostExecute(aVoid);
if (this.event != null) { if (main != null) {
main.get().update(event); if (this.event != null) {
} else { main.get().update(event);
main.get().error(error); } else {
main.get().clear(false); main.get().error(error);
main.get().clear(false);
}
} }
} }
} }