Minor bugs fixed in parsing user data.

This commit is contained in:
Docile-Alligator
2025-09-18 13:33:25 -04:00
parent 1b7342cde9
commit 8c752ca584

View File

@ -132,10 +132,19 @@ public class FetchUserData {
String iconImageUrl = userDataJson.getString(JSONUtils.ICON_IMG_KEY);
String bannerImageUrl = "";
boolean canBeFollowed;
boolean isNsfw;
String description;
String title;
if (userDataJson.has(JSONUtils.SUBREDDIT_KEY) && !userDataJson.isNull(JSONUtils.SUBREDDIT_KEY)) {
bannerImageUrl = userDataJson.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.BANNER_IMG_KEY);
isNsfw = userDataJson.getJSONObject(JSONUtils.SUBREDDIT_KEY).getBoolean(JSONUtils.OVER_18_KEY);
description = userDataJson.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.PUBLIC_DESCRIPTION_KEY);
title = userDataJson.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.TITLE_KEY);
canBeFollowed = true;
} else {
isNsfw = false;
description = "";
title = "";
canBeFollowed = false;
}
int linkKarma = userDataJson.getInt(JSONUtils.LINK_KARMA_KEY);
@ -151,9 +160,6 @@ public class FetchUserData {
long cakeday = userDataJson.getLong(JSONUtils.CREATED_UTC_KEY) * 1000;
boolean isGold = userDataJson.getBoolean(JSONUtils.IS_GOLD_KEY);
boolean isFriend = userDataJson.getBoolean(JSONUtils.IS_FRIEND_KEY);
boolean isNsfw = userDataJson.getJSONObject(JSONUtils.SUBREDDIT_KEY).getBoolean(JSONUtils.OVER_18_KEY);
String description = userDataJson.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.PUBLIC_DESCRIPTION_KEY);
String title = userDataJson.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.TITLE_KEY);
boolean isMod = userDataJson.getBoolean(JSONUtils.IS_MOD_KEY);
return new UserData(userName, iconImageUrl, bannerImageUrl, linkKarma, commentKarma, awarderKarma,