diff --git a/src/CommentReplyComponent-master/.gitignore b/src/CommentReplyComponent-master/.gitignore new file mode 100644 index 0000000..520a863 --- /dev/null +++ b/src/CommentReplyComponent-master/.gitignore @@ -0,0 +1,55 @@ +# Built application files +*.apk +*.ap_ + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# Intellij +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/dictionaries +.idea/libraries + +# Keystore files +*.jks + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/.gitignore b/src/CommentReplyComponent-master/CommentWithReplyList/.gitignore new file mode 100644 index 0000000..39fb081 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/.idea/.gitignore b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/.idea/compiler.xml b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/.idea/dictionaries/moos.xml b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/dictionaries/moos.xml new file mode 100644 index 0000000..2f01d98 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/dictionaries/moos.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/.idea/gradle.xml b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/gradle.xml new file mode 100644 index 0000000..a2d7c21 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/.idea/jarRepositories.xml b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/jarRepositories.xml new file mode 100644 index 0000000..a5f05cd --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/.idea/misc.xml b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/misc.xml new file mode 100644 index 0000000..6bb70d7 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/misc.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + Android + + + CorrectnessLintAndroid + + + Java + + + LintAndroid + + + Probable bugsJava + + + RELAX NG + + + + + Android + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/.idea/modules.xml b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/modules.xml new file mode 100644 index 0000000..f0036bc --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/.idea/modules.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/.gitignore b/src/CommentReplyComponent-master/CommentWithReplyList/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/build.gradle b/src/CommentReplyComponent-master/CommentWithReplyList/app/build.gradle new file mode 100644 index 0000000..8b179ce --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/build.gradle @@ -0,0 +1,32 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.moos.example" + minSdkVersion 21 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support.constraint:constraint-layout:2.0.4' + testImplementation 'junit:junit:4.12' + implementation 'com.android.support:design:28.0.0' + implementation 'de.hdodenhof:circleimageview:2.1.0' + implementation 'com.github.bumptech.glide:glide:3.7.0' + implementation 'com.google.code.gson:gson:2.7' + + +} diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/proguard-rules.pro b/src/CommentReplyComponent-master/CommentWithReplyList/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/androidTest/java/com/moos/example/ExampleInstrumentedTest.java b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/androidTest/java/com/moos/example/ExampleInstrumentedTest.java new file mode 100644 index 0000000..ae9bba6 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/androidTest/java/com/moos/example/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.moos.example; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.moos.example", appContext.getPackageName()); + } +} diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/AndroidManifest.xml b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..729fdbb --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/AndroidManifest.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/MainActivity.java b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/MainActivity.java new file mode 100644 index 0000000..05049c9 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/MainActivity.java @@ -0,0 +1,304 @@ +package com.moos.example; + +import android.graphics.Color; +import android.support.design.widget.BottomSheetBehavior; +import android.support.design.widget.BottomSheetDialog; +import android.support.design.widget.CollapsingToolbarLayout; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.support.v7.widget.Toolbar; +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.util.Log; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.MenuItem; +import android.view.View; +import android.view.Window; +import android.view.WindowManager; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ExpandableListView; +import android.widget.TextView; +import android.widget.Toast; + +import com.google.gson.Gson; +import com.moos.example.adapter.CommentExpandAdapter; +import com.moos.example.bean.CommentBean; +import com.moos.example.bean.CommentDetailBean; +import com.moos.example.bean.ReplyDetailBean; +import com.moos.example.view.CommentExpandableListView; + +import java.util.List; + +/** + * by moos on 2018/04/20 + */ +public class MainActivity extends AppCompatActivity implements View.OnClickListener { + private static final String TAG = "MainActivity"; + private android.support.v7.widget.Toolbar toolbar; + private TextView bt_comment; + private CommentExpandableListView expandableListView; + private CommentExpandAdapter adapter; + private CommentBean commentBean; + private List commentsList; + private BottomSheetDialog dialog; + private String testJson = "{\n" + + "\t\"code\": 1000,\n" + + "\t\"message\": \"查看评论成功\",\n" + + "\t\"data\": {\n" + + "\t\t\"total\": 3,\n" + + "\t\t\"list\": [{\n" + + "\t\t\t\t\"id\": 42,\n" + + "\t\t\t\t\"nickName\": \"程序猿\",\n" + + "\t\t\t\t\"userLogo\": \"http://ucardstorevideo.b0.upaiyun.com/userLogo/9fa13ec6-dddd-46cb-9df0-4bbb32d83fc1.png\",\n" + + "\t\t\t\t\"content\": \"时间是一切财富中最宝贵的财富。\",\n" + + "\t\t\t\t\"imgId\": \"xcclsscrt0tev11ok364\",\n" + + "\t\t\t\t\"replyTotal\": 1,\n" + + "\t\t\t\t\"createDate\": \"三分钟前\",\n" + + "\t\t\t\t\"replyList\": [{\n" + + "\t\t\t\t\t\"nickName\": \"沐風\",\n" + + "\t\t\t\t\t\"userLogo\": \"http://ucardstorevideo.b0.upaiyun.com/userLogo/9fa13ec6-dddd-46cb-9df0-4bbb32d83fc1.png\",\n" + + "\t\t\t\t\t\"id\": 40,\n" + + "\t\t\t\t\t\"commentId\": \"42\",\n" + + "\t\t\t\t\t\"content\": \"时间总是在不经意中擦肩而过,不留一点痕迹.\",\n" + + "\t\t\t\t\t\"status\": \"01\",\n" + + "\t\t\t\t\t\"createDate\": \"一个小时前\"\n" + + "\t\t\t\t}]\n" + + "\t\t\t},\n" + + "\t\t\t{\n" + + "\t\t\t\t\"id\": 41,\n" + + "\t\t\t\t\"nickName\": \"设计狗\",\n" + + "\t\t\t\t\"userLogo\": \"http://ucardstorevideo.b0.upaiyun.com/userLogo/9fa13ec6-dddd-46cb-9df0-4bbb32d83fc1.png\",\n" + + "\t\t\t\t\"content\": \"这世界要是没有爱情,它在我们心中还会有什么意义!这就如一盏没有亮光的走马灯。\",\n" + + "\t\t\t\t\"imgId\": \"xcclsscrt0tev11ok364\",\n" + + "\t\t\t\t\"replyTotal\": 1,\n" + + "\t\t\t\t\"createDate\": \"一天前\",\n" + + "\t\t\t\t\"replyList\": [{\n" + + "\t\t\t\t\t\"nickName\": \"沐風\",\n" + + "\t\t\t\t\t\"userLogo\": \"http://ucardstorevideo.b0.upaiyun.com/userLogo/9fa13ec6-dddd-46cb-9df0-4bbb32d83fc1.png\",\n" + + "\t\t\t\t\t\"commentId\": \"41\",\n" + + "\t\t\t\t\t\"content\": \"时间总是在不经意中擦肩而过,不留一点痕迹.\",\n" + + "\t\t\t\t\t\"status\": \"01\",\n" + + "\t\t\t\t\t\"createDate\": \"三小时前\"\n" + + "\t\t\t\t}]\n" + + "\t\t\t},\n" + + "\t\t\t{\n" + + "\t\t\t\t\"id\": 40,\n" + + "\t\t\t\t\"nickName\": \"产品喵\",\n" + + "\t\t\t\t\"userLogo\": \"http://ucardstorevideo.b0.upaiyun.com/userLogo/9fa13ec6-dddd-46cb-9df0-4bbb32d83fc1.png\",\n" + + "\t\t\t\t\"content\": \"笨蛋自以为聪明,聪明人才知道自己是笨蛋。\",\n" + + "\t\t\t\t\"imgId\": \"xcclsscrt0tev11ok364\",\n" + + "\t\t\t\t\"replyTotal\": 0,\n" + + "\t\t\t\t\"createDate\": \"三天前\",\n" + + "\t\t\t\t\"replyList\": []\n" + + "\t\t\t}\n" + + "\t\t]\n" + + "\t}\n" + + "}"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + initView(); + } + + private void initView() { + toolbar = (Toolbar) findViewById(R.id.toolbar); + expandableListView = (CommentExpandableListView) findViewById(R.id.detail_page_lv_comment); + bt_comment = (TextView) findViewById(R.id.detail_page_do_comment); + bt_comment.setOnClickListener(this); + setSupportActionBar(toolbar); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + CollapsingToolbarLayout collapsingToolbar = + (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); + collapsingToolbar.setTitle("详情"); + commentsList = generateTestData(); + initExpandableListView(commentsList); + } + + /** + * 初始化评论和回复列表 + */ + private void initExpandableListView(final List commentList){ + expandableListView.setGroupIndicator(null); + //默认展开所有回复 + adapter = new CommentExpandAdapter(this, commentList); + expandableListView.setAdapter(adapter); + for(int i = 0; i>>"+commentList.get(groupPosition).getId()); +// if(isExpanded){ +// expandableListView.collapseGroup(groupPosition); +// }else { +// expandableListView.expandGroup(groupPosition, true); +// } + showReplyDialog(groupPosition); + return true; + } + }); + + expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { + @Override + public boolean onChildClick(ExpandableListView expandableListView, View view, int groupPosition, int childPosition, long l) { + Toast.makeText(MainActivity.this,"点击了回复",Toast.LENGTH_SHORT).show(); + return false; + } + }); + + expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() { + @Override + public void onGroupExpand(int groupPosition) { + //toast("展开第"+groupPosition+"个分组"); + + } + }); + + } + + /** + * by moos on 2018/04/20 + * func:生成测试数据 + * @return 评论数据 + */ + private List generateTestData(){ + Gson gson = new Gson(); + commentBean = gson.fromJson(testJson, CommentBean.class); + List commentList = commentBean.getData().getList(); + return commentList; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if(item.getItemId() == android.R.id.home){ + finish(); + return true; + } + return super.onOptionsItemSelected(item); + } + + @Override + public void onClick(View view) { + if(view.getId() == R.id.detail_page_do_comment){ + + showCommentDialog(); + } + } + + /** + * by moos on 2018/04/20 + * func:弹出评论框 + */ + private void showCommentDialog(){ + dialog = new BottomSheetDialog(this); + View commentView = LayoutInflater.from(this).inflate(R.layout.comment_dialog_layout,null); + final EditText commentText = (EditText) commentView.findViewById(R.id.dialog_comment_et); + final Button bt_comment = (Button) commentView.findViewById(R.id.dialog_comment_bt); + dialog.setContentView(commentView); + /** + * 解决bsd显示不全的情况 + */ + View parent = (View) commentView.getParent(); + BottomSheetBehavior behavior = BottomSheetBehavior.from(parent); + commentView.measure(0,0); + behavior.setPeekHeight(commentView.getMeasuredHeight()); + + bt_comment.setOnClickListener(new View.OnClickListener() { + + @Override + public void onClick(View view) { + String commentContent = commentText.getText().toString().trim(); + if(!TextUtils.isEmpty(commentContent)){ + + //commentOnWork(commentContent); + dialog.dismiss(); + CommentDetailBean detailBean = new CommentDetailBean("小明", commentContent,"刚刚"); + adapter.addTheCommentData(detailBean); + Toast.makeText(MainActivity.this,"评论成功",Toast.LENGTH_SHORT).show(); + + }else { + Toast.makeText(MainActivity.this,"评论内容不能为空",Toast.LENGTH_SHORT).show(); + } + } + }); + commentText.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + if(!TextUtils.isEmpty(charSequence) && charSequence.length()>2){ + bt_comment.setBackgroundColor(Color.parseColor("#FFB568")); + }else { + bt_comment.setBackgroundColor(Color.parseColor("#D8D8D8")); + } + } + + @Override + public void afterTextChanged(Editable editable) { + + } + }); + dialog.show(); + } + + /** + * by moos on 2018/04/20 + * func:弹出回复框 + */ + private void showReplyDialog(final int position){ + dialog = new BottomSheetDialog(this); + View commentView = LayoutInflater.from(this).inflate(R.layout.comment_dialog_layout,null); + final EditText commentText = (EditText) commentView.findViewById(R.id.dialog_comment_et); + final Button bt_comment = (Button) commentView.findViewById(R.id.dialog_comment_bt); + commentText.setHint("回复 " + commentsList.get(position).getNickName() + " 的评论:"); + dialog.setContentView(commentView); + bt_comment.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String replyContent = commentText.getText().toString().trim(); + if(!TextUtils.isEmpty(replyContent)){ + + 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(); + } + } + }); + commentText.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { + + } + + @Override + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { + if(!TextUtils.isEmpty(charSequence) && charSequence.length()>2){ + bt_comment.setBackgroundColor(Color.parseColor("#FFB568")); + }else { + bt_comment.setBackgroundColor(Color.parseColor("#D8D8D8")); + } + } + + @Override + public void afterTextChanged(Editable editable) { + + } + }); + dialog.show(); + } + +} diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/adapter/CommentExpandAdapter.java b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/adapter/CommentExpandAdapter.java new file mode 100644 index 0000000..f732fba --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/adapter/CommentExpandAdapter.java @@ -0,0 +1,233 @@ +package com.moos.example.adapter; + +import android.content.Context; +import android.graphics.Color; +import android.support.design.widget.BottomSheetDialog; +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseExpandableListAdapter; +import android.widget.Button; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import com.bumptech.glide.Glide; +import com.bumptech.glide.load.engine.DiskCacheStrategy; +import com.moos.example.R; +import com.moos.example.bean.CommentDetailBean; +import com.moos.example.bean.ReplyDetailBean; + +import java.util.ArrayList; +import java.util.List; + +import de.hdodenhof.circleimageview.CircleImageView; + +/** + * Author: Moos + * E-mail: moosphon@gmail.com + * Date: 18/4/20. + * Desc: 评论与回复列表的适配器 + */ + +public class CommentExpandAdapter extends BaseExpandableListAdapter { + private static final String TAG = "CommentExpandAdapter"; + private List commentBeanList; + private List replyBeanList; + private Context context; + private int pageIndex = 1; + + public CommentExpandAdapter(Context context, List commentBeanList) { + this.context = context; + this.commentBeanList = commentBeanList; + } + + @Override + public int getGroupCount() { + return commentBeanList.size(); + } + + @Override + public int getChildrenCount(int i) { + if(commentBeanList.get(i).getReplyList() == null){ + return 0; + }else { + return commentBeanList.get(i).getReplyList().size()>0 ? commentBeanList.get(i).getReplyList().size():0; + } + + } + + @Override + public Object getGroup(int i) { + return commentBeanList.get(i); + } + + @Override + public Object getChild(int i, int i1) { + return commentBeanList.get(i).getReplyList().get(i1); + } + + @Override + public long getGroupId(int groupPosition) { + return groupPosition; + } + + @Override + public long getChildId(int groupPosition, int childPosition) { + return getCombinedChildId(groupPosition, childPosition); + } + + @Override + public boolean hasStableIds() { + return true; + } + boolean isLike = false; + + @Override + public View getGroupView(final int groupPosition, boolean isExpand, View convertView, ViewGroup viewGroup) { + final GroupHolder groupHolder; + + if(convertView == null){ + convertView = LayoutInflater.from(context).inflate(R.layout.comment_item_layout, viewGroup, false); + groupHolder = new GroupHolder(convertView); + convertView.setTag(groupHolder); + }else { + groupHolder = (GroupHolder) convertView.getTag(); + } + Glide.with(context).load(R.drawable.user_other) + .diskCacheStrategy(DiskCacheStrategy.RESULT) + .error(R.mipmap.ic_launcher) + .centerCrop() + .into(groupHolder.logo); + groupHolder.tv_name.setText(commentBeanList.get(groupPosition).getNickName()); + groupHolder.tv_time.setText(commentBeanList.get(groupPosition).getCreateDate()); + groupHolder.tv_content.setText(commentBeanList.get(groupPosition).getContent()); + groupHolder.iv_like.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if(isLike){ + isLike = false; + groupHolder.iv_like.setColorFilter(Color.parseColor("#aaaaaa")); + }else { + isLike = true; + groupHolder.iv_like.setColorFilter(Color.parseColor("#FF5C5C")); + } + } + }); + + return convertView; + } + + @Override + public View getChildView(final int groupPosition, int childPosition, boolean b, View convertView, ViewGroup viewGroup) { + final ChildHolder childHolder; + if(convertView == null){ + convertView = LayoutInflater.from(context).inflate(R.layout.comment_reply_item_layout,viewGroup, false); + childHolder = new ChildHolder(convertView); + convertView.setTag(childHolder); + } + else { + childHolder = (ChildHolder) convertView.getTag(); + } + + String replyUser = commentBeanList.get(groupPosition).getReplyList().get(childPosition).getNickName(); + if(!TextUtils.isEmpty(replyUser)){ + childHolder.tv_name.setText(replyUser + ":"); + }else { + childHolder.tv_name.setText("无名"+":"); + } + + childHolder.tv_content.setText(commentBeanList.get(groupPosition).getReplyList().get(childPosition).getContent()); + + return convertView; + } + + @Override + public boolean isChildSelectable(int i, int i1) { + return true; + } + + private class GroupHolder{ + private CircleImageView logo; + private TextView tv_name, tv_content, tv_time; + private ImageView iv_like; + public GroupHolder(View view) { + logo = (CircleImageView) view.findViewById(R.id.comment_item_logo); + tv_content = (TextView) view.findViewById(R.id.comment_item_content); + tv_name = (TextView) view.findViewById(R.id.comment_item_userName); + tv_time = (TextView) view.findViewById(R.id.comment_item_time); + iv_like = (ImageView) view.findViewById(R.id.comment_item_like); + } + } + + private class ChildHolder{ + private TextView tv_name, tv_content; + public ChildHolder(View view) { + tv_name = (TextView) view.findViewById(R.id.reply_item_user); + tv_content = (TextView) view.findViewById(R.id.reply_item_content); + } + } + + + /** + * by moos on 2018/04/20 + * func:评论成功后插入一条数据 + * @param commentDetailBean 新的评论数据 + */ + public void addTheCommentData(CommentDetailBean commentDetailBean){ + if(commentDetailBean!=null){ + + commentBeanList.add(commentDetailBean); + notifyDataSetChanged(); + }else { + throw new IllegalArgumentException("评论数据为空!"); + } + + } + + /** + * by moos on 2018/04/20 + * func:回复成功后插入一条数据 + * @param replyDetailBean 新的回复数据 + */ + public void addTheReplyData(ReplyDetailBean replyDetailBean, int groupPosition){ + if(replyDetailBean!=null){ + Log.e(TAG, "addTheReplyData: >>>>该刷新回复列表了:"+replyDetailBean.toString() ); + if(commentBeanList.get(groupPosition).getReplyList() != null ){ + commentBeanList.get(groupPosition).getReplyList().add(replyDetailBean); + }else { + List replyList = new ArrayList<>(); + replyList.add(replyDetailBean); + commentBeanList.get(groupPosition).setReplyList(replyList); + } + notifyDataSetChanged(); + }else { + throw new IllegalArgumentException("回复数据为空!"); + } + + } + + /** + * by moos on 2018/04/20 + * func:添加和展示所有回复 + * @param replyBeanList 所有回复数据 + * @param groupPosition 当前的评论 + */ + private void addReplyList(List replyBeanList, int groupPosition){ + if(commentBeanList.get(groupPosition).getReplyList() != null ){ + commentBeanList.get(groupPosition).getReplyList().clear(); + commentBeanList.get(groupPosition).getReplyList().addAll(replyBeanList); + }else { + + commentBeanList.get(groupPosition).setReplyList(replyBeanList); + } + + notifyDataSetChanged(); + } + +} diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/bean/CommentBean.java b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/bean/CommentBean.java new file mode 100644 index 0000000..69aaceb --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/bean/CommentBean.java @@ -0,0 +1,54 @@ +package com.moos.example.bean; + +import java.util.List; + +/** + * Created by moos on 2018/4/20. + */ + +public class CommentBean { + private int code; + private String message; + private Data data; + public void setCode(int code) { + this.code = code; + } + public int getCode() { + return code; + } + + public void setMessage(String message) { + this.message = message; + } + public String getMessage() { + return message; + } + + public void setData(Data data) { + this.data = data; + } + public Data getData() { + return data; + } + + public class Data { + + private int total; + private List list; + public void setTotal(int total) { + this.total = total; + } + public int getTotal() { + return total; + } + + public void setList(List list) { + this.list = list; + } + public List getList() { + return list; + } + + } + +} diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/bean/CommentDetailBean.java b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/bean/CommentDetailBean.java new file mode 100644 index 0000000..a5ab6fd --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/bean/CommentDetailBean.java @@ -0,0 +1,80 @@ +package com.moos.example.bean; + +import java.util.List; + +/** + * Created by moos on 2018/4/20. + */ + +public class CommentDetailBean { + private int id; + private String nickName; + private String userLogo; + private String content; + private String imgId; + private int replyTotal; + private String createDate; + private List replyList; + + public CommentDetailBean(String nickName, String content, String createDate) { + this.nickName = nickName; + this.content = content; + this.createDate = createDate; + } + + public void setId(int id) { + this.id = id; + } + public int getId() { + return id; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + public String getNickName() { + return nickName; + } + + public void setUserLogo(String userLogo) { + this.userLogo = userLogo; + } + public String getUserLogo() { + return userLogo; + } + + public void setContent(String content) { + this.content = content; + } + public String getContent() { + return content; + } + + public void setImgId(String imgId) { + this.imgId = imgId; + } + public String getImgId() { + return imgId; + } + + public void setReplyTotal(int replyTotal) { + this.replyTotal = replyTotal; + } + public int getReplyTotal() { + return replyTotal; + } + + public void setCreateDate(String createDate) { + this.createDate = createDate; + } + public String getCreateDate() { + return createDate; + } + + public void setReplyList(List replyList) { + this.replyList = replyList; + } + public List getReplyList() { + return replyList; + } +} diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/bean/ReplyDetailBean.java b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/bean/ReplyDetailBean.java new file mode 100644 index 0000000..9a3e346 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/bean/ReplyDetailBean.java @@ -0,0 +1,70 @@ +package com.moos.example.bean; + +/** + * Created by moos on 2018/4/20. + */ + +public class ReplyDetailBean { + private String nickName; + private String userLogo; + private int id; + private String commentId; + private String content; + private String status; + private String createDate; + + public ReplyDetailBean(String nickName, String content) { + this.nickName = nickName; + this.content = content; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + public String getNickName() { + return nickName; + } + + public void setUserLogo(String userLogo) { + this.userLogo = userLogo; + } + public String getUserLogo() { + return userLogo; + } + + public void setId(int id) { + this.id = id; + } + public int getId() { + return id; + } + + public void setCommentId(String commentId) { + this.commentId = commentId; + } + public String getCommentId() { + return commentId; + } + + public void setContent(String content) { + this.content = content; + } + public String getContent() { + return content; + } + + public void setStatus(String status) { + this.status = status; + } + public String getStatus() { + return status; + } + + public void setCreateDate(String createDate) { + this.createDate = createDate; + } + public String getCreateDate() { + return createDate; + } + +} diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/view/CommentExpandableListView.java b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/view/CommentExpandableListView.java new file mode 100644 index 0000000..63ca5ae --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/java/com/moos/example/view/CommentExpandableListView.java @@ -0,0 +1,83 @@ +package com.moos.example.view; + +import android.content.Context; +import android.os.Build; +import android.support.v4.view.NestedScrollingChild; +import android.support.v4.view.NestedScrollingChildHelper; +import android.util.AttributeSet; +import android.widget.ExpandableListView; +/** + * Author: Moos + * E-mail: moosphon@gmail.com + * Date: 18/4/20. + * Desc: 自定义ExpandableListView,解决与CoordinatorLayout滑动冲突问题 + */ + +public class CommentExpandableListView extends ExpandableListView implements NestedScrollingChild{ + private NestedScrollingChildHelper mScrollingChildHelper; + + + public CommentExpandableListView(Context context, AttributeSet attrs) { + super(context, attrs); + mScrollingChildHelper = new NestedScrollingChildHelper(this); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + setNestedScrollingEnabled(true); + } + + } + + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); + super.onMeasure(widthMeasureSpec, expandSpec); + + } + + @Override + public void setNestedScrollingEnabled(boolean enabled) { + mScrollingChildHelper.setNestedScrollingEnabled(enabled); + } + + @Override + public boolean isNestedScrollingEnabled() { + return mScrollingChildHelper.isNestedScrollingEnabled(); + } + + @Override + public boolean startNestedScroll(int axes) { + return mScrollingChildHelper.startNestedScroll(axes); + } + + @Override + public void stopNestedScroll() { + mScrollingChildHelper.stopNestedScroll(); + } + + @Override + public boolean hasNestedScrollingParent() { + return mScrollingChildHelper.hasNestedScrollingParent(); + } + + @Override + public boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, + int dyUnconsumed, int[] offsetInWindow) { + return mScrollingChildHelper.dispatchNestedScroll(dxConsumed, dyConsumed, + dxUnconsumed, dyUnconsumed, offsetInWindow); + } + + @Override + public boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow) { + return mScrollingChildHelper.dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow); + } + + @Override + public boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed) { + return mScrollingChildHelper.dispatchNestedFling(velocityX, velocityY, consumed); + } + + @Override + public boolean dispatchNestedPreFling(float velocityX, float velocityY) { + return mScrollingChildHelper.dispatchNestedPreFling(velocityX, velocityY); + } +} diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..c7bd21d --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/icon_collect.png b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/icon_collect.png new file mode 100644 index 0000000..3bf8bc1 Binary files /dev/null and b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/icon_collect.png differ diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/icon_comment_like.png b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/icon_comment_like.png new file mode 100644 index 0000000..4df9982 Binary files /dev/null and b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/icon_comment_like.png differ diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/icon_focus.png b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/icon_focus.png new file mode 100644 index 0000000..fd05b02 Binary files /dev/null and b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/icon_focus.png differ diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/icon_work_like.png b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/icon_work_like.png new file mode 100644 index 0000000..ba73e14 Binary files /dev/null and b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/icon_work_like.png differ diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/teaser.png b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/teaser.png new file mode 100644 index 0000000..e3ea129 Binary files /dev/null and b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/teaser.png differ diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/user_logo.jpg b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/user_logo.jpg new file mode 100644 index 0000000..c8d8a7b Binary files /dev/null and b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/user_logo.jpg differ diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/user_other.jpg b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/user_other.jpg new file mode 100644 index 0000000..cee062c Binary files /dev/null and b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable-xhdpi/user_other.jpg differ diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable/comment_bt_selector.xml b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable/comment_bt_selector.xml new file mode 100644 index 0000000..caca810 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable/comment_bt_selector.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable/comment_dialog_et_selector.xml b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable/comment_dialog_et_selector.xml new file mode 100644 index 0000000..9d1c3d8 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable/comment_dialog_et_selector.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable/ic_launcher_background.xml b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..d5fccc5 --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/layout/activity_main.xml b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..af4c99a --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/layout/comment_dialog_layout.xml b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/layout/comment_dialog_layout.xml new file mode 100644 index 0000000..1782d8b --- /dev/null +++ b/src/CommentReplyComponent-master/CommentWithReplyList/app/src/main/res/layout/comment_dialog_layout.xml @@ -0,0 +1,35 @@ + + + +