From f7008b517d2eca91b7bf90c1f79279da10f143a8 Mon Sep 17 00:00:00 2001 From: suhao <2301230182@qq.com> Date: Mon, 7 May 2018 10:21:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=B0=E5=A2=9E=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E5=90=8E=E5=9B=9E=E5=A4=8D=E4=BF=A1=E6=81=AF=E4=B8=8D?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/src/main/java/com/moos/example/MainActivity.java | 8 +++----- .../com/moos/example/adapter/CommentExpandAdapter.java | 6 ------ .../java/com/moos/example/bean/CommentDetailBean.java | 3 +-- .../com/moos/example/view/CommentExpandableListView.java | 4 ++-- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/CommentWithReplyList/app/src/main/java/com/moos/example/MainActivity.java b/CommentWithReplyList/app/src/main/java/com/moos/example/MainActivity.java index dde4bf9..cb661f5 100644 --- a/CommentWithReplyList/app/src/main/java/com/moos/example/MainActivity.java +++ b/CommentWithReplyList/app/src/main/java/com/moos/example/MainActivity.java @@ -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(); } @@ -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(){ @@ -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(); @@ -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(); diff --git a/CommentWithReplyList/app/src/main/java/com/moos/example/adapter/CommentExpandAdapter.java b/CommentWithReplyList/app/src/main/java/com/moos/example/adapter/CommentExpandAdapter.java index 85be599..c2d8081 100644 --- a/CommentWithReplyList/app/src/main/java/com/moos/example/adapter/CommentExpandAdapter.java +++ b/CommentWithReplyList/app/src/main/java/com/moos/example/adapter/CommentExpandAdapter.java @@ -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); @@ -174,7 +172,6 @@ public ChildHolder(View view) { tv_content = (TextView) view.findViewById(R.id.reply_item_content); } } - BottomSheetDialog dialog; /** @@ -184,7 +181,6 @@ public ChildHolder(View view) { */ public void addTheCommentData(CommentDetailBean commentDetailBean){ if(commentDetailBean!=null){ - Log.e(TAG, "addTheCommentData: >>>>该刷新评论列表了" ); commentBeanList.add(commentDetailBean); notifyDataSetChanged(); @@ -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 replyList = new ArrayList<>(); replyList.add(replyDetailBean); commentBeanList.get(groupPosition).setReplyList(replyList); } - notifyDataSetChanged(); }else { throw new IllegalArgumentException("回复数据为空!"); diff --git a/CommentWithReplyList/app/src/main/java/com/moos/example/bean/CommentDetailBean.java b/CommentWithReplyList/app/src/main/java/com/moos/example/bean/CommentDetailBean.java index 72461f3..a5ab6fd 100644 --- a/CommentWithReplyList/app/src/main/java/com/moos/example/bean/CommentDetailBean.java +++ b/CommentWithReplyList/app/src/main/java/com/moos/example/bean/CommentDetailBean.java @@ -16,9 +16,8 @@ public class CommentDetailBean { private String createDate; private List 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; } diff --git a/CommentWithReplyList/app/src/main/java/com/moos/example/view/CommentExpandableListView.java b/CommentWithReplyList/app/src/main/java/com/moos/example/view/CommentExpandableListView.java index f0a38b9..63ca5ae 100644 --- a/CommentWithReplyList/app/src/main/java/com/moos/example/view/CommentExpandableListView.java +++ b/CommentWithReplyList/app/src/main/java/com/moos/example/view/CommentExpandableListView.java @@ -9,8 +9,8 @@ /** * Author: Moos * E-mail: moosphon@gmail.com - * Date: 18/4/18. - * Desc: 自定义ExpandableListView,解决与NestedScrollview滑动冲突问题 + * Date: 18/4/20. + * Desc: 自定义ExpandableListView,解决与CoordinatorLayout滑动冲突问题 */ public class CommentExpandableListView extends ExpandableListView implements NestedScrollingChild{