protected String getLink() { if (mMaopaoObject == null) { return ""; } else { return mMaopaoObject.getLink(); } }
@Override public void parseJson(int code, JSONObject respanse, String tag, int pos, Object data) throws JSONException { if (tag.equals(URI_COMMENT)) { swipeRefreshLayout.setRefreshing(false); if (code == 0) { mData.clear(); JSONArray jsonArray = respanse.getJSONObject("data").getJSONArray("list"); for (int i = 0; i < jsonArray.length(); ++i) { Maopao.Comment comment = new Maopao.Comment(jsonArray.getJSONObject(i)); mData.add(comment); } if (mModifyComment) { mMaopaoObject.comments = mData.size(); mMaopaoObject.comment_list = mData; Intent intent = new Intent(); intent.putExtra(ListModify.DATA, mMaopaoObject); intent.putExtra(ListModify.TYPE, ListModify.Edit); setResult(Activity.RESULT_OK, intent); } adapter.notifyDataSetChanged(); } else { showErrorMsg(code, respanse); } } else if (tag.equals(ADD_COMMENT)) { showProgressBar(false); if (code == 0) { umengEvent(UmengEvent.MAOPAO, "添加冒泡评论"); getNetwork(URI_COMMENT, URI_COMMENT); mEnterLayout.restoreDelete(data); mEnterLayout.clearContent(); mEnterLayout.hideKeyboard(); mModifyComment = true; } else { showErrorMsg(code, respanse); } } else if (tag.equals(HOST_GOOD)) { if (code == 0) { Maopao.MaopaoObject maopao = mMaopaoObject; maopao.liked = !maopao.liked; if (maopao.liked) { umengEvent(UmengEvent.MAOPAO, "冒泡点赞"); Maopao.Like_user like_user = new Maopao.Like_user(MyApp.sUserObject); maopao.like_users.add(0, like_user); ++maopao.likes; } else { umengEvent(UmengEvent.MAOPAO, "冒泡取消点赞"); for (int j = 0; j < maopao.like_users.size(); ++j) { if (maopao.like_users.get(j).global_key.equals(MyApp.sUserObject.global_key)) { maopao.like_users.remove(j); --maopao.likes; break; } } } likeUsersArea.displayLikeUser(); Intent intent = new Intent(); intent.putExtra(ListModify.DATA, mMaopaoObject); intent.putExtra(ListModify.TYPE, ListModify.Edit); setResult(Activity.RESULT_OK, intent); } else { showErrorMsg(code, respanse); } likeBtn.setChecked(mMaopaoObject.liked); } else if (tag.equals(maopaoUrl)) { if (code == 0) { mMaopaoObject = new Maopao.MaopaoObject(respanse.getJSONObject("data")); initData(); } else { mMaopaoObject = mMaopaoObjectOld; swipeRefreshLayout.setRefreshing(false); showErrorMsg(code, respanse); } } else if (tag.equals(URI_COMMENT_DELETE)) { if (code == 0) { mModifyComment = true; getNetwork(URI_COMMENT, URI_COMMENT); } else { showErrorMsg(code, respanse); } } else if (tag.equals(TAG_DELETE_MAOPAO)) { if (code == 0) { Intent intent = new Intent(); intent.putExtra(ListModify.TYPE, ListModify.Delete); intent.putExtra(ListModify.ID, mMaopaoObject.id); setResult(Activity.RESULT_OK, intent); finish(); } else { showErrorMsg(code, respanse); } } else if (tag.equals(TAG_LIKE_USERS)) { if (code == 0) { JSONObject jsonData = respanse.getJSONObject("data"); JSONArray jsonArray = jsonData.getJSONArray("list"); for (int i = 0; i < jsonArray.length(); ++i) { Maopao.Like_user user = new Maopao.Like_user(jsonArray.getJSONObject(i)); mMaopaoObject.like_users.add(user); } likeUsersArea.displayLikeUser(); } } }