Skip to content

Commit

Permalink
修复新增评论后回复信息不展示的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Moosphan committed May 7, 2018
1 parent 92ad0c0 commit f7008b5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Window window = getWindow();
WindowManager.LayoutParams params = window.getAttributes();
window.setSoftInputMode(params.SOFT_INPUT_ADJUST_RESIZE);
setContentView(R.layout.activity_main);
initView();
}
Expand Down Expand Up @@ -195,7 +192,7 @@ public void onClick(View view) {
}

/**
* by moos on 2018/04/08
* by moos on 2018/04/20
* func:弹出评论框
*/
private void showCommentDialog(){
Expand All @@ -221,7 +218,7 @@ public void onClick(View view) {

//commentOnWork(commentContent);
dialog.dismiss();
CommentDetailBean detailBean = new CommentDetailBean("小明","http://ucardstorevideo.b0.upaiyun.com/userLogo/9fa13ec6-dddd-46cb-9df0-4bbb32d83fc1.png",commentContent,"刚刚");
CommentDetailBean detailBean = new CommentDetailBean("小明", commentContent,"刚刚");
adapter.addTheCommentData(detailBean);
Toast.makeText(MainActivity.this,"评论成功",Toast.LENGTH_SHORT).show();

Expand Down Expand Up @@ -273,6 +270,7 @@ public void onClick(View view) {
dialog.dismiss();
ReplyDetailBean detailBean = new ReplyDetailBean("小红",replyContent);
adapter.addTheReplyData(detailBean, position);
expandableListView.expandGroup(position);
Toast.makeText(MainActivity.this,"回复成功",Toast.LENGTH_SHORT).show();
}else {
Toast.makeText(MainActivity.this,"回复内容不能为空",Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,12 @@ public void onClick(View view) {
}
}
});
//int replyCount = commentBeanList.get(groupPosition).getReplyList()==null?0:commentBeanList.get(groupPosition).getReplyList().size();

return convertView;
}

@Override
public View getChildView(final int groupPosition, int childPosition, boolean b, View convertView, ViewGroup viewGroup) {
//Log.e(TAG, "getChildView: "+"加载展开子项的布局" );
final ChildHolder childHolder;
if(convertView == null){
convertView = LayoutInflater.from(context).inflate(R.layout.comment_reply_item_layout,viewGroup, false);
Expand Down Expand Up @@ -174,7 +172,6 @@ public ChildHolder(View view) {
tv_content = (TextView) view.findViewById(R.id.reply_item_content);
}
}
BottomSheetDialog dialog;


/**
Expand All @@ -184,7 +181,6 @@ public ChildHolder(View view) {
*/
public void addTheCommentData(CommentDetailBean commentDetailBean){
if(commentDetailBean!=null){
Log.e(TAG, "addTheCommentData: >>>>该刷新评论列表了" );

commentBeanList.add(commentDetailBean);
notifyDataSetChanged();
Expand All @@ -203,14 +199,12 @@ public void addTheReplyData(ReplyDetailBean replyDetailBean, int groupPosition){
if(replyDetailBean!=null){
Log.e(TAG, "addTheReplyData: >>>>该刷新回复列表了:"+replyDetailBean.toString() );
if(commentBeanList.get(groupPosition).getReplyList() != null ){
Log.e(TAG, "addTheReplyData: >>>>>replyList不为空" );
commentBeanList.get(groupPosition).getReplyList().add(replyDetailBean);
}else {
List<ReplyDetailBean> replyList = new ArrayList<>();
replyList.add(replyDetailBean);
commentBeanList.get(groupPosition).setReplyList(replyList);
}

notifyDataSetChanged();
}else {
throw new IllegalArgumentException("回复数据为空!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ public class CommentDetailBean {
private String createDate;
private List<ReplyDetailBean> replyList;

public CommentDetailBean(String nickName, String userLogo, String content, String createDate) {
public CommentDetailBean(String nickName, String content, String createDate) {
this.nickName = nickName;
this.userLogo = userLogo;
this.content = content;
this.createDate = createDate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
/**
* Author: Moos
* E-mail: [email protected]
* Date: 18/4/18.
* Desc: 自定义ExpandableListView,解决与NestedScrollview滑动冲突问题
* Date: 18/4/20.
* Desc: 自定义ExpandableListView,解决与CoordinatorLayout滑动冲突问题
*/

public class CommentExpandableListView extends ExpandableListView implements NestedScrollingChild{
Expand Down

0 comments on commit f7008b5

Please sign in to comment.