private void bindData(PostDetailEntity result, boolean afterFollow) { mPostDetailEntity = result; if (result.postDetail.user.uid == ApplicationVariable.INSTANCE.getUapUid() && result.postDetail.picked != PostEntity.C_TAG_PICKED && result.postDetail.stamp != PostEntity.C_TAG_JAY && System.currentTimeMillis() - result.postDetail.post_time < 5 * TimeUtil.MS_MINUTE) { mCommonActivityTitle.showRightBtn(); mCommonActivityTitle.setRightBtnEnabel(true); mCommonActivityTitle.setRightBtnText("删除"); mCommonActivityTitle.setRightBtnWidth(Helper.dip2px(mContext, 50)); } if (result.newestFollows != null) { mFollow_num = result.newestFollows.total; } mReply_num = result.postDetail.reply_num; mPraise_done = result.postDetail.praise_done; mPraise_num = result.postDetail.praise_num; // mTvPraise.setText(Util.getLove(mPraise_num)); mTvComment.setText(Util.getLove(mReply_num)); setPraiseData(mPraise_done, mPraise_num); // TODO进入帖子详情,获取到数量时就更新列表数量 EventBus.getDefault().post(new PraiseEventBean(mMainId, mPraise_num, mPraise_done)); // if (mPraise_done == PostEntity.C_PRAISE_DONE) { // mIvPraise.setImageResource(R.drawable.big_image_like_click); // } else { // mIvPraise.setImageResource(R.drawable.big_image_like_normal); // } if (mAdapter == null) { mAdapter = new PostDetailExpandAdapter(mContext, mListView, result); mAdapter.addFootView(vMorePick); mListView.setAdapter(mAdapter); } else { mAdapter.setData(result); mAdapter.notifyDataSetChanged(); } mBtnMore.setOnClickListener(this); if (mFollow_num > 10) { mBtnMore.setVisibility(View.VISIBLE); mBtnMore.setText( getResources().getString(R.string.forum_postdetail_loadmore, (mFollow_num - 10))); } else { mBtnMore.setVisibility(View.GONE); } for (int i = 0; i < mAdapter.getGroupCount(); i++) { mListView.expandGroup(i); } if (afterFollow) { mAdapter.scrollByFirstUid(ApplicationVariable.INSTANCE.getUapUid()); } }
@Override public void onFinish() { if (isFinish) return; isFinish = true; mListView = null; mInputBar = null; EventBus.getDefault().unregister(this); if (mAdapter != null) { mAdapter.onFinish(); mAdapter = null; } shutdownExecutorService(); }
public void onEventMainThread(VoiceEventBusBean bean) { // android.util.Log.e("cp:", "eventbus---PostDetail"); if (bean == null) return; if (BeanConst.DETAIL_REPLYFOLLOW.equals(bean.getStrAction())) { // 显示回复界面(评论跟帖) switchTestOnlyMode(); mReplyFollowInfo = (PostEntity) bean.getValue(BeanConst.DETAIL_REPLYFOLLOW); replyType = 1; if (mReplyInfo.user.uid != ApplicationVariable.INSTANCE.getUapUid()) { mEditText.setHint( getResources().getString(R.string.forum_reply, ":", mReplyFollowInfo.user.nickname)); } else { mEditText.setHint(""); } } else if (BeanConst.DETAIL_REPLYCOMMENT.equals(bean.getStrAction())) { // 显示回复界面(回复评论 switchTestOnlyMode(); mReplyInfo = (ReplyInfo) bean.getValue(BeanConst.DETAIL_REPLYCOMMENT); replyType = 2; if (mReplyInfo.user.uid != ApplicationVariable.INSTANCE.getUapUid()) { mEditText.setHint( getResources().getString(R.string.forum_reply, mReplyInfo.user.nickname, ":")); } else { mEditText.setHint(""); } } else if (BeanConst.REPLY_ADD.equals(bean.getStrAction())) { long tidReply = (Long) bean.getValue(BeanConst.TID); if (mMainId == tidReply) { mReply_num++; } if (mTvComment != null) { mTvComment.setText(Util.getLove(mReply_num)); } } else if (BeanConst.FOLLOW_INFO.equals(bean.getStrAction())) { // 跟帖信息更新 // fix BUG #56148 // 【48030】【论坛】赞操作:跟帖中,其他用户对帖子赞,本赞用户数据无法及时更新(即从跟帖详情页面回到帖子详情页面不会刷新数据) long followId = (Long) bean.getValue(BeanConst.FOLLOW_ID); long postMainId = (Long) bean.getValue(BeanConst.POST_MAIN_ID); PostFollowEntity postFollowEntity = (PostFollowEntity) bean.getValue(BeanConst.FOLLOW_ENTITY); Iterator<PostFollowEntity> postFollowEntityIterator = mPostDetailEntity.newestFollows.followList.iterator(); long praiseChange = 0; long commonChange = 0; for (; postFollowEntityIterator.hasNext(); ) { PostFollowEntity entity = postFollowEntityIterator.next(); if (entity.postinfo.tid == followId && entity.type != PostFollowEntity.JAY) { // 更新点赞数 praiseChange = postFollowEntity.postinfo.praise_num - entity.postinfo.praise_num; entity.postinfo.praise_num = postFollowEntity.postinfo.praise_num; // 更新点踩数 entity.postinfo.c_num = postFollowEntity.postinfo.c_num; // 更新评论数 commonChange = postFollowEntity.postinfo.reply_num - entity.postinfo.reply_num; entity.postinfo.reply_num = postFollowEntity.postinfo.reply_num; if (0 != commonChange) { final int orginalSize = entity.replyInfoList.size(); if (2 > orginalSize) { // 原来小于2,增加评论回帖的内容 final int currSize = postFollowEntity.replyInfoList.replyList.size(); int index = 0; while ((index + orginalSize < 2) && (index < currSize)) { ReplyInfo info = postFollowEntity.replyInfoList.replyList.get(index); Iterator<ReplyInfo> replyInfoIterator = entity.replyInfoList.replyList.iterator(); int count = 0; for (; replyInfoIterator.hasNext(); ) { ReplyInfo existReplyInfo = replyInfoIterator.next(); if (existReplyInfo.floor_id == info.floor_id) { break; } else { count++; } } if (count == entity.replyInfoList.replyList.size()) { entity.replyInfoList.add(info); } index++; } } } mAdapter.notifyDataSetChanged(); } } // 主贴点赞数目更新 mPraise_num += praiseChange; mTvPraise.setText(Util.getLove(mPraise_num)); // TODO同时通知列表更新点赞数 EventBus.getDefault().post(new PraiseEventBean(mMainId, mPraise_num, mPraise_done)); // 主贴评论数目更新 mReply_num += commonChange; mTvComment.setText(Util.getLove(mReply_num)); // 同时通知列表更新评论数 VoiceEventBusBean updateReplyBean = new VoiceEventBusBean(); updateReplyBean.setStrAction(BeanConst.REPLY_NUMBER_UPDATE); updateReplyBean.addValue(BeanConst.POST_MAIN_ID, mMainId); updateReplyBean.addValue(BeanConst.REPLY_NUMBER, mReply_num); EventBus.getDefault().post(updateReplyBean); } }