diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-01-11 03:33:32 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-01-11 03:33:32 +0000 |
commit | e48bb565a5aa871be18cae4003cb781ef6e2e154 (patch) | |
tree | 92efb6bf6b5d9db8f7411c1c6df83e18ccde06b5 /app/src/main/java/User/ParseUserData.java | |
parent | f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2 (diff) | |
download | infinity-for-reddit-e48bb565a5aa871be18cae4003cb781ef6e2e154.tar infinity-for-reddit-e48bb565a5aa871be18cae4003cb781ef6e2e154.tar.gz infinity-for-reddit-e48bb565a5aa871be18cae4003cb781ef6e2e154.tar.bz2 infinity-for-reddit-e48bb565a5aa871be18cae4003cb781ef6e2e154.tar.lz infinity-for-reddit-e48bb565a5aa871be18cae4003cb781ef6e2e154.tar.xz infinity-for-reddit-e48bb565a5aa871be18cae4003cb781ef6e2e154.tar.zst infinity-for-reddit-e48bb565a5aa871be18cae4003cb781ef6e2e154.zip |
View user details in ViewUserDetailActivity. Follow or unfollow user is not properly implemented right now. Change users and subscribed_users databases' schemes. Press Profile in navigation drawer to view my reddit info. Press the username in the post to view that account's info.
Diffstat (limited to '')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java (renamed from app/src/main/java/User/ParseUserData.java) | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/app/src/main/java/User/ParseUserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java index b6a7a39c..12402f03 100644 --- a/app/src/main/java/User/ParseUserData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseUserData.java @@ -1,4 +1,4 @@ -package User; +package ml.docilealligator.infinityforreddit; import android.os.AsyncTask; import android.util.Log; @@ -6,15 +6,15 @@ import android.util.Log; import org.json.JSONException; import org.json.JSONObject; -import ml.docilealligator.infinityforreddit.JSONUtils; +import User.UserData; public class ParseUserData { interface ParseUserDataListener { - void onParseUserDataSuccess(User user); + void onParseUserDataSuccess(UserData userData); void onParseUserDataFail(); } - static void parseMyInfo(String response, ParseUserDataListener parseUserDataListener) { + static void parseUserData(String response, ParseUserDataListener parseUserDataListener) { new ParseUserDataAsyncTask(response, parseUserDataListener).execute(); } @@ -23,15 +23,16 @@ public class ParseUserData { private ParseUserDataListener parseUserDataListener; private boolean parseFailed; - private User user; + private UserData userData; ParseUserDataAsyncTask(String response, ParseUserDataListener parseUserDataListener){ try { + Log.i("response", response); jsonResponse = new JSONObject(response); this.parseUserDataListener = parseUserDataListener; parseFailed = false; } catch (JSONException e) { - Log.i("user data json error", e.getMessage()); + Log.i("userdata json error", e.getMessage()); parseUserDataListener.onParseUserDataFail(); } } @@ -43,7 +44,7 @@ public class ParseUserData { String userName = jsonResponse.getString(JSONUtils.NAME_KEY); String iconImageUrl = jsonResponse.getString(JSONUtils.ICON_IMG_KEY); String bannerImageUrl = ""; - if(!jsonResponse.isNull(JSONUtils.SUBREDDIT_KEY)) { + if(jsonResponse.has(JSONUtils.SUBREDDIT_KEY) && !jsonResponse.isNull(JSONUtils.SUBREDDIT_KEY)) { bannerImageUrl = jsonResponse.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.BANNER_IMG_KEY); } int linkKarma = jsonResponse.getInt(JSONUtils.LINK_KARMA_KEY); @@ -52,7 +53,7 @@ public class ParseUserData { boolean isGold = jsonResponse.getBoolean(JSONUtils.IS_GOLD_KEY); boolean isFriend = jsonResponse.getBoolean(JSONUtils.IS_FRIEND_KEY); - user = new User(userName, iconImageUrl, bannerImageUrl, karma, isGold, isFriend); + userData = new UserData(userName, iconImageUrl, bannerImageUrl, karma, isGold, isFriend); } catch (JSONException e) { parseFailed = true; Log.i("parse user data error", e.getMessage()); @@ -63,7 +64,7 @@ public class ParseUserData { @Override protected void onPostExecute(Void aVoid) { if(!parseFailed) { - parseUserDataListener.onParseUserDataSuccess(user); + parseUserDataListener.onParseUserDataSuccess(userData); } else { parseUserDataListener.onParseUserDataFail(); } |