From e48bb565a5aa871be18cae4003cb781ef6e2e154 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 11 Jan 2019 11:33:32 +0800 Subject: 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. --- app/src/main/java/User/ParseUserData.java | 72 ------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 app/src/main/java/User/ParseUserData.java (limited to 'app/src/main/java/User/ParseUserData.java') diff --git a/app/src/main/java/User/ParseUserData.java b/app/src/main/java/User/ParseUserData.java deleted file mode 100644 index b6a7a39c..00000000 --- a/app/src/main/java/User/ParseUserData.java +++ /dev/null @@ -1,72 +0,0 @@ -package User; - -import android.os.AsyncTask; -import android.util.Log; - -import org.json.JSONException; -import org.json.JSONObject; - -import ml.docilealligator.infinityforreddit.JSONUtils; - -public class ParseUserData { - interface ParseUserDataListener { - void onParseUserDataSuccess(User user); - void onParseUserDataFail(); - } - - static void parseMyInfo(String response, ParseUserDataListener parseUserDataListener) { - new ParseUserDataAsyncTask(response, parseUserDataListener).execute(); - } - - private static class ParseUserDataAsyncTask extends AsyncTask { - private JSONObject jsonResponse; - private ParseUserDataListener parseUserDataListener; - private boolean parseFailed; - - private User user; - - ParseUserDataAsyncTask(String response, ParseUserDataListener parseUserDataListener){ - try { - jsonResponse = new JSONObject(response); - this.parseUserDataListener = parseUserDataListener; - parseFailed = false; - } catch (JSONException e) { - Log.i("user data json error", e.getMessage()); - parseUserDataListener.onParseUserDataFail(); - } - } - - @Override - protected Void doInBackground(Void... voids) { - try { - jsonResponse = jsonResponse.getJSONObject(JSONUtils.DATA_KEY); - String userName = jsonResponse.getString(JSONUtils.NAME_KEY); - String iconImageUrl = jsonResponse.getString(JSONUtils.ICON_IMG_KEY); - String bannerImageUrl = ""; - if(!jsonResponse.isNull(JSONUtils.SUBREDDIT_KEY)) { - bannerImageUrl = jsonResponse.getJSONObject(JSONUtils.SUBREDDIT_KEY).getString(JSONUtils.BANNER_IMG_KEY); - } - int linkKarma = jsonResponse.getInt(JSONUtils.LINK_KARMA_KEY); - int commentKarma = jsonResponse.getInt(JSONUtils.COMMENT_KARMA_KEY); - int karma = linkKarma + commentKarma; - 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); - } catch (JSONException e) { - parseFailed = true; - Log.i("parse user data error", e.getMessage()); - } - return null; - } - - @Override - protected void onPostExecute(Void aVoid) { - if(!parseFailed) { - parseUserDataListener.onParseUserDataSuccess(user); - } else { - parseUserDataListener.onParseUserDataFail(); - } - } - } -} -- cgit v1.2.3