aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-12-02 07:20:29 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-12-02 07:20:29 +0000
commitc213cc0962c13cd8450ea1be89775c40dc7f7f15 (patch)
tree4a348539cca63c0b074e58671103f69aa6442728 /app
parent5c31c21d06cfbf9c2fca0a32ca0d7c185566b625 (diff)
downloadinfinity-for-reddit-c213cc0962c13cd8450ea1be89775c40dc7f7f15.tar
infinity-for-reddit-c213cc0962c13cd8450ea1be89775c40dc7f7f15.tar.gz
infinity-for-reddit-c213cc0962c13cd8450ea1be89775c40dc7f7f15.tar.bz2
infinity-for-reddit-c213cc0962c13cd8450ea1be89775c40dc7f7f15.tar.lz
infinity-for-reddit-c213cc0962c13cd8450ea1be89775c40dc7f7f15.tar.xz
infinity-for-reddit-c213cc0962c13cd8450ea1be89775c40dc7f7f15.tar.zst
infinity-for-reddit-c213cc0962c13cd8450ea1be89775c40dc7f7f15.zip
Fix some NullPointerException.
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditListingDataSource.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java19
2 files changed, 11 insertions, 10 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditListingDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditListingDataSource.java
index 3757cde9..a9dad4b7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditListingDataSource.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditListingDataSource.java
@@ -83,7 +83,7 @@ public class SubredditListingDataSource extends PageKeyedDataSource<String, Subr
this.params = params;
this.callback = callback;
- if (params.key.equals("") || params.key.equals("null")) {
+ if (params.key == null || params.key.equals("") || params.key.equals("null")) {
return;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java
index 8e56b3ab..5416e056 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/user/ParseUserData.java
@@ -70,28 +70,29 @@ public class ParseUserData {
private static class ParseUserDataAsyncTask extends AsyncTask<Void, Void, Void> {
private JSONObject jsonResponse;
private ParseUserDataListener parseUserDataListener;
- private boolean parseFailed;
+ private boolean parseFailed = false;
private UserData userData;
ParseUserDataAsyncTask(String response, ParseUserDataListener parseUserDataListener) {
+ this.parseUserDataListener = parseUserDataListener;
try {
jsonResponse = new JSONObject(response);
- this.parseUserDataListener = parseUserDataListener;
- parseFailed = false;
} catch (JSONException e) {
+ parseFailed = true;
e.printStackTrace();
- parseUserDataListener.onParseUserDataFailed();
}
}
@Override
protected Void doInBackground(Void... voids) {
- try {
- userData = parseUserDataBase(jsonResponse, true);
- } catch (JSONException e) {
- parseFailed = true;
- e.printStackTrace();
+ if (!parseFailed) {
+ try {
+ userData = parseUserDataBase(jsonResponse, true);
+ } catch (JSONException e) {
+ parseFailed = true;
+ e.printStackTrace();
+ }
}
return null;
}