@Override public void onBackPressed() { if (mEnterLayout.isEnterPanelShowing()) { mEnterLayout.closeEnterPanel(); return; } super.onBackPressed(); }
@OnActivityResult(RESULT_REQUEST_AT) void onResultAt(int requestCode, Intent data) { if (requestCode == Activity.RESULT_OK) { String name = data.getStringExtra("name"); mEnterLayout.insertText(name); } }
void prepareAddComment(Object data, boolean popKeyboard) { Maopao.Comment comment = null; EditText content = mEnterLayout.content; if (data instanceof Maopao.Comment) { comment = (Maopao.Comment) data; content.setHint("回复 " + comment.owner.name); content.setTag(comment); } else if (data instanceof Maopao.MaopaoObject) { comment = new Maopao.Comment((Maopao.MaopaoObject) data); content.setHint("评论冒泡"); content.setTag(comment); } mEnterLayout.restoreLoad(comment); if (popKeyboard) { content.requestFocus(); Global.popSoftkeyboard(MaopaoDetailActivity.this, content, true); } }
void action_share_third() { mEnterLayout.hideKeyboard(); CustomShareBoard.ShareData shareData = new CustomShareBoard.ShareData(mMaopaoObject); CustomShareBoard shareBoard = new CustomShareBoard(this, shareData); shareBoard.showAtLocation(getWindow().getDecorView(), Gravity.BOTTOM, 0, 0); }
@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(); } } }