Merge pull request #427 from maskaravivek/npeFix

Fixes #426: Crash fix caused by NPE
This commit is contained in:
Josephine Lim 2017-03-12 20:41:37 +10:00 committed by GitHub
commit fba9d49938
2 changed files with 10 additions and 3 deletions

View file

@ -312,4 +312,8 @@ public class Utils {
}
return title;
}
public static boolean isNullOrWhiteSpace(String value) {
return value == null || value.trim().isEmpty();
}
}

View file

@ -49,13 +49,16 @@ public class ModificationsSyncAdapter extends AbstractThreadedSyncAdapter {
String authCookie;
try {
authCookie = AccountManager.get(getContext()).blockingGetAuthToken(account, "", false);
} catch (OperationCanceledException e) {
} catch (OperationCanceledException | AuthenticatorException e) {
throw new RuntimeException(e);
} catch (IOException e) {
Log.d("Commons", "Could not authenticate :(");
return;
} catch (AuthenticatorException e) {
throw new RuntimeException(e);
}
if(Utils.isNullOrWhiteSpace(authCookie)) {
Log.d("Commons", "Could not authenticate :(");
return;
}
MWApi api = CommonsApplication.createMWApi();