Skip to content

Commit f7008b5

Browse files
committed
修复新增评论后回复信息不展示的问题
1 parent 92ad0c0 commit f7008b5

4 files changed

Lines changed: 6 additions & 15 deletions

File tree

CommentWithReplyList/app/src/main/java/com/moos/example/MainActivity.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
100100
@Override
101101
protected void onCreate(Bundle savedInstanceState) {
102102
super.onCreate(savedInstanceState);
103-
Window window = getWindow();
104-
WindowManager.LayoutParams params = window.getAttributes();
105-
window.setSoftInputMode(params.SOFT_INPUT_ADJUST_RESIZE);
106103
setContentView(R.layout.activity_main);
107104
initView();
108105
}
@@ -195,7 +192,7 @@ public void onClick(View view) {
195192
}
196193

197194
/**
198-
* by moos on 2018/04/08
195+
* by moos on 2018/04/20
199196
* func:弹出评论框
200197
*/
201198
private void showCommentDialog(){
@@ -221,7 +218,7 @@ public void onClick(View view) {
221218

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

@@ -273,6 +270,7 @@ public void onClick(View view) {
273270
dialog.dismiss();
274271
ReplyDetailBean detailBean = new ReplyDetailBean("小红",replyContent);
275272
adapter.addTheReplyData(detailBean, position);
273+
expandableListView.expandGroup(position);
276274
Toast.makeText(MainActivity.this,"回复成功",Toast.LENGTH_SHORT).show();
277275
}else {
278276
Toast.makeText(MainActivity.this,"回复内容不能为空",Toast.LENGTH_SHORT).show();

CommentWithReplyList/app/src/main/java/com/moos/example/adapter/CommentExpandAdapter.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,12 @@ public void onClick(View view) {
119119
}
120120
}
121121
});
122-
//int replyCount = commentBeanList.get(groupPosition).getReplyList()==null?0:commentBeanList.get(groupPosition).getReplyList().size();
123122

124123
return convertView;
125124
}
126125

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

179176

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

189185
commentBeanList.add(commentDetailBean);
190186
notifyDataSetChanged();
@@ -203,14 +199,12 @@ public void addTheReplyData(ReplyDetailBean replyDetailBean, int groupPosition){
203199
if(replyDetailBean!=null){
204200
Log.e(TAG, "addTheReplyData: >>>>该刷新回复列表了:"+replyDetailBean.toString() );
205201
if(commentBeanList.get(groupPosition).getReplyList() != null ){
206-
Log.e(TAG, "addTheReplyData: >>>>>replyList不为空" );
207202
commentBeanList.get(groupPosition).getReplyList().add(replyDetailBean);
208203
}else {
209204
List<ReplyDetailBean> replyList = new ArrayList<>();
210205
replyList.add(replyDetailBean);
211206
commentBeanList.get(groupPosition).setReplyList(replyList);
212207
}
213-
214208
notifyDataSetChanged();
215209
}else {
216210
throw new IllegalArgumentException("回复数据为空!");

CommentWithReplyList/app/src/main/java/com/moos/example/bean/CommentDetailBean.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ public class CommentDetailBean {
1616
private String createDate;
1717
private List<ReplyDetailBean> replyList;
1818

19-
public CommentDetailBean(String nickName, String userLogo, String content, String createDate) {
19+
public CommentDetailBean(String nickName, String content, String createDate) {
2020
this.nickName = nickName;
21-
this.userLogo = userLogo;
2221
this.content = content;
2322
this.createDate = createDate;
2423
}

CommentWithReplyList/app/src/main/java/com/moos/example/view/CommentExpandableListView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
/**
1010
* Author: Moos
1111
* E-mail: moosphon@gmail.com
12-
* Date: 18/4/18.
13-
* Desc: 自定义ExpandableListView,解决与NestedScrollview滑动冲突问题
12+
* Date: 18/4/20.
13+
* Desc: 自定义ExpandableListView,解决与CoordinatorLayout滑动冲突问题
1414
*/
1515

1616
public class CommentExpandableListView extends ExpandableListView implements NestedScrollingChild{

0 commit comments

Comments
 (0)