wangkai

添加详情页

Showing 54 changed files with 3816 additions and 22 deletions

Too many changes to show.

To preserve performance only 54 of 54+ files are displayed.

  1 +configurations.maybeCreate("default")
  2 +artifacts.add("default", file('materialiconlib-1.1.5.aar'))
  1 +configurations.maybeCreate("default")
  2 +artifacts.add("default", file('videocache-2.7.1.aar'))
  1 +configurations.maybeCreate("default")
  2 +artifacts.add("default", file('doraemonlibrary_v1.5.0_release.aar'))
  3 +artifacts.add("default", file('main-2.2.1-release.aar'))
  4 +artifacts.add("default", file('logger-2.2.1-release.aar'))
  1 +configurations.maybeCreate("default")
  2 +artifacts.add("default", file('auth_number_product-2.13.2.1-release.aar'))
  1 +configurations.maybeCreate("default")
  2 +artifacts.add("default", file('etas-release_20240131.aar'))
  1 +configurations.maybeCreate("default")
  2 +artifacts.add("default", file('nuisdk-release-V2.5.14-01B-20230807_Android.aar'))
No preview for this file type
  1 +configurations.maybeCreate("default")
  2 +artifacts.add("default", file('ability-1.1.3.1.aar'))
  1 +configurations.maybeCreate("default")
  2 +artifacts.add("default", file('framework-1.1.2.1.aar'))
@@ -64,6 +64,8 @@ dependencies { @@ -64,6 +64,8 @@ dependencies {
64 implementation project(path: ':module_home') 64 implementation project(path: ':module_home')
65 implementation project(path: ':module_videoplayer') 65 implementation project(path: ':module_videoplayer')
66 implementation project(path: ':module_personalcenter') 66 implementation project(path: ':module_personalcenter')
67 -// annotationProcessor 'com.alibaba:arouter-compiler:1.5.2' 67 + implementation project(path: ':lib_jsbridge')
  68 + implementation project(path: ':base_webview')
  69 + implementation project(path: ':base_comment')
68 70
69 } 71 }
@@ -9,14 +9,16 @@ @@ -9,14 +9,16 @@
9 android:required="false" /> 9 android:required="false" />
10 <application 10 <application
11 android:name=".MyApplication" 11 android:name=".MyApplication"
12 - android:allowBackup="true" 12 + android:allowBackup="false"
13 android:fullBackupContent="@xml/backup_rules" 13 android:fullBackupContent="@xml/backup_rules"
14 android:icon="@mipmap/ic_fastcode" 14 android:icon="@mipmap/ic_fastcode"
15 android:label="@string/app_name" 15 android:label="@string/app_name"
16 android:roundIcon="@mipmap/ic_fastcode" 16 android:roundIcon="@mipmap/ic_fastcode"
17 android:supportsRtl="true" 17 android:supportsRtl="true"
18 - android:theme="@style/Theme.MyApplication"  
19 - tools:targetApi="31"> 18 + android:theme="@style/AppTheme"
  19 + android:usesCleartextTraffic="true"
  20 + tools:ignore="Instantiatable"
  21 + tools:replace="android:allowBackup,android:name">
20 22
21 <activity 23 <activity
22 android:name=".MainActivity" 24 android:name=".MainActivity"
1 1
2 package com.wd.fastcoding.app; 2 package com.wd.fastcoding.app;
3 3
4 -import android.app.Application;  
5 -  
6 import com.wd.capability.network.RetrofitClient; 4 import com.wd.capability.network.RetrofitClient;
7 -import com.wd.foundation.wdinterfaceimpl.interceptor.TokenInterceptor;  
8 import com.wd.capability.router.ArouteInit; 5 import com.wd.capability.router.ArouteInit;
9 -import com.wd.foundation.wdkit.utils.CommonUtil; 6 +import com.wd.common.base.BaseApplication;
10 import com.wd.fastcoding.app.start.StartTaskConfig; 7 import com.wd.fastcoding.app.start.StartTaskConfig;
  8 +import com.wd.foundation.wdkit.utils.CommonUtil;
11 import com.wd.foundation.wdkitcore.tools.AppContext; 9 import com.wd.foundation.wdkitcore.tools.AppContext;
12 import com.wd.foundation.wdkitcore.tools.StringUtils; 10 import com.wd.foundation.wdkitcore.tools.StringUtils;
13 11
14 -import okhttp3.Interceptor;  
15 -  
16 /** 12 /**
17 * @author devel 13 * @author devel
18 * @time 2024/8/28 星期三 16:23 14 * @time 2024/8/28 星期三 16:23
19 */ 15 */
20 -public class MyApplication extends Application { 16 +public class MyApplication extends BaseApplication {
21 @Override 17 @Override
22 public void onCreate() { 18 public void onCreate() {
23 super.onCreate(); 19 super.onCreate();
@@ -52,4 +48,62 @@ public class MyApplication extends Application { @@ -52,4 +48,62 @@ public class MyApplication extends Application {
52 String name = getPackageName(); 48 String name = getPackageName();
53 return StringUtils.isEmpty(curProcessName) || StringUtils.isEmpty(name) || name.equals(curProcessName); 49 return StringUtils.isEmpty(curProcessName) || StringUtils.isEmpty(name) || name.equals(curProcessName);
54 } 50 }
  51 +
  52 + @Override
  53 + public void countDownTimerChange(int i) {
  54 + super.countDownTimerChange(i);
  55 +// if (0 == i|| 1 == i) {
  56 +// // 更新倒计时文本
  57 +// PlayerManagerUtils.setTimer(0L);
  58 +// PlayerManager.getInstance().updateDownCount();
  59 +// if (mCountDownTimer != null) {
  60 +// // 取消倒计时
  61 +// mCountDownTimer.cancel();
  62 +// }
  63 +// return;
  64 +// }
  65 +// // 创建一个持续时间为 30 分钟的倒计时器,并设置倒计时间隔为 1 秒
  66 +// int time;
  67 +// switch (i) {
  68 +// case 3:
  69 +// time = 20;
  70 +// break;
  71 +// case 4:
  72 +// time = 30;
  73 +// break;
  74 +// case 5:
  75 +// time = 60;
  76 +// break;
  77 +// default:
  78 +// time = 10;
  79 +// break;
  80 +// }
  81 +// if (mCountDownTimer != null){
  82 +// mCountDownTimer.cancel();
  83 +// mCountDownTimer = null;
  84 +// }
  85 +// CustomCountDownTimer.OnCountDownListener listener = new CustomCountDownTimer.OnCountDownListener() {
  86 +// @Override
  87 +// public void onTick(long millisUntilFinished) {
  88 +// // 更新倒计时文本
  89 +// PlayerManagerUtils.setTimer(millisUntilFinished);
  90 +// PlayerManager.getInstance().updateDownCount();
  91 +// }
  92 +//
  93 +// @Override
  94 +// public void onFinish() {
  95 +// PlayerManagerUtils.pauseAudio();
  96 +// // 更新倒计时文本
  97 +// PlayerManagerUtils.setTimer(0L);
  98 +// PlayerManager.getInstance().updateDownCount();
  99 +// }
  100 +// };
  101 +//// if(i == 1){
  102 +//// mCountDownTimer = new CustomCountDownTimer(PlayerManager.getInstance().getResidueDuration(),1000,listener);
  103 +//// }else{
  104 +// mCountDownTimer = CustomCountDownTimer.create(time, listener);
  105 +//// }
  106 +// // 开始倒计时
  107 +// mCountDownTimer.start();
  108 + }
55 } 109 }
1 <resources xmlns:tools="http://schemas.android.com/tools"> 1 <resources xmlns:tools="http://schemas.android.com/tools">
2 <!-- Base application theme. --> 2 <!-- Base application theme. -->
3 - <style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar">  
4 - <!-- Primary brand color. -->  
5 - <item name="colorPrimary">@color/purple_500</item>  
6 - <item name="colorPrimaryVariant">@color/purple_700</item>  
7 - <item name="colorOnPrimary">@color/white</item>  
8 - <!-- Secondary brand color. -->  
9 - <item name="colorSecondary">@color/teal_200</item>  
10 - <item name="colorSecondaryVariant">@color/teal_700</item>  
11 - <item name="colorOnSecondary">@color/black</item>  
12 - <!-- Status bar color. -->  
13 - <item name="android:statusBarColor">?attr/colorPrimaryVariant</item> 3 + <style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
14 <!-- Customize your theme here. --> 4 <!-- Customize your theme here. -->
  5 + <item name="colorPrimary">@color/white</item>
  6 + <item name="colorPrimaryDark">@color/white</item>
  7 + <item name="colorAccent">@color/colorAccent</item>
  8 + <item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
15 </style> 9 </style>
16 </resources> 10 </resources>
  1 +plugins {
  2 + id 'com.android.library'
  3 + id 'kotlin-android'
  4 +}
  5 +
  6 +android {
  7 + compileSdkVersion var.compileSdkVersion
  8 + buildToolsVersion var.buildToolsVersion
  9 +
  10 + defaultConfig {
  11 + minSdkVersion var.minSdkVersion
  12 + targetSdkVersion var.targetSdkVersion
  13 + versionCode var.versionCode
  14 + versionName var.versionName
  15 +
  16 + consumerProguardFiles "consumer-rules.pro"
  17 +
  18 + javaCompileOptions {
  19 + annotationProcessorOptions {
  20 + arguments = [AROUTER_MODULE_NAME: project.getName()]
  21 + }
  22 + }
  23 + }
  24 +
  25 + buildTypes {
  26 + release {
  27 + minifyEnabled false
  28 + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  29 + }
  30 + }
  31 + compileOptions {
  32 + sourceCompatibility JavaVersion.VERSION_1_8
  33 + targetCompatibility JavaVersion.VERSION_1_8
  34 + }
  35 +}
  36 +
  37 +dependencies {
  38 + api rootProject.ext.dependencies["gson"]
  39 +// implementation project(path: ':base_umeng')
  40 + implementation project(path: ':base_speech')
  41 + api project(path: ':lib_base')
  42 + implementation project(':aar_repo:lib_speech')
  43 + implementation rootProject.ext.dependencies["eventbus"]
  44 + implementation rootProject.ext.support["legacy-support"]
  45 + annotationProcessor rootProject.ext.dependencies["arouter-compiler"]
  46 +// //图片选择
  47 +// implementation project(path: ':base_matisse')
  48 +// implementation project(path: ':lib_library')
  49 +}
  1 +# Add project specific ProGuard rules here.
  2 +# You can control the set of applied configuration files using the
  3 +# proguardFiles setting in build.gradle.
  4 +#
  5 +# For more details, see
  6 +# http://developer.android.com/guide/developing/tools/proguard.html
  7 +
  8 +# If your project uses WebView with JS, uncomment the following
  9 +# and specify the fully qualified class name to the JavaScript interface
  10 +# class:
  11 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  12 +# public *;
  13 +#}
  14 +
  15 +# Uncomment this to preserve the line number information for
  16 +# debugging stack traces.
  17 +#-keepattributes SourceFile,LineNumberTable
  18 +
  19 +# If you keep the line number information, uncomment this to
  20 +# hide the original source file name.
  21 +#-renamesourcefileattribute SourceFile
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3 + package="com.people.comment">
  4 +
  5 + <uses-permission android:name="android.permission.INTERNET" />
  6 + <uses-permission android:name="android.permission.RECORD_AUDIO" />
  7 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  8 + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  9 + <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
  10 + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  11 + <uses-permission android:name="android.permission.WAKE_LOCK" />
  12 + <uses-permission android:name="android.permission.CAMERA" />
  13 + <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
  14 +
  15 + <application></application>
  16 +
  17 +</manifest>
  1 +package com.people.comment.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.view.LayoutInflater;
  5 +import android.view.View;
  6 +import android.view.ViewGroup;
  7 +
  8 +import androidx.annotation.NonNull;
  9 +import androidx.recyclerview.widget.RecyclerView;
  10 +
  11 +import com.people.comment.R;
  12 +import com.people.comment.view_holder.CommentChildViewHolder;
  13 +import com.people.comment.view_holder.CommentParentViewHolder;
  14 +import com.people.comment.view_holder.CommentTitleViewHolder;
  15 +import com.people.comment.view_holder.EmptyCommentViewHolder;
  16 +import com.people.comment.view_holder.MoreCommentViewHolder;
  17 +import com.people.comment.view_holder.NoMoreCommentViewHolder;
  18 +import com.wd.common.constant.PageNameConstants;
  19 +import com.wd.common.widget.DefaultView;
  20 +import com.wd.foundation.bean.custom.content.CommentItem;
  21 +import com.wd.foundation.wdkitcore.tools.ResUtils;
  22 +
  23 +import java.util.ArrayList;
  24 +import java.util.List;
  25 +
  26 +/**
  27 + * @Author LiuKun
  28 + * @date:2023/5/9
  29 + * @desc:评论适配器 详情页页面底部评论列表布局
  30 + */
  31 +public class CommentListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
  32 + public static final int COMMENT_TYPE_ERROR = -1;
  33 + public static final int COMMENT_TYPE_PARENT = 1;
  34 + public static final int COMMENT_TYPE_CHILD = 2;
  35 + public static final int COMMENT_TYPE_MORE = 3;
  36 + public static final int COMMENT_TYPE_EMPTY = 4;
  37 + public static final int COMMENT_TYPE_FOOTER = 5;
  38 +
  39 + public static final int COMMENT_TYPE_HIGHQUALITY = 6;
  40 +
  41 + /**
  42 + * 标题
  43 + */
  44 + public static final int COMMENT_TYPE_TITLE = 7;
  45 +
  46 +
  47 + private Context context;
  48 + private List<CommentItem> mData = new ArrayList<>();
  49 + private CommentAdapterListener mListener;
  50 + private DefaultView.RetryClickListener retryClickListener;
  51 + private String pageName;
  52 +
  53 + private boolean isDarkMode = false;
  54 + public CommentListAdapter(Context context) {
  55 + mData.clear();
  56 + this.context = context;
  57 + }
  58 +
  59 + public CommentListAdapter(Context context, boolean isDarkMode) {
  60 + mData.clear();
  61 + this.context = context;
  62 + this.isDarkMode = isDarkMode;
  63 + }
  64 +
  65 +
  66 + public CommentListAdapter(Context context, String fromPage) {
  67 + mData.clear();
  68 + this.context = context;
  69 + this.pageName = fromPage;
  70 + }
  71 +
  72 + public void setData(List<CommentItem> data) {
  73 + mData.clear();
  74 + mData.addAll(data);
  75 + notifyDataSetChanged();
  76 + }
  77 +
  78 + public List<CommentItem> getData() {
  79 + return mData;
  80 + }
  81 +
  82 + /**
  83 + * 列表翻页添加数据
  84 + */
  85 + public void addData(List<CommentItem> data, int startPosition) {
  86 + mData.addAll(data);
  87 + notifyItemRangeInserted(startPosition, data.size());
  88 + }
  89 +
  90 + /**
  91 + * 删除单条数据
  92 + */
  93 + public void removeSingleData(int position) {
  94 + mData.remove(position);
  95 + notifyItemRemoved(position);
  96 + notifyDataSetChanged();
  97 + }
  98 +
  99 + /**
  100 + * 删除单条数据
  101 + */
  102 + public void removeData(ArrayList<CommentItem> toRemove) {
  103 + for (int i = toRemove.size() - 1; i >= 0; i--) {
  104 + mData.remove(toRemove.get(i));
  105 + notifyItemRemoved(i);
  106 + }
  107 + notifyDataSetChanged();
  108 + }
  109 +
  110 + /**
  111 + * 按指定位置添加某条数据
  112 + */
  113 + public void addPositionData(int position, CommentItem itemBean) {
  114 + if (isAddEmptyOrErrorData()) {
  115 + mData.clear();
  116 + mData.add(itemBean);
  117 + notifyItemChanged(position);
  118 + } else {
  119 + mData.add(position, itemBean);
  120 + notifyItemRangeInserted(position, 1);
  121 + }
  122 +
  123 + }
  124 +
  125 + /**
  126 + * 插入二级数据
  127 + */
  128 + public void insertData(int startPosition, List<CommentItem> data) {
  129 + mData.addAll(startPosition, data);
  130 + notifyItemRangeInserted(startPosition, data.size());
  131 + }
  132 +
  133 +
  134 + /**
  135 + * 收起二级数据
  136 + */
  137 + public void rangeRemoveData(int startRangePosition, List<CommentItem> removeSecondList) {
  138 + mData.removeAll(removeSecondList);
  139 + notifyItemRangeRemoved(startRangePosition, removeSecondList.size());
  140 + }
  141 +
  142 + /**
  143 + * 清除数据
  144 + */
  145 + public void clearData() {
  146 + mData.clear();
  147 + notifyDataSetChanged();
  148 + }
  149 +
  150 + /**
  151 + * 添加空数据
  152 + */
  153 + public void addEmptyOrErrorData(CommentItem itemBean,int type) {
  154 + mData.clear();
  155 + if(type == 0){
  156 + CommentItem newTitleCommentObj = new CommentItem();
  157 + newTitleCommentObj.setCommentLevel(CommentListAdapter.COMMENT_TYPE_TITLE);
  158 + newTitleCommentObj.setItemType(-1);
  159 + newTitleCommentObj.setItemTitle("评论");
  160 + mData.add(newTitleCommentObj);
  161 + }
  162 + mData.add(itemBean);
  163 + notifyDataSetChanged();
  164 + }
  165 +
  166 + /**
  167 + * 添加没有更多数据
  168 + */
  169 + public void addNoMoreData(CommentItem itemBean) {
  170 + mData.add(itemBean);
  171 + notifyDataSetChanged();
  172 + }
  173 +
  174 + /**
  175 + * 是否已显示空布局
  176 + *
  177 + * @return
  178 + */
  179 + private boolean isAddEmptyOrErrorData() {
  180 + if (!isEmpty(mData) && mData.size() == 1) {
  181 + if (mData.get(0).getCommentLevel() == CommentListAdapter.COMMENT_TYPE_EMPTY
  182 + || (mData.get(0).getCommentLevel() == CommentListAdapter.COMMENT_TYPE_ERROR)) {
  183 + return true;
  184 + }
  185 + }
  186 + return false;
  187 + }
  188 +
  189 + /**
  190 + * 集合是否为空
  191 + */
  192 + public static <D> boolean isEmpty(List<D> list) {
  193 + return list == null || list.isEmpty();
  194 + }
  195 +
  196 + /**
  197 + * 重试按钮
  198 + * @param retryClickListener
  199 + */
  200 + public void setRetryClickListener(DefaultView.RetryClickListener retryClickListener) {
  201 + this.retryClickListener = retryClickListener;
  202 + }
  203 +
  204 + /**
  205 + * 加载数据
  206 + */
  207 + @Override
  208 + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  209 + //上层评论
  210 + if (viewType == COMMENT_TYPE_PARENT) {
  211 + View view = LayoutInflater.from(context).inflate(R.layout.item_comment_parent, parent, false);
  212 + return new CommentParentViewHolder(view, mListener, COMMENT_TYPE_PARENT);
  213 + }
  214 + //子评论
  215 + else if (viewType == COMMENT_TYPE_CHILD) {
  216 + View view = LayoutInflater.from(context).inflate(R.layout.item_comment_child, parent, false);
  217 + return new CommentChildViewHolder(view, mListener, COMMENT_TYPE_CHILD);
  218 + }
  219 + //更多评论
  220 + else if (viewType == COMMENT_TYPE_MORE) {
  221 + View view = LayoutInflater.from(context).inflate(R.layout.item_comment_more, parent, false);
  222 + return new MoreCommentViewHolder(view, mListener);
  223 + }
  224 + //没有更多评论
  225 + else if (viewType == COMMENT_TYPE_FOOTER) {
  226 + View view = LayoutInflater.from(context).inflate(R.layout.item_comment_no_more, parent, false);
  227 + return new NoMoreCommentViewHolder(view, mListener);
  228 + }
  229 + //评论标题
  230 + else if (viewType == COMMENT_TYPE_TITLE) {
  231 + View view = LayoutInflater.from(context).inflate(R.layout.item_comment_title, parent, false);
  232 + return new CommentTitleViewHolder(view);
  233 + }
  234 + //没有评论信息
  235 + else {
  236 + EmptyCommentViewHolder emptyCommentViewHolder;
  237 + View view = LayoutInflater.from(context).inflate(R.layout.item_comment_empty, parent, false);
  238 + if (PageNameConstants.DYNAMIC_DETAIL_PAGE.equals(pageName)||
  239 + PageNameConstants.ARTICLE_DETAIL_PAGE.equals(pageName)) {
  240 + //1、网络问题需要重试,2、默认无数据处理
  241 + if (viewType == COMMENT_TYPE_ERROR){
  242 + emptyCommentViewHolder = new EmptyCommentViewHolder(view,
  243 + (int) ResUtils.getDimension(R.dimen.rmrb_dp32),
  244 + (int) ResUtils.getDimension(R.dimen.rmrb_dp50), (int) ResUtils.getDimension(R.dimen.rmrb_dp258),-1, () -> {
  245 + if (retryClickListener != null){
  246 + retryClickListener.onRetryClick();
  247 + }
  248 + });
  249 + }else {
  250 + emptyCommentViewHolder = new EmptyCommentViewHolder(view,
  251 + (int) ResUtils.getDimension(R.dimen.rmrb_dp32),
  252 + (int) ResUtils.getDimension(R.dimen.rmrb_dp50), (int) ResUtils.getDimension(R.dimen.rmrb_dp258),0, null);
  253 + }
  254 + return emptyCommentViewHolder;
  255 + }else if(PageNameConstants.POLITICS_DETAIL_PAGE.equals(pageName)){
  256 + if (viewType == COMMENT_TYPE_ERROR){
  257 + //网络问题需要重试
  258 + emptyCommentViewHolder = new EmptyCommentViewHolder(view,
  259 + 1, 1
  260 + , (int) ResUtils.getDimension(R.dimen.rmrb_dp258), -1, () -> {
  261 + if (retryClickListener != null){
  262 + retryClickListener.onRetryClick();
  263 + }
  264 + });
  265 + }else {
  266 + emptyCommentViewHolder = new EmptyCommentViewHolder(view,
  267 + 1, 1
  268 + , (int) ResUtils.getDimension(R.dimen.rmrb_dp258),0,null);
  269 + }
  270 +
  271 + return emptyCommentViewHolder;
  272 + }else {
  273 + if (viewType == COMMENT_TYPE_ERROR){
  274 + emptyCommentViewHolder = new EmptyCommentViewHolder(view,
  275 + 1,
  276 + 1, -1, () -> {
  277 + if (retryClickListener != null){
  278 + retryClickListener.onRetryClick();
  279 + }
  280 + });
  281 + }else {
  282 + emptyCommentViewHolder = new EmptyCommentViewHolder(view);
  283 + }
  284 + return emptyCommentViewHolder;
  285 + }
  286 +
  287 + }
  288 + }
  289 +
  290 + @Override
  291 + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
  292 + //父评论
  293 + if (holder instanceof CommentParentViewHolder) {
  294 + if(position == 0){
  295 + ((CommentParentViewHolder) holder).getRoot().setPadding(0,-(int) ResUtils.getDimension(R.dimen.rmrb_dp2)
  296 + ,0,(int) ResUtils.getDimension(R.dimen.rmrb_dp6));
  297 + }else{
  298 + ((CommentParentViewHolder) holder).getRoot().setPadding(0,(int) ResUtils.getDimension(R.dimen.rmrb_dp8)
  299 + ,0,(int) ResUtils.getDimension(R.dimen.rmrb_dp6));
  300 + }
  301 + ((CommentParentViewHolder) holder).updateData(mData.get(position),COMMENT_TYPE_PARENT,isDarkMode);
  302 + }
  303 + //子评论
  304 + else if (holder instanceof CommentChildViewHolder) {
  305 + ((CommentChildViewHolder) holder).updateData(mData.get(position), isDarkMode);
  306 + }
  307 + //二级评论分页查看更多回复
  308 + else if (holder instanceof MoreCommentViewHolder) {
  309 + CommentItem covertCommentBean = mData.get(position);
  310 + String realCommentContent = covertCommentBean.getRealCommentContent();
  311 + boolean showExpandChild = covertCommentBean.isShowExpandChild();
  312 + boolean showCloseChild = covertCommentBean.isShowCloseChild();
  313 + ((MoreCommentViewHolder) holder)
  314 + .setMoreContent(realCommentContent)
  315 + .setExpandVisible(showExpandChild)
  316 + .setCloseTvVisible(showCloseChild);
  317 + }
  318 + //没有更多数据
  319 + else if (holder instanceof NoMoreCommentViewHolder) {
  320 + CommentItem covertCommentBean = mData.get(position);
  321 + ((NoMoreCommentViewHolder) holder).setNoMoreContent(covertCommentBean.getRealCommentContent());
  322 + }
  323 + //标题
  324 + else if (holder instanceof CommentTitleViewHolder) {
  325 + CommentItem covertCommentBean = mData.get(position);
  326 + ((CommentTitleViewHolder) holder).updateData(covertCommentBean);
  327 + }
  328 + }
  329 +
  330 + /**
  331 + * 获取所有数据
  332 + */
  333 + @Override
  334 + public int getItemCount() {
  335 + return mData.size();
  336 + }
  337 +
  338 +
  339 + /**
  340 + * 获取布局类型
  341 + */
  342 + @Override
  343 + public int getItemViewType(int position) {
  344 + CommentItem entity = mData.get(position);
  345 + return entity.getCommentLevel();
  346 + }
  347 +
  348 + /**
  349 + * 设置监听
  350 + */
  351 + public void setCommentAdapterListener(CommentAdapterListener listener) {
  352 + mListener = listener;
  353 + }
  354 +
  355 + /**
  356 + *加载更多
  357 + */
  358 +
  359 +
  360 + /**
  361 + * 接口监听
  362 + */
  363 + public interface CommentAdapterListener {
  364 + /**
  365 + * 回复
  366 + * @param position
  367 + */
  368 + void replyComment(int position);
  369 +
  370 + /**
  371 + * 二级回复
  372 + * @param position
  373 + */
  374 + void loadSecondLevelComment(int position);
  375 +
  376 + /**
  377 + * 关闭展开
  378 + * @param position
  379 + */
  380 + void closeListComment(int position);
  381 +
  382 + /**
  383 + * 点赞
  384 + * @param position
  385 + */
  386 + void commentLike(int position);
  387 +
  388 + /**
  389 + * 点击用户头像
  390 + * @param position
  391 + */
  392 + void clickHead(int position);
  393 +
  394 + /**
  395 + * 点击内容展开、收起
  396 + * @param position
  397 + * @param type
  398 + */
  399 + void clickExpandOrShrink(int position, int type);
  400 +
  401 +
  402 + /**
  403 + * 长按弹窗海报
  404 + * @param position
  405 + */
  406 + void commentLongClick(int position);
  407 + }
  408 +}
  1 +package com.people.comment.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.view.LayoutInflater;
  5 +import android.view.View;
  6 +import android.view.ViewGroup;
  7 +import android.widget.BaseAdapter;
  8 +import android.widget.TextView;
  9 +
  10 +import com.people.comment.R;
  11 +import com.people.comment.bean.EmojiEntity;
  12 +
  13 +import java.util.List;
  14 +
  15 +
  16 +/**
  17 + * @author LiuKun
  18 + * @date 2023/5/2 18:48
  19 + * @Description:表情适配器
  20 + */
  21 +public class ExpressionGridViewAdapter extends BaseAdapter {
  22 +
  23 + private static final int ITEM_LAYOUT_TYPE_COUNT = 2;
  24 + private static final int TYPE_TEXT = 0;
  25 + private static final int TYPE_IMAGE = 1;
  26 + private LayoutInflater inflater;
  27 + private Context context;
  28 + private List<EmojiEntity> emojiList;
  29 +
  30 + public ExpressionGridViewAdapter(Context context, List<EmojiEntity> emojiList) {
  31 + this.context = context;
  32 + this.emojiList = emojiList;
  33 + inflater = LayoutInflater.from(context);
  34 + }
  35 +
  36 + @Override
  37 + public int getCount() {
  38 + return emojiList.size();
  39 + }
  40 +
  41 + @Override
  42 + public EmojiEntity getItem(int position) {
  43 + return emojiList.get(position);
  44 + }
  45 +
  46 + @Override
  47 + public long getItemId(int position) {
  48 + return position;
  49 + }
  50 +
  51 + @Override
  52 + public int getViewTypeCount() {
  53 + return ITEM_LAYOUT_TYPE_COUNT;
  54 + }
  55 +
  56 + @Override
  57 + public int getItemViewType(int position) {
  58 + if (position == 20) {
  59 + return TYPE_IMAGE;
  60 + } else {
  61 + return TYPE_TEXT;
  62 + }
  63 + }
  64 +
  65 + @Override
  66 + public View getView(int position, View convertView, ViewGroup parent) {
  67 + int layoutType = getItemViewType(position);
  68 + if (TYPE_TEXT == layoutType) {
  69 + TextHolder viewHolder;
  70 + if (convertView == null) {
  71 + viewHolder = new TextHolder();
  72 + convertView = inflater.inflate(R.layout.adapter_row_expression, parent, false);
  73 + viewHolder.textView = (TextView) convertView.findViewById(R.id.tv_expression);
  74 + convertView.setTag(viewHolder);
  75 + } else {
  76 + viewHolder = (TextHolder) convertView.getTag();
  77 + }
  78 + viewHolder.textView.setText(getItem(position).code);
  79 + } else if (TYPE_IMAGE == layoutType) {
  80 + if (convertView == null) {
  81 + convertView = inflater.inflate(R.layout.adapter_row_expression_img, parent, false);
  82 + }
  83 + }
  84 +
  85 + return convertView;
  86 + }
  87 +
  88 + private class TextHolder {
  89 + TextView textView;
  90 + }
  91 +
  92 +
  93 +}
  1 +package com.people.comment.adapter;
  2 +
  3 +import android.view.View;
  4 +import android.view.ViewGroup;
  5 +
  6 +import androidx.viewpager.widget.PagerAdapter;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 + * @author LiuKun
  12 + * @date 2023/5/2 18:52
  13 + * @Description:适配器
  14 + */
  15 +public class ExpressionPagerAdapter extends PagerAdapter {
  16 +
  17 + private List<View> views;
  18 +
  19 + public ExpressionPagerAdapter(List<View> views) {
  20 + this.views = views;
  21 + }
  22 +
  23 + @Override
  24 + public int getCount() {
  25 + return views.size();
  26 + }
  27 +
  28 + @Override
  29 + public boolean isViewFromObject(View view, Object object) {
  30 + return view == object;
  31 + }
  32 +
  33 + @Override
  34 + public Object instantiateItem(ViewGroup container, int position) {
  35 + container.addView(views.get(position));
  36 + return views.get(position);
  37 + }
  38 +
  39 + @Override
  40 + public void destroyItem(ViewGroup container, int position, Object object) {
  41 + container.removeView(views.get(position));
  42 + }
  43 +
  44 +}
  1 +package com.people.comment.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.view.LayoutInflater;
  5 +import android.view.View;
  6 +import android.view.ViewGroup;
  7 +import android.widget.BaseAdapter;
  8 +import android.widget.FrameLayout;
  9 +import android.widget.ImageView;
  10 +
  11 +import com.people.comment.R;
  12 +import com.wd.common.imageglide.ImageUtils;
  13 +import com.wd.foundation.wdkit.utils.ScreenUtils;
  14 +
  15 +import java.util.ArrayList;
  16 +import java.util.List;
  17 +
  18 +/**
  19 + * @author qtiansheng
  20 + * @date 2024/2/6
  21 + * @Description 定制表情况图片适配器
  22 + * @doc
  23 + */
  24 +public class ImageAdapter extends BaseAdapter {
  25 + private Context mContext;
  26 + /**
  27 + * 图片资源ID数组
  28 + */
  29 + private List<String> mImageUrls;
  30 +
  31 + private LayoutInflater inflater;
  32 +
  33 + /**
  34 + * 构造函数
  35 + * @param context
  36 + * @param gifIcons
  37 + */
  38 + public ImageAdapter(Context context, List<String> gifIcons) {
  39 + mContext = context;
  40 + mImageUrls = new ArrayList<String>();
  41 + if(gifIcons!= null && !gifIcons.isEmpty()) {
  42 + mImageUrls.addAll(gifIcons);
  43 + }
  44 + inflater = LayoutInflater.from(mContext);
  45 + }
  46 +
  47 + @Override
  48 + public int getCount() {
  49 + if(mImageUrls != null && mImageUrls.size() > 0){
  50 + return mImageUrls.size();
  51 + }else{
  52 + return 0;
  53 + }
  54 +
  55 + }
  56 +
  57 + @Override
  58 + public Object getItem(int position) {
  59 + return position;
  60 + }
  61 +
  62 + @Override
  63 + public long getItemId(int position) {
  64 + return position;
  65 + }
  66 +
  67 + @Override
  68 + public View getView(int position, View convertView, ViewGroup parent) {
  69 + ImageHolder viewHolder;
  70 + if (convertView == null) {
  71 + viewHolder = new ImageHolder();
  72 + convertView = inflater.inflate(R.layout.item_emoji_gif, parent, false);
  73 + viewHolder.imgLayout = (FrameLayout) convertView.findViewById(R.id.layout_gif);
  74 + viewHolder.imageView = (ImageView) convertView.findViewById(R.id.iv_gifview);
  75 + convertView.setTag(viewHolder);
  76 + } else {
  77 + viewHolder = (ImageHolder) convertView.getTag();
  78 + }
  79 +
  80 + //最后一行设置下滑动间距
  81 + if(position == getCount() - 1){
  82 + ViewGroup.LayoutParams layoutParams = (ViewGroup.LayoutParams) viewHolder.imgLayout.getLayoutParams();
  83 + layoutParams.height = ScreenUtils.dpToPx(80);
  84 + viewHolder.imgLayout.setLayoutParams(layoutParams);
  85 + viewHolder.imgLayout.setPadding(0,0,0,ScreenUtils.dpToPx(20));
  86 + }
  87 +
  88 + // 设置图片资源ID对应的图片资源到ImageView中
  89 + ImageUtils.getInstance().loadImageCanSameUrl(viewHolder.imageView,mImageUrls.get(position));
  90 +
  91 + return convertView;
  92 + }
  93 +
  94 + public void setDataList(List<String> listStr) {
  95 + mImageUrls.clear();
  96 + mImageUrls.addAll(listStr);
  97 + notifyDataSetChanged();
  98 + }
  99 +
  100 + private class ImageHolder {
  101 + FrameLayout imgLayout;
  102 + ImageView imageView;
  103 + }
  104 +
  105 +}
  1 +package com.people.comment.adapter;
  2 +
  3 +
  4 +import android.graphics.Typeface;
  5 +import android.text.Spannable;
  6 +import android.text.SpannableStringBuilder;
  7 +import android.text.TextPaint;
  8 +import android.text.TextUtils;
  9 +import android.text.method.LinkMovementMethod;
  10 +import android.text.style.ClickableSpan;
  11 +import android.text.style.StyleSpan;
  12 +import android.view.Gravity;
  13 +import android.view.View;
  14 +import android.widget.ImageView;
  15 +import android.widget.LinearLayout;
  16 +import android.widget.TextView;
  17 +
  18 +import androidx.annotation.NonNull;
  19 +import androidx.constraintlayout.widget.ConstraintLayout;
  20 +import androidx.core.content.ContextCompat;
  21 +
  22 +import com.chad.library.adapter.base.BaseViewHolder;
  23 +import com.people.comment.R;
  24 +import com.wd.common.base.BaseSplitAdapter;
  25 +import com.wd.common.imageglide.ImageUtils;
  26 +import com.wd.common.viewclick.BaseClickListener;
  27 +import com.wd.common.widget.ExpandableTextView;
  28 +import com.wd.foundation.bean.custom.content.CommentItem;
  29 +import com.wd.foundation.bean.response.ParentCommentVoBean;
  30 +import com.wd.foundation.bean.utils.TimeUtil;
  31 +import com.wd.foundation.wdkit.perloader.DeviceHelper;
  32 +import com.wd.foundation.wdkit.utils.NumberStrUtils;
  33 +import com.wd.foundation.wdkit.view.AnimationView;
  34 +import com.wd.foundation.wdkit.view.RoundImageView;
  35 +import com.wd.foundation.wdkitcore.tools.AppContext;
  36 +import com.wd.foundation.wdkitcore.tools.StringUtils;
  37 +
  38 +/**
  39 + * 查看自己/他人的评论列表适配器
  40 + * * @author ouyang
  41 + * * @version [V1.0.0, 2023/5/10]
  42 + */
  43 +public class MyCommentListAdapter extends BaseSplitAdapter<CommentItem, BaseViewHolder> {
  44 +
  45 +
  46 + public OnAdapterClickListener mOnAdapterClickListener;
  47 +
  48 + public OnMyLongClickListener mOnMyLongClickListener;
  49 + /**
  50 + * 加V
  51 + */
  52 + private String authIcon;
  53 + /**
  54 + * 荣誉头像框
  55 + */
  56 + private String honoraryIcon;
  57 + /**
  58 + * 等级头像框
  59 + */
  60 + private String levelIcon;
  61 +
  62 + public MyCommentListAdapter() {
  63 + super(R.layout.item_my_comment_list);
  64 +// addChildClickViewIds(R.id.tv_original_news_title,R.id.iv_like);
  65 + }
  66 +
  67 +
  68 + @Override
  69 + protected void convert(@NonNull BaseViewHolder baseViewHolder, CommentItem item) {
  70 + if (item==null) {
  71 + return;
  72 + }
  73 +
  74 + ConstraintLayout cl_root = baseViewHolder.getView(R.id.cl_root);
  75 + ConstraintLayout cl_bottom = baseViewHolder.getView(R.id.cl_bottom);
  76 +
  77 + RoundImageView iv_header_image = baseViewHolder.getView(R.id.iv_header_image);
  78 + //头像
  79 + if (item != null && StringUtils.isNotBlank(item.getFromUserType()) && !"1".equals(item.getFromUserType())){
  80 + ImageUtils.getInstance().
  81 + loadImageCircle(iv_header_image, item.getFromUserHeader(), R.mipmap.icon_default_head_mater);
  82 + }else {
  83 + ImageUtils.getInstance().
  84 + loadImageCircle(iv_header_image, item.getFromUserHeader(), R.mipmap.icon_default_head);
  85 + }
  86 + //加V
  87 + ImageView ivvip = baseViewHolder.getView(R.id.ivvip);
  88 + if(TextUtils.isEmpty(authIcon)){
  89 + ivvip.setVisibility(View.GONE);
  90 + }else{
  91 + ImageUtils.getInstance().loadImage(ivvip, authIcon);
  92 + ivvip.setVisibility(View.VISIBLE);
  93 + }
  94 + //头像框
  95 + ImageView ivAvatarFrame = baseViewHolder.getView(R.id.iv_avatar_frame);
  96 + setUserAvatarFrame(ivAvatarFrame, item);
  97 +
  98 + TextView tv_name = baseViewHolder.getView(R.id.tv_name);
  99 + tv_name.setText(StringUtils.getStringValue(item.getFromUserName()));
  100 + tv_name.getPaint().setFakeBoldText(true);
  101 +
  102 + TextView tv_date = baseViewHolder.getView(R.id.tv_date);
  103 + setTime(tv_date, TimeUtil.converTimeForm(item.getCreateTime()));
  104 +
  105 + LinearLayout ll_like = baseViewHolder.getView(R.id.ll_like);
  106 + TextView tv_like_number = baseViewHolder.getView(R.id.tv_like_number);
  107 + tv_like_number.getPaint().setFakeBoldText(true);
  108 + AnimationView iv_like = baseViewHolder.getView(R.id.iv_like);
  109 + setLikeData(ll_like,tv_like_number,iv_like,item.getLikeNum(),item.getLikeStatus(),item.getCheckStatus());
  110 +
  111 + ExpandableTextView tv_my_content = baseViewHolder.getView(R.id.tv_my_content);
  112 + setContent(tv_my_content,item);
  113 + //我的评论动画表情
  114 + ImageView ivMyComment = baseViewHolder.getView(R.id.iv_my_comment);
  115 + setContentPic(ivMyComment,item.getCommentPics());
  116 +
  117 + ExpandableTextView tv_original_comment_content = baseViewHolder.getView(R.id.tv_original_comment_content);
  118 + View line_view = baseViewHolder.getView(R.id.line_view);
  119 +
  120 + //评论所属内容的删除状态,0:有效;1:删除
  121 + TextView tv_original_news_title = baseViewHolder.getView(R.id.tv_original_news_title);
  122 + int targetStatus = item.getTargetStatus();
  123 + if (targetStatus==0) {
  124 + tv_original_news_title.setText(StringUtils.getStringValue(item.getTargetTitle()));
  125 +// tv_original_news_title.setTextColor(ContextCompat.getColor(getContext(),R.color.res_color_common_C1));
  126 + tv_original_news_title.setGravity(Gravity.LEFT);
  127 + }else{
  128 + tv_original_news_title.setText("抱歉,原内容已被删除");
  129 + tv_original_news_title.setGravity(Gravity.CENTER);
  130 + }
  131 + tv_original_news_title.setTextColor(ContextCompat.getColor(AppContext.getContext(),R.color.res_color_common_C2));
  132 +
  133 + ParentCommentVoBean mParentCommentVoBean = item.getParentCommentVo();
  134 + if (mParentCommentVoBean==null) {
  135 + tv_original_comment_content.setVisibility(View.GONE);
  136 + line_view.setVisibility(View.GONE);
  137 + }else{
  138 + tv_original_comment_content.setVisibility(View.VISIBLE);
  139 + line_view.setVisibility(View.VISIBLE);
  140 + String user_name = mParentCommentVoBean.getFromUserName();
  141 + handleOriginalCommentContent(tv_original_comment_content,"@"+user_name+": "+mParentCommentVoBean.getCommentContent(),user_name.length()+2);
  142 + }
  143 + View bottomLine = baseViewHolder.getView(R.id.line_bottom);
  144 + int position = getItemPosition(item);
  145 + //设置分割线
  146 + int itemCount = getItemCount();
  147 + if(itemCount > 1 && position == itemCount - 2){
  148 + bottomLine.setVisibility(View.GONE);
  149 + }else {
  150 + bottomLine.setVisibility(View.VISIBLE);
  151 + }
  152 + MyOnLongClickListener mMyOnLongClickListener = new MyOnLongClickListener(position);
  153 + cl_root.setOnLongClickListener(mMyOnLongClickListener);
  154 + tv_my_content.setOnLongClickListener(mMyOnLongClickListener);
  155 + cl_bottom.setOnLongClickListener(mMyOnLongClickListener);
  156 + }
  157 +
  158 + /**
  159 + * 设置评论图片
  160 + */
  161 + public void setContentPic(ImageView ivMyComment, String picUrl) {
  162 + if (null == ivMyComment){
  163 + return;
  164 + }
  165 + if (!TextUtils.isEmpty(picUrl)) {
  166 + ivMyComment.setVisibility(View.VISIBLE);
  167 + if (picUrl.contains(",")) {
  168 + picUrl = picUrl.split(",")[0];
  169 + }
  170 + ImageUtils.getInstance().loadImageHighLev(ivMyComment, picUrl, R.drawable.rmrb_placeholder_compe_all);
  171 + } else {
  172 + ivMyComment.setVisibility(View.GONE);
  173 + }
  174 + }
  175 +
  176 + public void setAuthIcon(String authIcon) {
  177 + this.authIcon = authIcon;
  178 + }
  179 +
  180 + public void setHonoraryIcon(String honoraryIcon) {
  181 + this.honoraryIcon = honoraryIcon;
  182 + }
  183 +
  184 + public void setLevelIcon(String levelIcon) {
  185 + this.levelIcon = levelIcon;
  186 + }
  187 +
  188 + private void setUserAvatarFrame(ImageView ivAvatarFrame, CommentItem item){
  189 + ivAvatarFrame.setVisibility(View.GONE);
  190 + if ("1".equals(item.getFromUserType())){
  191 + // V>普通用户显示最佳评论员>等级头像框
  192 + if (StringUtils.isBlank(authIcon)){
  193 + if (StringUtils.isNotBlank(item.avatarFrame)){
  194 + ImageUtils.getInstance().loadImage(ivAvatarFrame,item.avatarFrame);
  195 + ivAvatarFrame.setVisibility(View.VISIBLE);
  196 + }else if (StringUtils.isNotBlank(levelIcon)){
  197 + ImageUtils.getInstance().loadImage(ivAvatarFrame,levelIcon);
  198 + ivAvatarFrame.setVisibility(View.VISIBLE);
  199 + }
  200 + }
  201 + }else {
  202 + // 号主显示荣誉头像,V>最佳评论员头像,不显示等级框
  203 + if (StringUtils.isNotBlank(honoraryIcon)){
  204 + ImageUtils.getInstance().loadImage(ivAvatarFrame,honoraryIcon);
  205 + ivAvatarFrame.setVisibility(View.VISIBLE);
  206 + }else {
  207 + //没有荣誉框且没有V才显示最佳评论员
  208 + if (StringUtils.isBlank(authIcon) && StringUtils.isNotBlank(item.avatarFrame)){
  209 + ImageUtils.getInstance().loadImage(ivAvatarFrame,item.avatarFrame);
  210 + ivAvatarFrame.setVisibility(View.VISIBLE);
  211 + }
  212 + }
  213 + }
  214 + }
  215 +
  216 + /**
  217 + * 长按事件
  218 + */
  219 + private class MyOnLongClickListener implements View.OnLongClickListener {
  220 + private int position;
  221 +
  222 + public MyOnLongClickListener(int position){
  223 + this.position = position;
  224 + }
  225 +
  226 + @Override
  227 + public boolean onLongClick(View v) {
  228 + if (mOnMyLongClickListener!=null) {
  229 + return mOnMyLongClickListener.OnMyLongClick(position);
  230 + }else{
  231 + return false;
  232 + }
  233 + }
  234 + }
  235 +
  236 +
  237 +
  238 + /**
  239 + * 设置评论内容
  240 + */
  241 + public void setContent(ExpandableTextView tv_my_content, CommentItem item) {
  242 + String content = item.getRealCommentContent();
  243 + int expandableStatus = item.getExpandableStatus();
  244 + if (!StringUtils.isBlank(content)) {
  245 + tv_my_content.setVisibility(View.VISIBLE);
  246 + tv_my_content.updateForRecyclerView(content, DeviceHelper.getRealWidth(AppContext.getContext()), expandableStatus);
  247 + //描述内容
  248 + tv_my_content.setExpandListener(new ExpandableTextView.OnExpandListener() {
  249 + int bindingAdapterPosition = getItemPosition(item);
  250 +
  251 + @Override
  252 + public void onExpand(ExpandableTextView view) {
  253 + if(mOnAdapterClickListener !=null){
  254 + mOnAdapterClickListener.clickExpandOrShrink(bindingAdapterPosition, ExpandableTextView.STATE_EXPAND);
  255 + }
  256 + }
  257 +
  258 + @Override
  259 + public void onShrink(ExpandableTextView view) {
  260 + if (mOnAdapterClickListener != null) {
  261 + mOnAdapterClickListener.clickExpandOrShrink(bindingAdapterPosition, ExpandableTextView.STATE_SHRINK);
  262 + }
  263 + }
  264 + });
  265 + } else {
  266 + tv_my_content.setVisibility(View.GONE);
  267 + }
  268 + }
  269 +
  270 +
  271 + public void setLikeData(LinearLayout ll_like,TextView tv_like_number,AnimationView iv_like,String likeNum, int likeStatus, int checkStatus) {
  272 + iv_like.setNeedLogin(true);
  273 + //checkStatus评论审核状态,0:未审核;1:审核中;2:通过;3:不通过 只有审核通过的才显示回复按钮
  274 +// if (checkStatus==2) {
  275 + ll_like.setVisibility(View.VISIBLE);
  276 + if (TextUtils.isEmpty(likeNum) || "0".equals(likeNum)) {
  277 + tv_like_number.setVisibility(View.GONE);
  278 + }else{
  279 + tv_like_number.setVisibility(View.VISIBLE);
  280 + tv_like_number.setText(NumberStrUtils.Companion.getINSTANCE().handlerNumber(String.valueOf(likeNum)));
  281 + }
  282 + if (likeStatus == 1) {
  283 + iv_like.setSelected(true);
  284 + tv_like_number.setTextColor(ContextCompat.getColor(AppContext.getContext(),R.color.res_color_common_C11));
  285 + }else{
  286 + iv_like.setSelected(false);
  287 + tv_like_number.setTextColor(ContextCompat.getColor(AppContext.getContext(),R.color.res_color_common_C2));
  288 + }
  289 +// }else{
  290 +// ll_like.setVisibility(View.GONE);
  291 +// }
  292 + }
  293 +
  294 + /**
  295 + * 设置评论时间
  296 + */
  297 + public void setTime(TextView tv_date,String adapterCommentDate) {
  298 + if (!TextUtils.isEmpty(adapterCommentDate)) {
  299 + tv_date.setVisibility(View.VISIBLE);
  300 + tv_date.setText(adapterCommentDate);
  301 + } else {
  302 + tv_date.setVisibility(View.GONE);
  303 + }
  304 + }
  305 +
  306 +
  307 + private void handleOriginalCommentContent(TextView tv_original_comment_content, String value, int handleLength) {
  308 +
  309 + if (StringUtils.isBlank(value)) {
  310 + return;
  311 + }
  312 + if (value.length() < handleLength) {
  313 + return;
  314 + }
  315 +
  316 + SpannableStringBuilder builder = new SpannableStringBuilder(value);
  317 +
  318 + builder.setSpan(new StyleSpan(Typeface.BOLD), 0, handleLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
  319 + //设置文本点击事件
  320 + builder.setSpan(new PrivacyPolicyDialogClickSpannable(new BaseClickListener() {
  321 + @Override
  322 + protected void onNoDoubleClick(View v) {
  323 + if(mOnAdapterClickListener !=null){
  324 + mOnAdapterClickListener.OnClickName();
  325 + }
  326 + }
  327 + }), 0, handleLength,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
  328 +
  329 + tv_original_comment_content.setMovementMethod(LinkMovementMethod.getInstance());
  330 + tv_original_comment_content.setText(builder);
  331 + }
  332 +
  333 + private int getItemPosition(CommentItem item) {
  334 + return item != null && this.mData != null && !this.mData.isEmpty() ? this.mData.indexOf(item) : -1;
  335 + }
  336 +
  337 +
  338 + /**
  339 + * SpannableStringBuilder 点击事件
  340 + */
  341 + public class PrivacyPolicyDialogClickSpannable extends ClickableSpan implements
  342 + View.OnClickListener {
  343 +
  344 + private BaseClickListener onClickListener;
  345 +
  346 + public PrivacyPolicyDialogClickSpannable(BaseClickListener onClickListener) {
  347 + this.onClickListener = onClickListener;
  348 + }
  349 +
  350 + @Override
  351 + public void onClick(View widget) {
  352 +// onClickListener.onClick(widget);
  353 + }
  354 +
  355 + @Override
  356 + public void updateDrawState(TextPaint ds) {
  357 +
  358 + }
  359 +
  360 + }
  361 +
  362 +
  363 +
  364 +
  365 + public void setOnAdapterClickListener(OnAdapterClickListener mOnClickNameListener){
  366 + this.mOnAdapterClickListener = mOnClickNameListener;
  367 + }
  368 +
  369 +
  370 + public void setOnMyLongClickListener(OnMyLongClickListener mOnMyLongClickListener){
  371 + this.mOnMyLongClickListener = mOnMyLongClickListener;
  372 + }
  373 +
  374 + public interface OnAdapterClickListener{
  375 + void OnClickName();
  376 + /**
  377 + * 点击内容展开、收起
  378 + */
  379 + void clickExpandOrShrink(int position, int type);
  380 + }
  381 +
  382 +
  383 + public interface OnMyLongClickListener{
  384 + boolean OnMyLongClick(int position);
  385 + }
  386 +}
  1 +package com.people.comment.adapter;
  2 +
  3 +import android.graphics.Typeface;
  4 +import android.text.Spannable;
  5 +import android.text.SpannableStringBuilder;
  6 +import android.text.TextPaint;
  7 +import android.text.TextUtils;
  8 +import android.text.method.LinkMovementMethod;
  9 +import android.text.style.ClickableSpan;
  10 +import android.text.style.StyleSpan;
  11 +import android.view.Gravity;
  12 +import android.view.View;
  13 +import android.widget.ImageView;
  14 +import android.widget.TextView;
  15 +import androidx.annotation.NonNull;
  16 +import androidx.constraintlayout.widget.ConstraintLayout;
  17 +import androidx.core.content.ContextCompat;
  18 +
  19 +import com.chad.library.adapter.base.BaseViewHolder;
  20 +import com.people.comment.R;
  21 +import com.wd.common.base.BaseSplitAdapter;
  22 +import com.wd.common.imageglide.ImageUtils;
  23 +import com.wd.common.viewclick.BaseClickListener;
  24 +import com.wd.common.widget.ExpandableTextView;
  25 +import com.wd.foundation.bean.custom.content.CommentItem;
  26 +import com.wd.foundation.bean.music.bean.VoicePlayerBean;
  27 +import com.wd.foundation.bean.response.ParentCommentVoBean;
  28 +import com.wd.foundation.wdkit.perloader.DeviceHelper;
  29 +import com.wd.foundation.wdkitcore.tools.AppContext;
  30 +import com.wd.foundation.wdkitcore.tools.StringUtils;
  31 +
  32 +/**
  33 + * 游客评论列表适配器
  34 + * @author baozhaoxin
  35 + * @version [V1.0.0, 2024/1/22]
  36 + * @since V1.0.0
  37 + */
  38 +public class VisitorCommentListAdapter extends BaseSplitAdapter<CommentItem, BaseViewHolder> {
  39 +
  40 + private OnAdapterClickListener mOnAdapterClickListener;
  41 +
  42 + public OnMyLongClickListener mOnMyLongClickListener;
  43 +
  44 + public VisitorCommentListAdapter() {
  45 + super(R.layout.item_visitor_comment_list);
  46 +// addChildClickViewIds(R.id.tv_original_news_title);
  47 + }
  48 +
  49 + @Override
  50 + protected void convert(@NonNull BaseViewHolder baseViewHolder, CommentItem item) {
  51 + if (item == null) {
  52 + return;
  53 + }
  54 +
  55 + ConstraintLayout cl_root = baseViewHolder.getView(R.id.cl_root);
  56 + ConstraintLayout cl_bottom = baseViewHolder.getView(R.id.cl_bottom);
  57 +
  58 + ExpandableTextView tv_my_content = baseViewHolder.getView(R.id.tv_my_content);
  59 + setContent(tv_my_content,item);
  60 +
  61 + //我的评论动画表情
  62 + ImageView ivMyComment = baseViewHolder.getView(R.id.iv_my_comment);
  63 + setContentPic(ivMyComment,item.getCommentPics());
  64 +
  65 + ExpandableTextView tv_original_comment_content = baseViewHolder.getView(R.id.tv_original_comment_content);
  66 + View line_view = baseViewHolder.getView(R.id.line_view);
  67 +
  68 + View bottomLine = baseViewHolder.getView(R.id.line_bottom);
  69 +
  70 + //评论所属内容的删除状态,0:有效;1:删除
  71 + TextView tv_original_news_title = baseViewHolder.getView(R.id.tv_original_news_title);
  72 + int targetStatus = item.getTargetStatus();
  73 + if (targetStatus==0) {
  74 + tv_original_news_title.setText(StringUtils.getStringValue(item.getTargetTitle()));
  75 +// tv_original_news_title.setTextColor(ContextCompat.getColor(getContext(),R.color.res_color_common_C1));
  76 + tv_original_news_title.setGravity(Gravity.LEFT);
  77 + }else{
  78 + tv_original_news_title.setText("抱歉,原内容已被删除");
  79 + tv_original_news_title.setGravity(Gravity.CENTER);
  80 + }
  81 + tv_original_news_title.setTextColor(ContextCompat.getColor(AppContext.getContext(),R.color.res_color_common_C2));
  82 +
  83 + ParentCommentVoBean mParentCommentVoBean = item.getParentCommentVo();
  84 + if (mParentCommentVoBean==null) {
  85 + tv_original_comment_content.setVisibility(View.GONE);
  86 + line_view.setVisibility(View.GONE);
  87 + }else{
  88 + tv_original_comment_content.setVisibility(View.VISIBLE);
  89 + line_view.setVisibility(View.VISIBLE);
  90 + String user_name = mParentCommentVoBean.getFromUserName();
  91 + handleOriginalCommentContent(tv_original_comment_content,"@"+user_name+": "+mParentCommentVoBean.getCommentContent(),user_name.length()+2);
  92 + }
  93 +
  94 + int position = getItemPosition(item);
  95 + //设置分割线
  96 + int itemCount = getItemCount();
  97 + if(itemCount > 1 && position == itemCount - 2){
  98 + bottomLine.setVisibility(View.GONE);
  99 + }else {
  100 + bottomLine.setVisibility(View.VISIBLE);
  101 + }
  102 + MyOnLongClickListener mMyOnLongClickListener = new MyOnLongClickListener(position);
  103 + cl_root.setOnLongClickListener(mMyOnLongClickListener);
  104 + tv_my_content.setOnLongClickListener(mMyOnLongClickListener);
  105 + cl_bottom.setOnLongClickListener(mMyOnLongClickListener);
  106 +
  107 + }
  108 +
  109 + /**
  110 + * 设置评论图片
  111 + */
  112 + public void setContentPic(ImageView ivMyComment, String picUrl) {
  113 + if (null == ivMyComment){
  114 + return;
  115 + }
  116 + if (!TextUtils.isEmpty(picUrl)) {
  117 + ivMyComment.setVisibility(View.VISIBLE);
  118 + if (picUrl.contains(",")) {
  119 + picUrl = picUrl.split(",")[0];
  120 + }
  121 + ImageUtils.getInstance().loadImageHighLev(ivMyComment, picUrl, R.drawable.rmrb_placeholder_compe_all);
  122 + } else {
  123 + ivMyComment.setVisibility(View.GONE);
  124 + }
  125 + }
  126 +
  127 + /**
  128 + * 设置评论内容
  129 + */
  130 + public void setContent(ExpandableTextView tv_my_content, CommentItem item) {
  131 + String content = item.getRealCommentContent();
  132 + int expandableStatus = item.getExpandableStatus();
  133 + if (!StringUtils.isBlank(content)) {
  134 + tv_my_content.setVisibility(View.VISIBLE);
  135 + tv_my_content.updateForRecyclerView(content, DeviceHelper.getRealWidth(AppContext.getContext()), expandableStatus);
  136 + //描述内容
  137 + tv_my_content.setExpandListener(new ExpandableTextView.OnExpandListener() {
  138 + int bindingAdapterPosition = getItemPosition(item);
  139 +
  140 + @Override
  141 + public void onExpand(ExpandableTextView view) {
  142 + if(mOnAdapterClickListener !=null){
  143 + mOnAdapterClickListener.clickExpandOrShrink(bindingAdapterPosition, ExpandableTextView.STATE_EXPAND);
  144 + }
  145 + }
  146 +
  147 + @Override
  148 + public void onShrink(ExpandableTextView view) {
  149 + if (mOnAdapterClickListener != null) {
  150 + mOnAdapterClickListener.clickExpandOrShrink(bindingAdapterPosition, ExpandableTextView.STATE_SHRINK);
  151 + }
  152 + }
  153 + });
  154 + } else {
  155 + tv_my_content.setVisibility(View.GONE);
  156 + }
  157 + }
  158 +
  159 + private void handleOriginalCommentContent(TextView tv_original_comment_content, String value, int handleLength) {
  160 +
  161 + if (StringUtils.isBlank(value)) {
  162 + return;
  163 + }
  164 + if (value.length() < handleLength) {
  165 + return;
  166 + }
  167 +
  168 + SpannableStringBuilder builder = new SpannableStringBuilder(value);
  169 +
  170 + builder.setSpan(new StyleSpan(Typeface.BOLD), 0, handleLength, Spannable.SPAN_INCLUSIVE_INCLUSIVE);
  171 + //设置文本点击事件
  172 + builder.setSpan(new PrivacyPolicyDialogClickSpannable(new BaseClickListener() {
  173 + @Override
  174 + protected void onNoDoubleClick(View v) {
  175 + if(mOnAdapterClickListener !=null){
  176 + mOnAdapterClickListener.OnClickName();
  177 + }
  178 + }
  179 + }), 0, handleLength,Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
  180 +
  181 + tv_original_comment_content.setMovementMethod(LinkMovementMethod.getInstance());
  182 + tv_original_comment_content.setText(builder);
  183 + }
  184 +
  185 + private int getItemPosition(CommentItem item) {
  186 + return item != null && this.mData != null && !this.mData.isEmpty() ? this.mData.indexOf(item) : -1;
  187 + }
  188 +
  189 + /**
  190 + * SpannableStringBuilder 点击事件
  191 + */
  192 + public class PrivacyPolicyDialogClickSpannable extends ClickableSpan implements
  193 + View.OnClickListener {
  194 +
  195 + private BaseClickListener onClickListener;
  196 +
  197 + public PrivacyPolicyDialogClickSpannable(BaseClickListener onClickListener) {
  198 + this.onClickListener = onClickListener;
  199 + }
  200 +
  201 + @Override
  202 + public void onClick(View widget) {
  203 +// onClickListener.onClick(widget);
  204 + }
  205 +
  206 + @Override
  207 + public void updateDrawState(TextPaint ds) {
  208 +
  209 + }
  210 + }
  211 +
  212 + /**
  213 + * 长按事件
  214 + */
  215 + private class MyOnLongClickListener implements View.OnLongClickListener {
  216 + private int position;
  217 +
  218 + public MyOnLongClickListener(int position){
  219 + this.position = position;
  220 + }
  221 +
  222 + @Override
  223 + public boolean onLongClick(View v) {
  224 + if (mOnMyLongClickListener!=null) {
  225 + return mOnMyLongClickListener.OnMyLongClick(position);
  226 + }else{
  227 + return false;
  228 + }
  229 + }
  230 + }
  231 +
  232 + public void setOnAdapterClickListener(OnAdapterClickListener mOnClickNameListener){
  233 + this.mOnAdapterClickListener = mOnClickNameListener;
  234 + }
  235 +
  236 + public void setOnMyLongClickListener(OnMyLongClickListener mOnMyLongClickListener){
  237 + this.mOnMyLongClickListener = mOnMyLongClickListener;
  238 + }
  239 +
  240 + public interface OnAdapterClickListener{
  241 + void OnClickName();
  242 + /**
  243 + * 点击内容展开、收起
  244 + */
  245 + void clickExpandOrShrink(int position, int type);
  246 + }
  247 +
  248 + public interface OnMyLongClickListener{
  249 + boolean OnMyLongClick(int position);
  250 + }
  251 +}
  1 +package com.people.comment.bean;
  2 +
  3 +
  4 +import androidx.annotation.IntDef;
  5 +
  6 +/**
  7 + * @author LiuKun
  8 + * @date 2023/5/15 15:30
  9 + * @Description:弹出框
  10 + */
  11 +@IntDef({CommentClickShowType.reply, CommentClickShowType.share, CommentClickShowType.copy, CommentClickShowType.delete, CommentClickShowType.report})
  12 +public @interface CommentClickShowType {
  13 + int reply = 0;
  14 + int share = 1;
  15 + int copy = 2;
  16 + int delete = 3;
  17 + int report = 4;
  18 +}
  1 +package com.people.comment.bean;
  2 +
  3 +import java.util.ArrayList;
  4 +
  5 +/**
  6 + * @Author LiuKun
  7 + * @date:2023/5/2
  8 + * @desc:消息透传实体类
  9 + */
  10 +public class CommentEventBean {
  11 + public static class AudioPermissionApply {
  12 + public boolean result;
  13 +
  14 + public AudioPermissionApply(boolean result) {
  15 + this.result = result;
  16 + }
  17 + }
  18 +
  19 + public static class ImageUploadCallback {
  20 + public ArrayList<String> images;
  21 +
  22 + public ImageUploadCallback(ArrayList<String> images) {
  23 + this.images = images;
  24 + }
  25 + }
  26 +}
  1 +package com.people.comment.bean;
  2 +
  3 +/**
  4 + * @author LiuKun
  5 + * @date 2023/5/2 18:46
  6 + * @Description:表情
  7 + */
  8 +public class EmojiEntity {
  9 +
  10 + public String code;
  11 +
  12 + public EmojiEntity(String code) {
  13 + this.code = code;
  14 + }
  15 +}
  1 +package com.people.comment.comment.listener;
  2 +
  3 +import com.wd.foundation.bean.response.SpeechTokenBean;
  4 +import com.wd.foundation.wdkit.mvvm.vm.IVMCallback;
  5 +
  6 +
  7 +/**
  8 + * @author LiuKun
  9 + * @date 2023/5/5 14:39
  10 + * @Description:阿里监听
  11 + */
  12 +public interface AliTokenListener extends IVMCallback {
  13 +
  14 + /**
  15 + * @param SpeechTokenBean
  16 + */
  17 + void onGetTokenSuccess(SpeechTokenBean SpeechTokenBean);
  18 +
  19 + /**
  20 + * @param error 错误信息
  21 + */
  22 + void onGetTokenFailed(String error);
  23 +}
  1 +package com.people.comment.comment.listener;
  2 +
  3 +
  4 +import com.wd.foundation.bean.comment.CommentListBean;
  5 +import com.wd.foundation.wdkit.mvvm.vm.IVMCallback;
  6 +
  7 +/**
  8 + * 游客评论
  9 + * @author baozhaoxin
  10 + * @version [V1.0.0, 2024/1/22]
  11 + * @since V1.0.0
  12 + */
  13 +public interface IVisitorCommentDataListener extends IVMCallback {
  14 + /**
  15 + * 获取评论列表成功
  16 + *
  17 + * @param commentList 列表
  18 + */
  19 + void onGetCommentListSuccess(CommentListBean commentList);
  20 +
  21 + /**
  22 + * 获取评论失列表败
  23 + *
  24 + * @param msg 消息
  25 + */
  26 + void onGetCommentListFail(String msg);
  27 +}
  1 +package com.people.comment.comment.model;
  2 +
  3 +
  4 +import android.text.TextUtils;
  5 +
  6 +import com.people.comment.adapter.CommentListAdapter;
  7 +import com.people.comment.listener.BatchMyCommentListLikeStatusListener;
  8 +import com.people.comment.listener.DeleteMyCommentListListener;
  9 +import com.people.comment.listener.MyCommentListDataListener;
  10 +import com.people.comment.listener.SubmitMyCommentListListener;
  11 +import com.wd.capability.network.BaseObserver;
  12 +import com.wd.capability.network.bean.MetaBean;
  13 +import com.wd.capability.network.constant.EventConstants;
  14 +import com.wd.capability.network.constant.ParameterConstant;
  15 +import com.wd.capability.network.fetcher.BaseDataFetcher;
  16 +import com.wd.capability.network.response.BaseResponse;
  17 +import com.wd.common.api.RequestApi;
  18 +import com.wd.common.incentive.constants.TaskOperateTypeConstants;
  19 +import com.wd.common.incentive.task.TaskManager;
  20 +import com.wd.common.interact.ICommentDataNewListener;
  21 +import com.wd.common.utils.CommonNetUtils;
  22 +import com.wd.common.utils.PDUtils;
  23 +import com.wd.foundation.bean.comment.CommentListBean;
  24 +import com.wd.foundation.bean.comment.CommentStatusBean;
  25 +import com.wd.foundation.bean.custom.content.CommentItem;
  26 +import com.wd.foundation.bean.incentive.LevelInfoBean;
  27 +import com.wd.foundation.bean.livedate.EventMessage;
  28 +import com.wd.foundation.bean.request.CommentLikeParameterBean;
  29 +import com.wd.foundation.bean.request.PublishCommentParameterBean;
  30 +import com.wd.foundation.bean.response.PersonalInfoBean;
  31 +import com.wd.foundation.bean.utils.TimeUtil;
  32 +import com.wd.foundation.wdkit.constant.IntentConstants;
  33 +import com.wd.foundation.wdkit.system.DeviceUtil;
  34 +import com.wd.foundation.wdkit.utils.CommonUtil;
  35 +import com.wd.foundation.wdkit.utils.SpUtils;
  36 +import com.wd.foundation.wdkitcore.livedata.LiveDataBus;
  37 +import com.wd.foundation.wdkitcore.tools.ArrayUtils;
  38 +import com.wd.foundation.wdkitcore.tools.StringUtils;
  39 +
  40 +import java.util.ArrayList;
  41 +import java.util.HashMap;
  42 +import java.util.List;
  43 +import java.util.Map;
  44 +
  45 +import io.reactivex.Observable;
  46 +import io.reactivex.android.schedulers.AndroidSchedulers;
  47 +import io.reactivex.functions.Action;
  48 +import io.reactivex.functions.Consumer;
  49 +import io.reactivex.schedulers.Schedulers;
  50 +
  51 +/**
  52 + * @Author LiuKun
  53 + * @date:2023/5/9
  54 + * @desc:评论相关接口
  55 + */
  56 +public class CommentDataFetcher extends BaseDataFetcher<RequestApi> {
  57 + /**
  58 + * 接口回调
  59 + */
  60 + private ICommentDataNewListener mDataListener;
  61 +
  62 + /**
  63 + * 数据请求
  64 + */
  65 + public CommentDataFetcher(ICommentDataNewListener listener) {
  66 + mDataListener = listener;
  67 + }
  68 +
  69 + public CommentDataFetcher() {
  70 +
  71 + }
  72 +
  73 + /**
  74 + * 获取评论列表
  75 + */
  76 + public void getCommentList(String contentId, String contentType, int pageNum, int pageSize,
  77 + String hotComment,String hotIds) {
  78 + Map<String, Object> map = new HashMap<>();
  79 + //内容id 内容类型
  80 + map.put(ParameterConstant.CONTENTID, contentId);
  81 + map.put(ParameterConstant.CONTENT_TYPE, contentType);
  82 + map.put(ParameterConstant.PAGENUM, pageNum);
  83 + map.put(ParameterConstant.PAGESIZE, pageSize);
  84 + //用户信息 如果userType为2、3、4时,creatorId必填
  85 + map.put(ParameterConstant.USER_ID, SpUtils.getUserId());
  86 + map.put(ParameterConstant.USER_TYPE, SpUtils.getUserType());
  87 + map.put(ParameterConstant.CREATORID, SpUtils.getCreatorId());
  88 + //时间
  89 + map.put(ParameterConstant.TIME, TimeUtil.getDateToString(System.currentTimeMillis()));
  90 + //设备id
  91 + map.put(ParameterConstant.DEVICEID, DeviceUtil.getDeviceId());
  92 + //需要返回热门评论,默认为0不需要--兼容已发布客户端和官网
  93 + if(StringUtils.isEmpty(hotComment)){
  94 + map.put(ParameterConstant.HOT_COMMENT, "0");
  95 + }else {
  96 + map.put(ParameterConstant.HOT_COMMENT, hotComment);
  97 + }
  98 + //app评论列表第二页传值,热门评论ids,逗号分隔的字符串
  99 + if(StringUtils.isNotBlank(hotIds)){
  100 + map.put(ParameterConstant.HOT_IDS, hotIds);
  101 + }
  102 + //接口请求
  103 + Observable<BaseResponse<CommentListBean>> requestData = getRetrofit().getCommentList(map);
  104 + request(requestData, new BaseObserver<CommentListBean>() {
  105 + @Override
  106 + protected void dealSpecialCode(int code, String message) {
  107 + if (mDataListener != null) {
  108 + mDataListener.onGetCommentListFail(code, message);
  109 + }
  110 + }
  111 +
  112 + @Override
  113 + public void onSuccess(CommentListBean videoItemBean) {
  114 + if (mDataListener != null) {
  115 + mDataListener.onGetCommentListSuccess(videoItemBean);
  116 + }
  117 + }
  118 +
  119 + @Override
  120 + public void _onError(String e) {
  121 + if (mDataListener != null) {
  122 + mDataListener.onGetCommentListFail(-1, e);
  123 + }
  124 + }
  125 + });
  126 + }
  127 +
  128 +
  129 + /**
  130 + * 批查用户等级信息
  131 + */
  132 + public void batchUserLevelInfor(List<CommentItem> data, int freshStartIndex, int listLevel) {
  133 +
  134 +
  135 + List<String> list = new ArrayList<>();
  136 + for (CommentItem bean : data) {
  137 + String fromUserId = bean.getFromUserId();
  138 + if (!TextUtils.isEmpty(fromUserId)) {
  139 + if (list.contains(fromUserId)) {
  140 +
  141 + } else {
  142 + list.add(bean.getFromUserId());
  143 + }
  144 + }
  145 + }
  146 +
  147 + //接口请求
  148 + Observable<BaseResponse<List<LevelInfoBean>>> requestData = getRetrofit().batchUser(getBody(list));
  149 + request(requestData, new BaseObserver<List<LevelInfoBean>>() {
  150 + @Override
  151 + protected void dealSpecialCode(int code, String message) {
  152 + mDataListener.onGetLevelInfoBeanListSuccess(data, freshStartIndex, listLevel);
  153 + }
  154 +
  155 + @Override
  156 + public void onSuccess(List<LevelInfoBean> levelInfoBeans) {
  157 + if (mDataListener != null) {
  158 +
  159 + if (levelInfoBeans != null) {
  160 +
  161 + for (LevelInfoBean levelInfoBean : levelInfoBeans) {
  162 +
  163 + String userId = levelInfoBean.getUserId();
  164 +
  165 + for (CommentItem bean : data) {
  166 + String fromUserId = bean.getFromUserId();
  167 + if (!TextUtils.isEmpty(userId) && userId.equals(fromUserId)) {
  168 + bean.setLevelHead(levelInfoBean.getLevelHead());
  169 + bean.levelInfoBean = levelInfoBean;
  170 + }
  171 + }
  172 +
  173 + }
  174 +
  175 + mDataListener.onGetLevelInfoBeanListSuccess(data, freshStartIndex, listLevel);
  176 + }
  177 +
  178 +
  179 + }
  180 + }
  181 +
  182 + @Override
  183 + public void _onError(String e) {
  184 + mDataListener.onGetLevelInfoBeanListSuccess(data, freshStartIndex, listLevel);
  185 + }
  186 + });
  187 + }
  188 +
  189 + /**
  190 + * 单独查询用户等级头像
  191 + */
  192 + private void batchUserLevelInfor(CommentItem data, int position, String msg) {
  193 +
  194 +
  195 + List<String> list = new ArrayList<>();
  196 + list.add(data.getFromUserId());
  197 +
  198 + //接口请求
  199 + Observable<BaseResponse<List<LevelInfoBean>>> requestData = getRetrofit().batchUser(getBody(list));
  200 + request(requestData, new BaseObserver<List<LevelInfoBean>>() {
  201 + @Override
  202 + protected void dealSpecialCode(int code, String message) {
  203 + // mDataListener.onGetLevelInfoBeanSuccess(data, position);
  204 + if (mDataListener != null) {
  205 + mDataListener.onSubmitPushCommentSuccess(data, position, msg);
  206 + }
  207 + }
  208 +
  209 + @Override
  210 + public void onSuccess(List<LevelInfoBean> levelInfoBeans) {
  211 + if (mDataListener != null) {
  212 +
  213 + if (levelInfoBeans != null) {
  214 +
  215 + for (LevelInfoBean levelInfoBean : levelInfoBeans) {
  216 + String userId = levelInfoBean.getUserId();
  217 + String fromUserId = data.getFromUserId();
  218 + if (!TextUtils.isEmpty(userId) && userId.equals(fromUserId)) {
  219 + data.setLevelHead(levelInfoBean.getLevelHead());
  220 + data.levelInfoBean = levelInfoBean;
  221 + }
  222 + }
  223 + }
  224 +
  225 +
  226 + mDataListener.onSubmitPushCommentSuccess(data, position, msg);
  227 +
  228 + }
  229 + }
  230 +
  231 + @Override
  232 + public void _onError(String e) {
  233 + if (mDataListener != null) {
  234 + mDataListener.onSubmitPushCommentSuccess(data, position, msg);
  235 + }
  236 + }
  237 + });
  238 + }
  239 +
  240 + /**
  241 + * 单查用户号主信息
  242 + * @param creatorId
  243 + * @param data
  244 + * @param position
  245 + * @param msg
  246 + */
  247 + private void getMastersAuthentication(String creatorId, CommentItem data, int position, String msg) {
  248 +
  249 +
  250 + Map<String, Object> map = new HashMap<>();
  251 + List<String> listMap = new ArrayList<>();
  252 + //creatorId 为空
  253 + if (StringUtils.isBlank(creatorId)){
  254 + if (mDataListener != null) {
  255 + mDataListener.onSubmitPushCommentSuccess(data, position, msg);
  256 + }
  257 + return;
  258 + }
  259 + listMap.add(creatorId);
  260 + map.put("creatorIdList", listMap);
  261 + Observable<BaseResponse<List<PersonalInfoBean>>> userInfo = getRetrofit().getMasterInfoListData(getBody(map));
  262 + request(userInfo, new BaseObserver<List<PersonalInfoBean>>() {
  263 +
  264 + @Override
  265 + protected void dealSpecialCode(int code, String message) {
  266 + if (mDataListener != null) {
  267 + mDataListener.onSubmitPushCommentSuccess(data, position, msg);
  268 + }
  269 + }
  270 +
  271 + @Override
  272 + public void onSuccess(List<PersonalInfoBean> masterInfoList) {
  273 +
  274 + if (mDataListener != null) {
  275 +
  276 + for (PersonalInfoBean masterInfoBean : masterInfoList) {
  277 + String targetId = masterInfoBean.getRmhId();
  278 + String fromCreatorId = StringUtils.getStringValue(data.getFromCreatorId());
  279 + if (fromCreatorId.equals(targetId)) {
  280 + data.setAuthIcon(masterInfoBean.getAuthIcon());
  281 + data.mainControl = masterInfoBean.getCnMainControl();
  282 + }
  283 + }
  284 +
  285 + mDataListener.onSubmitPushCommentSuccess(data, position, msg);
  286 + }
  287 + }
  288 +
  289 + @Override
  290 + public void _onError(String e) {
  291 + if (mDataListener != null) {
  292 + mDataListener.onSubmitPushCommentSuccess(data, position, msg);
  293 + }
  294 + }
  295 + });
  296 + }
  297 +
  298 +
  299 + /**
  300 + * 获取二级评论列表
  301 + */
  302 + public void getSecondCommentList(int position, String commentId, String pageNum, String pageSize, String excludeIds, String contentId, String contentType) {
  303 + long currentTimeMillis = System.currentTimeMillis();
  304 + Map<String, Object> map = new HashMap<>();
  305 + //评论id
  306 + map.put(ParameterConstant.COMMENT_ID, commentId);
  307 + map.put(ParameterConstant.PAGENUM, pageNum);
  308 + map.put(ParameterConstant.PAGESIZE, pageSize);
  309 + //
  310 + map.put(ParameterConstant.EXCLUDE_IDS, excludeIds);
  311 + //用户信息
  312 + map.put(ParameterConstant.CREATORID, SpUtils.getCreatorId());
  313 + map.put(ParameterConstant.USER_ID, SpUtils.getUserId());
  314 + map.put(ParameterConstant.USER_TYPE, SpUtils.getUserType());
  315 + map.put(ParameterConstant.TIME, TimeUtil.getDateToString(currentTimeMillis));
  316 +
  317 + //内容id、内容类型
  318 + map.put(ParameterConstant.CONTENTID, contentId);
  319 + map.put(ParameterConstant.CONTENT_TYPE, contentType);
  320 + //设备id
  321 + map.put(ParameterConstant.DEVICEID, DeviceUtil.getDeviceId());
  322 + Observable<BaseResponse<CommentListBean>> secondCommentList = getRetrofit().getSecondCommentList(map);
  323 + request(secondCommentList, new BaseObserver<CommentListBean>() {
  324 + @Override
  325 + protected void dealSpecialCode(int code, String message) {
  326 + if (mDataListener != null) {
  327 + mDataListener.onGetSecondCommentListFail();
  328 + }
  329 + }
  330 +
  331 + @Override
  332 + public void onSuccess(CommentListBean videoItemBean) {
  333 + if (mDataListener != null) {
  334 + mDataListener.onGetSecondCommentListSuccess(position, videoItemBean);
  335 + }
  336 + }
  337 +
  338 + @Override
  339 + public void _onError(String e) {
  340 + if (mDataListener != null) {
  341 + mDataListener.onGetSecondCommentListFail();
  342 + }
  343 + }
  344 + });
  345 + }
  346 +
  347 + /**
  348 + * 提交评论
  349 + */
  350 + public void submitPushComment(PublishCommentParameterBean parameterBean) {
  351 + int position = parameterBean.getPosition();
  352 + String rootCommentId = parameterBean.getRootCommentId();
  353 + Observable<BaseResponse<CommentItem>> submitRequestData = CommonNetUtils.getInstance().
  354 + createSubmitRequestData(parameterBean);
  355 + request(submitRequestData, new BaseObserver<CommentItem>() {
  356 + @Override
  357 + protected void dealSpecialCode(int code, String message) {
  358 + if (mDataListener != null) {
  359 + mDataListener.onSubmitPushCommentFail(code, message);
  360 + }
  361 + }
  362 +
  363 + @Override
  364 + public void onSuccess(CommentItem pushCommentBean) {
  365 +
  366 + }
  367 +
  368 + @Override
  369 + protected void onSuccess(CommentItem pushCommentBean, MetaBean metaBean, String msg, int code) {
  370 + super.onSuccess(pushCommentBean, metaBean, msg, code);
  371 + if (StringUtils.isEqual("-1", rootCommentId)) {
  372 + //执行任务:评论
  373 + TaskManager.getInstance().executePointLevelOperate(TaskOperateTypeConstants.COMMENT);
  374 + } else {
  375 + //执行任务:回复
  376 + TaskManager.getInstance().executePointLevelOperate(TaskOperateTypeConstants.REPLY);
  377 + }
  378 + if(!PDUtils.isLogin()){
  379 + //未登录,游客评论
  380 + String touristFirstCommentTime = SpUtils.getTouristFirstCommentTime();
  381 + if(StringUtils.isEmpty(touristFirstCommentTime)){
  382 + //保存游客评论第一条的时间,格式:yyyy-MM-dd HH:mm:ss
  383 + try {
  384 + String currentDatetime = TimeUtil.currentDatetime();
  385 + SpUtils.saveTouristFirstCommentTime(currentDatetime);
  386 + } catch (Exception e) {
  387 + e.printStackTrace();
  388 + }
  389 + }
  390 + }
  391 + if (mDataListener != null && pushCommentBean != null) {
  392 +
  393 + String creatorId = null;
  394 + int commentLevel = pushCommentBean.getCommentLevel();
  395 + if (commentLevel == CommentListAdapter.COMMENT_TYPE_PARENT || commentLevel == CommentListAdapter.COMMENT_TYPE_CHILD) {
  396 + //创作者
  397 + if (pushCommentBean.getCreatorFlag() == 1) {
  398 + creatorId = pushCommentBean.getFromCreatorId();
  399 + }
  400 + }
  401 +
  402 + if (TextUtils.isEmpty(creatorId)) {
  403 + batchUserLevelInfor(pushCommentBean, position, msg);
  404 + } else {
  405 + getMastersAuthentication(creatorId, pushCommentBean, position, msg);
  406 + }
  407 + // mDataListener.onSubmitPushCommentSuccess(pushCommentBean, position, msg)
  408 + }else {
  409 + //有msg,也进行提示,处理评论预显示关闭,发布评论场景
  410 + if (mDataListener != null) {
  411 + mDataListener.onSubmitPushCommentSuccess(pushCommentBean, position, msg);
  412 + }
  413 + }
  414 + }
  415 +
  416 + @Override
  417 + public void _onError(String e) {
  418 + if (mDataListener != null) {
  419 + mDataListener.onSubmitPushCommentFail(-1, e);
  420 + }
  421 + }
  422 + });
  423 + }
  424 +
  425 + /**
  426 + * 批量获取创作者的认证信息
  427 + *
  428 + * @param targetId 内容id
  429 + * @param originalListData 一级评论原始数据
  430 + * @param freshStartIndex 刷新起始位置
  431 + * @param listLevel 数据类型 1 一级评论 2 二级评论
  432 + */
  433 + public void getMastersAuthenticationList(String targetId,List<CommentItem> originalListData, int freshStartIndex, int listLevel) {
  434 + List<String> creatorIdList = new ArrayList<>();
  435 +// List<String> userIdList = new ArrayList<>();
  436 + int size = originalListData.size();
  437 + Observable.range(0, size)
  438 + .subscribeOn(Schedulers.io()) // 在 IO 线程执行循环操作
  439 + .observeOn(AndroidSchedulers.mainThread()) // 在主线程观察结果
  440 + .subscribe(new Consumer<Integer>() {
  441 + @Override
  442 + public void accept(Integer i) throws Exception {
  443 + // 循环体代码
  444 + int commentLevel = originalListData.get(i).getCommentLevel();
  445 + if (commentLevel == CommentListAdapter.COMMENT_TYPE_PARENT || commentLevel == CommentListAdapter.COMMENT_TYPE_CHILD) {
  446 + //不是创作者也有客态了
  447 + if (originalListData.get(i).getCreatorFlag() == 1) {
  448 + creatorIdList.add(originalListData.get(i).getFromCreatorId());
  449 + }
  450 +// if (!TextUtils.isEmpty(originalListData.get(i).getFromUserId() )){
  451 +// userIdList.add()
  452 +// }
  453 + }
  454 + }
  455 + }, new Consumer<Throwable>() {
  456 + @Override
  457 + public void accept(Throwable throwable) throws Exception {
  458 + // 处理错误
  459 + }
  460 + }, new Action() {
  461 + @Override
  462 + public void run() throws Exception {
  463 + // 循环完毕后执行下一步的代码
  464 + getMastersAuthenticationListRxjava(targetId,creatorIdList, originalListData, freshStartIndex, listLevel);
  465 + }
  466 + });
  467 + }
  468 +
  469 + private void getMastersAuthenticationListRxjava(String targetId,List<String> creatorIdList, List<CommentItem> originalListData, int freshStartIndex, int listLevel) {
  470 + if (CommonUtil.isEmpty(creatorIdList)) {
  471 + //未登录不需查询点赞状态
  472 + if (!PDUtils.isLogin()) {
  473 + if (mDataListener != null) {
  474 + mDataListener.onGetMastersAuthenticationListSuccess(null, originalListData, freshStartIndex, listLevel);
  475 + }
  476 + return;
  477 + }
  478 + //没有创作者直接查询点赞状态
  479 + getCommentStatusList(targetId,null, originalListData, freshStartIndex, listLevel);
  480 + return;
  481 + }
  482 +
  483 + Map<String, Object> map = new HashMap<>();
  484 + List<String> listMap = new ArrayList<>();
  485 + for (String tempCreatorId : creatorIdList) {
  486 + if (!listMap.contains(tempCreatorId)) {
  487 + //避免重复查询
  488 + listMap.add(tempCreatorId);
  489 + }
  490 + }
  491 + map.put("creatorIdList", listMap);
  492 + if (ArrayUtils.isEmpty(listMap)){
  493 + if (mDataListener != null) {
  494 + mDataListener.onGetMastersAuthenticationListFailure("creatorIdList 为空", listLevel);
  495 + }
  496 + return;
  497 + }
  498 + Observable<BaseResponse<List<PersonalInfoBean>>> userInfo = getRetrofit().getMasterInfoListData(getBody(map));
  499 + request(userInfo, new BaseObserver<List<PersonalInfoBean>>() {
  500 +
  501 + @Override
  502 + protected void dealSpecialCode(int code, String message) {
  503 + if (mDataListener != null) {
  504 + mDataListener.onGetMastersAuthenticationListFailure(message, listLevel);
  505 + }
  506 + }
  507 +
  508 + @Override
  509 + public void onSuccess(List<PersonalInfoBean> masterInfoList) {
  510 + //未登录只查询号主信息
  511 + if (!PDUtils.isLogin()) {
  512 + if (mDataListener != null) {
  513 + mDataListener.onGetMastersAuthenticationListSuccess(masterInfoList, originalListData, freshStartIndex, listLevel);
  514 + }
  515 + return;
  516 + }
  517 +
  518 + //已登录 号主信息查完以后再查询点赞状态
  519 + getCommentStatusList(targetId,masterInfoList, originalListData, freshStartIndex, listLevel);
  520 + }
  521 +
  522 + @Override
  523 + public void _onError(String e) {
  524 + if (mDataListener != null) {
  525 + mDataListener.onGetMastersAuthenticationListFailure(e, listLevel);
  526 + }
  527 + }
  528 + });
  529 + }
  530 +
  531 +
  532 + /**
  533 + * 批量查询当前登录人评论点赞状态
  534 + *
  535 + * @param targetId 内容id
  536 + * @param originalListData 一级评论原始数据
  537 + * @param freshStartIndex 刷新起始位置
  538 + * @param listLevel 数据类型 1 一级评论 2 二级评论
  539 + */
  540 + public void getCommentStatusList(String targetId,List<PersonalInfoBean> masterInfoList, List<CommentItem> originalListData, int freshStartIndex, int listLevel) {
  541 + if(!PDUtils.isLogin()){
  542 + return;
  543 + }
  544 + List<Integer> commentIdList = new ArrayList<>();
  545 + List<String> uuidList = new ArrayList<>();
  546 + for (CommentItem mCovertCommentObj : originalListData) {
  547 + int tempId = mCovertCommentObj.getId();
  548 + //评论审核状态,0:未审核;1:审核中;2:通过;3:不通过 只有审核通过的才显示回复按钮
  549 + /*int checkStatus = mCovertCommentObj.getCheckStatus();
  550 + if (tempId != 0 || checkStatus == 2) {
  551 + commentIdList.add(tempId);
  552 + }*/
  553 +
  554 + if(tempId != 0){
  555 + commentIdList.add(tempId);
  556 + }else if(StringUtils.isNotBlank(mCovertCommentObj.getUuid())){
  557 + uuidList.add(mCovertCommentObj.getUuid());
  558 + }
  559 + }
  560 +
  561 + if (CommonUtil.isEmpty(commentIdList)) {
  562 + if (mDataListener != null) {
  563 + mDataListener.onGetAllDataSuccess(null, masterInfoList, originalListData, freshStartIndex, listLevel);
  564 + }
  565 + return;
  566 + }
  567 + Map<String, Object> map = new HashMap<>();
  568 + map.put("commentIdList", commentIdList);
  569 + map.put("targetId", targetId);
  570 + map.put("uuidList", uuidList);
  571 + Observable<BaseResponse<List<CommentStatusBean>>> userInfo = getRetrofit().batchCommentStatus(getBody(map));
  572 + request(userInfo, new BaseObserver<List<CommentStatusBean>>() {
  573 +
  574 + @Override
  575 + protected void dealSpecialCode(int code, String message) {
  576 + if (mDataListener != null) {
  577 + mDataListener.onGetCommentStatusListFailure(message, listLevel);
  578 + }
  579 + }
  580 +
  581 + @Override
  582 + public void onSuccess(List<CommentStatusBean> statusList) {
  583 + if (mDataListener != null) {
  584 + mDataListener.onGetAllDataSuccess(statusList, masterInfoList, originalListData, freshStartIndex, listLevel);
  585 + }
  586 + }
  587 +
  588 + @Override
  589 + public void _onError(String e) {
  590 + //接口请求失败
  591 + if (mDataListener != null) {
  592 + mDataListener.onGetCommentStatusListFailure(e, listLevel);
  593 + }
  594 + }
  595 + });
  596 + }
  597 +
  598 +
  599 + /**
  600 + * 评论点赞
  601 + */
  602 + public void commentLike(CommentLikeParameterBean commentLikeParameterBean) {
  603 + if(commentLikeParameterBean == null){
  604 + return;
  605 + }
  606 + String commentId = commentLikeParameterBean.getCommentId();
  607 + String targetId = commentLikeParameterBean.getTargetId();
  608 + int status = commentLikeParameterBean.getStatus();
  609 + Map<String, Object> map = new HashMap<>();
  610 + map.put("rootCommentId", commentLikeParameterBean.getRootCommentId());
  611 + map.put("uuid", commentLikeParameterBean.getUuid());
  612 + map.put("commentId", commentId);
  613 + map.put("targetId", targetId);
  614 + map.put("targetType", commentLikeParameterBean.getTargetType());
  615 + map.put("status", status);
  616 + map.put("userName", SpUtils.getUserName());
  617 + map.put("userHeaderUrl", SpUtils.getHeadPhotoUrl());
  618 + Observable<BaseResponse<Object>> requestData = getRetrofit().commentLike(getBody(map));
  619 + request(requestData, new BaseObserver<Object>() {
  620 + @Override
  621 + protected void dealSpecialCode(int code, String message) {
  622 +
  623 + }
  624 +
  625 + @Override
  626 + public void onSuccess(Object s) {
  627 + if(StringUtils.isEmpty(commentId)){
  628 + return;
  629 + }
  630 + EventMessage mEventMessage = new EventMessage(EventConstants.FRESH_ZAN_CREATOR_EVENT);
  631 + mEventMessage.putExtra(IntentConstants.CONTENT_ID, commentId);
  632 + mEventMessage.putExtra(IntentConstants.TARGET_ID, targetId);
  633 + mEventMessage.putExtra(IntentConstants.IS_ZAN, 0 == status);
  634 + //全局刷新创作者关注状态
  635 + LiveDataBus.getInstance().with(EventConstants.FRESH_ZAN_CREATOR_EVENT).postValue(mEventMessage);
  636 + }
  637 +
  638 + @Override
  639 + public void _onError(String e) {
  640 +
  641 + }
  642 + });
  643 + }
  644 +
  645 +
  646 + /**
  647 + * 评论点赞(不需要发通知事件)
  648 + */
  649 + public void commentLike(String commentId, String targetId, String targetType, int status) {
  650 + Map<String, Object> map = new HashMap<>();
  651 + map.put("commentId", commentId);
  652 + map.put("targetId", targetId);
  653 + map.put("targetType", targetType);
  654 + map.put("status", status);
  655 + map.put("userName", SpUtils.getUserName());
  656 + map.put("userHeaderUrl", SpUtils.getHeadPhotoUrl());
  657 + Observable<BaseResponse<Object>> requestData = getRetrofit().commentLike(getBody(map));
  658 + request(requestData, new BaseObserver<Object>() {
  659 + @Override
  660 + protected void dealSpecialCode(int code, String message) {
  661 +
  662 + }
  663 +
  664 + @Override
  665 + public void onSuccess(Object s) {
  666 +
  667 + }
  668 +
  669 + @Override
  670 + public void _onError(String e) {
  671 +
  672 + }
  673 + });
  674 + }
  675 +
  676 + /**
  677 + * 获取发出去的单条评论数据的号主V
  678 + *
  679 + * @param creatorId 发送者的号主id
  680 + * @param freshPosition 后续需要刷新的item的下标
  681 + */
  682 + public void getSingleMastersAuthenticationData(String creatorId, int freshPosition) {
  683 + Map<String, Object> map = new HashMap<>();
  684 + List<String> listMap = new ArrayList<>();
  685 + //避免重复查询
  686 + //creatorId 为空
  687 + if (StringUtils.isBlank(creatorId)){
  688 + return;
  689 + }
  690 + listMap.add(creatorId);
  691 + map.put("creatorIdList", listMap);
  692 + Observable<BaseResponse<List<PersonalInfoBean>>> userInfo = getRetrofit().getMasterInfoListData(getBody(map));
  693 + request(userInfo, new BaseObserver<List<PersonalInfoBean>>() {
  694 +
  695 + @Override
  696 + protected void dealSpecialCode(int code, String message) {
  697 +
  698 + }
  699 +
  700 + @Override
  701 + public void onSuccess(List<PersonalInfoBean> masterInfoList) {
  702 + if (CommonUtil.isEmpty(masterInfoList)) {
  703 + return;
  704 + }
  705 + if (mDataListener != null) {
  706 + mDataListener.onGetSingleMastersAuthenticationDataSuccess(masterInfoList.get(0), freshPosition);
  707 + }
  708 + }
  709 +
  710 + @Override
  711 + public void _onError(String e) {
  712 +
  713 + }
  714 + });
  715 + }
  716 +
  717 +
  718 + /**
  719 + * 删除评论
  720 + *
  721 + * @param commentId 要删除的评论id
  722 + * @param targetId 删除评论所属内容id
  723 + */
  724 + public void delComment(String commentId, String targetId, String uuid, int freshPosition) {
  725 + CommonNetUtils.getInstance().delComment(commentId,targetId,uuid,freshPosition,mDataListener);
  726 + }
  727 +
  728 + /**
  729 + * 获取用户的评论列表数据
  730 + */
  731 + public void getUserCommentList(String userId, String userType, String creatorId,
  732 + int pageNum, int pageSize, boolean isSelf,
  733 + MyCommentListDataListener mMyCommentListDataListener) {
  734 +
  735 + long currentTimeMillis = System.currentTimeMillis();
  736 +
  737 + HashMap<String, Object> queryMap = new HashMap<>();
  738 + queryMap.put(ParameterConstant.PAGENUM, pageNum);
  739 + queryMap.put(ParameterConstant.PAGESIZE, pageSize);
  740 + queryMap.put(ParameterConstant.TIME, TimeUtil.getDateToString(currentTimeMillis));
  741 + Observable<BaseResponse<CommentListBean>> register = null;
  742 + if (isSelf) {
  743 + register = getRetrofit().getMyCommentList(queryMap);
  744 + } else {
  745 + queryMap.put(ParameterConstant.CREATORID, creatorId);
  746 + queryMap.put(ParameterConstant.USER_ID, userId);
  747 + queryMap.put(ParameterConstant.USER_TYPE, userType);
  748 + register = getRetrofit().getOthersCommentList(queryMap);
  749 + }
  750 +
  751 + if (register == null) {
  752 + return;
  753 + }
  754 + request(register, new BaseObserver<CommentListBean>() {
  755 + @Override
  756 + protected void dealSpecialCode(int code, String message) {
  757 + if (mMyCommentListDataListener != null) {
  758 + mMyCommentListDataListener.onGetDateFailed(message);
  759 + }
  760 + }
  761 +
  762 + @Override
  763 + public void onSuccess(CommentListBean mData) {
  764 + if (mMyCommentListDataListener != null) {
  765 + mMyCommentListDataListener.onGetDateSuccess(mData);
  766 + }
  767 + }
  768 +
  769 + @Override
  770 + public void _onError(String e) {
  771 + if (mMyCommentListDataListener != null) {
  772 + mMyCommentListDataListener.onGetDateFailed(e);
  773 + }
  774 + }
  775 + });
  776 + }
  777 +
  778 +
  779 + /**
  780 + * 批量查询我的评论列表评论点赞状态
  781 + */
  782 + public void getMyCommentListStatusList(List<Integer> params, BatchMyCommentListLikeStatusListener mMyCommentListDataListener) {
  783 + if(!PDUtils.isLogin()){
  784 + return;
  785 + }
  786 + Map<String, Object> map = new HashMap<>();
  787 + map.put("commentIdList", params);
  788 + Observable<BaseResponse<List<CommentStatusBean>>> userInfo = getRetrofit().batchCommentStatus(getBody(map));
  789 + request(userInfo, new BaseObserver<List<CommentStatusBean>>() {
  790 +
  791 + @Override
  792 + protected void dealSpecialCode(int code, String message) {
  793 + if (mMyCommentListDataListener != null) {
  794 + mMyCommentListDataListener.onGetCommentStatusListFailure(message);
  795 + }
  796 + }
  797 +
  798 + @Override
  799 + public void onSuccess(List<CommentStatusBean> statusList) {
  800 + if (mMyCommentListDataListener != null) {
  801 + mMyCommentListDataListener.onGetCommentStatusListSuccess(statusList);
  802 + }
  803 + }
  804 +
  805 + @Override
  806 + public void _onError(String e) {
  807 + if (mMyCommentListDataListener != null) {
  808 + mMyCommentListDataListener.onGetCommentStatusListFailure(e);
  809 + }
  810 + }
  811 + });
  812 + }
  813 +
  814 +
  815 + /**
  816 + * 删除评论(我的评论列表)
  817 + *
  818 + * @param commentId 要删除的评论id
  819 + * @param targetId 删除评论所属内容id
  820 + */
  821 + public void delComment(String commentId, String targetId, String uuid, int freshPosition, DeleteMyCommentListListener mDeleteMyCommentListListener) {
  822 + Observable<BaseResponse<String>> userInfo = CommonNetUtils.getInstance().createDelRequestData(commentId, targetId, uuid);
  823 + request(userInfo, new BaseObserver<String>() {
  824 +
  825 + @Override
  826 + protected void dealSpecialCode(int code, String message) {
  827 + if (mDeleteMyCommentListListener != null) {
  828 + mDeleteMyCommentListListener.onDeleteFailure(message);
  829 + }
  830 + }
  831 +
  832 + @Override
  833 + public void onSuccess(String success) {
  834 + if (mDeleteMyCommentListListener != null) {
  835 + mDeleteMyCommentListListener.onDeleteSuccess(freshPosition);
  836 + }
  837 + }
  838 +
  839 + @Override
  840 + public void _onError(String e) {
  841 + if (mDeleteMyCommentListListener != null) {
  842 + mDeleteMyCommentListListener.onDeleteFailure(e);
  843 + }
  844 + }
  845 + });
  846 + }
  847 +
  848 +
  849 + /**
  850 + * 提交评论(我的评论列表)
  851 + */
  852 + public void submitPushComment(PublishCommentParameterBean parameterBean,
  853 + SubmitMyCommentListListener mSubmitMyCommentListListener) {
  854 + if(parameterBean == null){
  855 + return;
  856 + }
  857 + int position = parameterBean.getPosition();
  858 + String rootCommentId = parameterBean.getRootCommentId();
  859 + Observable<BaseResponse<CommentItem>> submitRequestData = CommonNetUtils.getInstance().createSubmitRequestData(parameterBean);
  860 + request(submitRequestData, new BaseObserver<CommentItem>() {
  861 + @Override
  862 + protected void dealSpecialCode(int code, String message) {
  863 + if (mSubmitMyCommentListListener != null) {
  864 + mSubmitMyCommentListListener.onSubmitFailure(code, message);
  865 + }
  866 + }
  867 +
  868 + @Override
  869 + public void onSuccess(CommentItem pushCommentBean) {
  870 +
  871 + }
  872 +
  873 + @Override
  874 + protected void onSuccess(CommentItem listBean, MetaBean metaBean, String msg, int code) {
  875 + super.onSuccess(listBean, metaBean, msg, code);
  876 + if (StringUtils.isEqual("-1", rootCommentId)) {
  877 + //执行任务:评论
  878 + TaskManager.getInstance().executePointLevelOperate(TaskOperateTypeConstants.COMMENT);
  879 + } else {
  880 + //执行任务:回复
  881 + TaskManager.getInstance().executePointLevelOperate(TaskOperateTypeConstants.REPLY);
  882 + }
  883 + if(!PDUtils.isLogin()){
  884 + //未登录,游客评论
  885 + String touristFirstCommentTime = SpUtils.getTouristFirstCommentTime();
  886 + if(StringUtils.isEmpty(touristFirstCommentTime)){
  887 + //保存游客评论第一条的时间,格式:yyyy-MM-dd HH:mm:ss
  888 + try {
  889 + String currentDatetime = TimeUtil.currentDatetime();
  890 + SpUtils.saveTouristFirstCommentTime(currentDatetime);
  891 + } catch (Exception e) {
  892 + e.printStackTrace();
  893 + }
  894 + }
  895 + }
  896 + if (mSubmitMyCommentListListener != null) {
  897 + mSubmitMyCommentListListener.onSubmitSuccess(listBean, position, msg);
  898 + }
  899 + }
  900 +
  901 + @Override
  902 + public void _onError(String e) {
  903 + if (mSubmitMyCommentListListener != null) {
  904 + mSubmitMyCommentListListener.onSubmitFailure(-1, e);
  905 + }
  906 + }
  907 + });
  908 + }
  909 +}
  1 +package com.people.comment.comment.model;
  2 +
  3 +import com.people.comment.comment.listener.AliTokenListener;
  4 +import com.wd.capability.network.BaseObserver;
  5 +import com.wd.capability.network.fetcher.BaseDataFetcher;
  6 +import com.wd.capability.network.response.BaseResponse;
  7 +import com.wd.common.api.RequestApi;
  8 +import com.wd.foundation.bean.response.SpeechTokenBean;
  9 +
  10 +import io.reactivex.Observable;
  11 +
  12 +/**
  13 + * @Author LiuKun
  14 + * @date:2023/5/5
  15 + * @desc:获取阿里语音识别
  16 + */
  17 +public class GetAliTokenFetcher extends BaseDataFetcher<RequestApi> {
  18 + /**
  19 + * 获取阿里云语音识别token
  20 + */
  21 + public void getAliToken(AliTokenListener mListener) {
  22 + Observable<BaseResponse<SpeechTokenBean>> codeData = getRetrofit().getAliToken();
  23 + request(codeData, new BaseObserver<SpeechTokenBean>() {
  24 + @Override
  25 + protected void dealSpecialCode(int code, String message) {
  26 +
  27 + }
  28 +
  29 + @Override
  30 + protected void onSuccess(SpeechTokenBean speechTokenBean) {
  31 + if (mListener != null) {
  32 + mListener.onGetTokenSuccess(speechTokenBean);
  33 + }
  34 + }
  35 +
  36 +
  37 + @Override
  38 + public void _onError(String e) {
  39 + if (mListener != null) {
  40 + mListener.onGetTokenFailed(e);
  41 + }
  42 + }
  43 + });
  44 +
  45 + }
  46 +}
  1 +package com.people.comment.comment.model;
  2 +
  3 +import com.people.comment.comment.listener.IVisitorCommentDataListener;
  4 +import com.wd.capability.network.BaseObserver;
  5 +import com.wd.capability.network.constant.ParameterConstant;
  6 +import com.wd.capability.network.fetcher.BaseDataFetcher;
  7 +import com.wd.capability.network.response.BaseResponse;
  8 +import com.wd.common.api.RequestApi;
  9 +import com.wd.foundation.bean.comment.CommentListBean;
  10 +import com.wd.foundation.bean.utils.TimeUtil;
  11 +import com.wd.foundation.wdkit.system.DeviceUtil;
  12 +import com.wd.foundation.wdkit.utils.SpUtils;
  13 +
  14 +import java.util.HashMap;
  15 +import java.util.Map;
  16 +import io.reactivex.Observable;
  17 +
  18 +/**
  19 + * 游客评论
  20 + * @author baozhaoxin
  21 + * @version [V1.0.0, 2024/1/22]
  22 + * @since V1.0.0
  23 + */
  24 +public class VisitorCommentDataFetcher extends BaseDataFetcher<RequestApi> {
  25 +
  26 + private IVisitorCommentDataListener iVisitorCommentDataListener;
  27 +
  28 + public VisitorCommentDataFetcher(IVisitorCommentDataListener iVisitorCommentDataListener) {
  29 + this.iVisitorCommentDataListener = iVisitorCommentDataListener;
  30 + }
  31 +
  32 + /**
  33 + * 获取评论列表
  34 + */
  35 + public void getCommentList(int pageNum, int pageSize) {
  36 + Map<String, Object> map = new HashMap<>();
  37 + map.put(ParameterConstant.PAGENUM, pageNum);
  38 + map.put(ParameterConstant.PAGESIZE, pageSize);
  39 + //时间
  40 + String currentDatetime = TimeUtil.currentDatetime();
  41 + map.put(ParameterConstant.TIME, currentDatetime);
  42 + String touristFirstCommentTime = SpUtils.getTouristFirstCommentTime();
  43 + String deviceId = DeviceUtil.getDeviceId();
  44 + map.put(ParameterConstant.VISITOR_FIRST_TIME, touristFirstCommentTime);
  45 + map.put(ParameterConstant.DEVICEID, deviceId);
  46 +
  47 + Observable<BaseResponse<CommentListBean>> observable = getRetrofit().
  48 + getVisitorCommentList(map);
  49 + request(observable, new BaseObserver<CommentListBean>() {
  50 + @Override
  51 + protected void dealSpecialCode(int code, String message) {
  52 + if (iVisitorCommentDataListener != null) {
  53 + iVisitorCommentDataListener.onGetCommentListFail(message);
  54 + }
  55 + }
  56 +
  57 + @Override
  58 + public void onSuccess(CommentListBean mData) {
  59 + if (iVisitorCommentDataListener != null) {
  60 + iVisitorCommentDataListener.onGetCommentListSuccess(mData);
  61 + }
  62 + }
  63 +
  64 + @Override
  65 + public void _onError(String e) {
  66 + if (iVisitorCommentDataListener != null) {
  67 + iVisitorCommentDataListener.onGetCommentListFail(e);
  68 + }
  69 + }
  70 + });
  71 +
  72 + }
  73 +}
  1 +package com.people.comment.comment.vm;
  2 +
  3 +import androidx.lifecycle.LifecycleOwner;
  4 +
  5 +import com.people.comment.comment.model.CommentDataFetcher;
  6 +import com.people.comment.listener.BatchMyCommentListLikeStatusListener;
  7 +import com.people.comment.listener.DeleteMyCommentListListener;
  8 +import com.people.comment.listener.MyCommentListDataListener;
  9 +import com.people.comment.listener.SubmitMyCommentListListener;
  10 +import com.wd.common.UIViewModel;
  11 +import com.wd.common.interact.ICommentDataNewListener;
  12 +import com.wd.common.interfaces.OnGetContentBeanSuccessListener;
  13 +import com.wd.common.utils.CommonNetUtils;
  14 +import com.wd.foundation.bean.custom.content.CommentItem;
  15 +import com.wd.foundation.bean.request.CommentLikeParameterBean;
  16 +import com.wd.foundation.bean.request.PublishCommentParameterBean;
  17 +
  18 +import java.util.List;
  19 +
  20 +/**
  21 + * @Author LiuKun
  22 + * @date:2023/5/9
  23 + * @desc:评论接口回调
  24 + */
  25 +public class CommentViewModel extends UIViewModel {
  26 + /**
  27 + * 接口回调
  28 + */
  29 + private ICommentDataNewListener mDataListener;
  30 + /**
  31 + * 数据请求
  32 + */
  33 + private CommentDataFetcher mCommentFetcher;
  34 +
  35 + public void observeCommentListener(LifecycleOwner lifecycleOwner, ICommentDataNewListener listener) {
  36 + if (mDataListener == null) {
  37 + mDataListener = observe(lifecycleOwner, listener, ICommentDataNewListener.class);
  38 + } else {
  39 + observeRepeat(lifecycleOwner, listener, mDataListener);
  40 + }
  41 + }
  42 +
  43 + /**
  44 + * 获取评论列表
  45 + *
  46 + * @param contentId 内容id
  47 + * @param contentType 内容类型
  48 + */
  49 + public void getCommentList(String contentId, String contentType, int pageNum, int pageSize,
  50 + String hotComment,String hotIds) {
  51 + if (mCommentFetcher == null) {
  52 + mCommentFetcher = new CommentDataFetcher(mDataListener);
  53 + }
  54 + mCommentFetcher.getCommentList(contentId, contentType, pageNum, pageSize,hotComment,hotIds);
  55 + }
  56 +
  57 +
  58 + /**
  59 + * 获取二级评论列表
  60 + *
  61 + * @param excludeIds 需要排除的id,多个用逗号隔开;【一级评论下面3条子评论的首次展开使用;pageId=1】
  62 + */
  63 + public void getSecondCommentList(int position, String commentId, String pageNum, String pageSize, String excludeIds, String contentId, String contentType) {
  64 + if (mCommentFetcher == null) {
  65 + mCommentFetcher = new CommentDataFetcher(mDataListener);
  66 + }
  67 + mCommentFetcher.getSecondCommentList(position, commentId, pageNum, pageSize, excludeIds, contentId, contentType);
  68 + }
  69 +
  70 + /**
  71 + * 发布评论
  72 + * @position 条目点击位置
  73 + */
  74 + public void submitComment(PublishCommentParameterBean parameterBean) {
  75 + if (mCommentFetcher == null) {
  76 + mCommentFetcher = new CommentDataFetcher(mDataListener);
  77 + }
  78 + mCommentFetcher.submitPushComment(parameterBean);
  79 + }
  80 +
  81 + /**
  82 + * 发布评论(我的评论列表)
  83 + */
  84 + public void submitComment(PublishCommentParameterBean parameterBean,
  85 + SubmitMyCommentListListener mSubmitMyCommentListListener) {
  86 + if (mCommentFetcher == null) {
  87 + mCommentFetcher = new CommentDataFetcher(mDataListener);
  88 + }
  89 + mCommentFetcher.submitPushComment(parameterBean, mSubmitMyCommentListListener);
  90 + }
  91 +
  92 +
  93 + /**
  94 + * 批量获取创作者的认证信息
  95 + *
  96 + * @param targetId 内容id
  97 + * @param originalListData 一级评论原始数据
  98 + * @param freshStartIndex 刷新起始位置
  99 + * @param listLevel 数据类型 1 一级评论 2 二级评论
  100 + */
  101 + public void getMastersAuthenticationList(String targetId, List<CommentItem> originalListData, int freshStartIndex, int listLevel) {
  102 + if (mCommentFetcher == null) {
  103 + mCommentFetcher = new CommentDataFetcher(mDataListener);
  104 + }
  105 + mCommentFetcher.getMastersAuthenticationList(targetId,originalListData, freshStartIndex, listLevel);
  106 + }
  107 +
  108 + /**
  109 + * 评论点赞
  110 + */
  111 + public void commentLike(CommentLikeParameterBean commentLikeParameterBean) {
  112 + if (mCommentFetcher == null) {
  113 + mCommentFetcher = new CommentDataFetcher(mDataListener);
  114 + }
  115 + mCommentFetcher.commentLike(commentLikeParameterBean);
  116 + }
  117 +
  118 + /**
  119 + * 获取发出去的单条评论数据的号主V
  120 + *
  121 + * @param creatorId 发送者的号主id
  122 + * @param freshPosition 后续需要刷新的item的下标
  123 + */
  124 + public void getSingleMastersAuthenticationData(String creatorId, int freshPosition) {
  125 + if (mCommentFetcher == null) {
  126 + mCommentFetcher = new CommentDataFetcher(mDataListener);
  127 + }
  128 + mCommentFetcher.getSingleMastersAuthenticationData(creatorId, freshPosition);
  129 + }
  130 +
  131 + /**
  132 + * 用户删除评论
  133 + *
  134 + * @param commentId 要删除的评论id
  135 + * @param targetId 删除评论所属内容id
  136 + */
  137 + public void delComment(String commentId, String targetId, String uuid,int freshPosition) {
  138 + if (mCommentFetcher == null) {
  139 + mCommentFetcher = new CommentDataFetcher(mDataListener);
  140 + }
  141 + mCommentFetcher.delComment(commentId, targetId,uuid, freshPosition);
  142 + }
  143 +
  144 +
  145 + /**
  146 + * 获取用户自己的评论列表数据
  147 + *
  148 + * @param userId
  149 + */
  150 + public void getMyCommentList(String userId,String userType, String creatorId, int pageNum, int pageSize,boolean isSelf, MyCommentListDataListener mMyCommentListDataListener) {
  151 + if (mCommentFetcher == null) {
  152 + mCommentFetcher = new CommentDataFetcher();
  153 + }
  154 + mCommentFetcher.getUserCommentList(userId, userType,creatorId,pageNum,pageSize,isSelf,mMyCommentListDataListener);
  155 + }
  156 +
  157 +
  158 + /**
  159 + * 批量查询我的评论列表评论点赞状态
  160 + */
  161 + public void getMyCommentListStatusList(List<Integer> params, BatchMyCommentListLikeStatusListener mMyCommentListDataListener) {
  162 + if (mCommentFetcher == null) {
  163 + mCommentFetcher = new CommentDataFetcher();
  164 + }
  165 + mCommentFetcher.getMyCommentListStatusList(params, mMyCommentListDataListener);
  166 + }
  167 +
  168 +
  169 + /**
  170 + * 用户删除评论(我的评论列表)
  171 + *
  172 + * @param commentId 要删除的评论id
  173 + * @param targetId 删除评论所属内容id
  174 + * @param uuid
  175 + */
  176 + public void delComment(String commentId, String targetId,String uuid, int freshPosition, DeleteMyCommentListListener mDeleteMyCommentListListener) {
  177 + if (mCommentFetcher == null) {
  178 + mCommentFetcher = new CommentDataFetcher();
  179 + }
  180 + mCommentFetcher.delComment(commentId, targetId,uuid, freshPosition,mDeleteMyCommentListListener);
  181 + }
  182 +
  183 + /**
  184 + * 获取评论关联的内容对象(通过contentId获取ContentBean)
  185 + * @param contentId
  186 + * @param mOnGetContentBeanSuccessListener
  187 + */
  188 + public void getContentBeanByContentId(String contentId, String relId, String relType, OnGetContentBeanSuccessListener mOnGetContentBeanSuccessListener) {
  189 + if (mCommentFetcher == null) {
  190 + mCommentFetcher = new CommentDataFetcher();
  191 + }
  192 + CommonNetUtils.getInstance().getNewsDetail(contentId, relId,relType,mOnGetContentBeanSuccessListener);
  193 + }
  194 +
  195 + /**
  196 + * 批查用户等级头像
  197 + * @param data
  198 + * @param freshStartIndex
  199 + * @param listLevel
  200 + */
  201 + public void batchUserLevelInfor(List<CommentItem> data, int freshStartIndex, int listLevel) {
  202 + if (mCommentFetcher == null) {
  203 + mCommentFetcher = new CommentDataFetcher();
  204 + }
  205 + mCommentFetcher.batchUserLevelInfor(data,freshStartIndex, listLevel);
  206 + }
  207 +
  208 +}
  1 +package com.people.comment.comment.vm;
  2 +
  3 +import androidx.lifecycle.LifecycleOwner;
  4 +import com.people.comment.comment.listener.IVisitorCommentDataListener;
  5 +import com.people.comment.comment.model.VisitorCommentDataFetcher;
  6 +import com.wd.common.UIViewModel;
  7 +
  8 +/**
  9 + * 游客评论vm
  10 + * @author baozhaoxin
  11 + * @version [V1.0.0, 2024/1/22]
  12 + * @since V1.0.0
  13 + */
  14 +public class VisitorCommentViewModel extends UIViewModel {
  15 +
  16 + /**
  17 + * 接口回调
  18 + */
  19 + private IVisitorCommentDataListener mDataListener;
  20 + /**
  21 + * 数据请求
  22 + */
  23 + private VisitorCommentDataFetcher mCommentFetcher;
  24 +
  25 + public void observeCommentListener(LifecycleOwner lifecycleOwner, IVisitorCommentDataListener listener) {
  26 + if (mDataListener == null) {
  27 + mDataListener = observe(lifecycleOwner, listener, IVisitorCommentDataListener.class);
  28 + } else {
  29 + observeRepeat(lifecycleOwner, listener, mDataListener);
  30 + }
  31 + }
  32 +
  33 + /**
  34 + * 获取评论列表
  35 + * @param pageNum
  36 + * @param pageSize
  37 + */
  38 + public void getCommentList(int pageNum, int pageSize) {
  39 + if (mCommentFetcher == null) {
  40 + mCommentFetcher = new VisitorCommentDataFetcher(mDataListener);
  41 + }
  42 + mCommentFetcher.getCommentList(pageNum, pageSize);
  43 + }
  44 +}
  1 +package com.people.comment.dialog;
  2 +
  3 +import android.app.Dialog;
  4 +import android.content.Context;
  5 +import android.graphics.Color;
  6 +import android.text.TextUtils;
  7 +import android.util.TypedValue;
  8 +import android.view.Display;
  9 +import android.view.Gravity;
  10 +import android.view.LayoutInflater;
  11 +import android.view.View;
  12 +import android.view.View.OnClickListener;
  13 +import android.view.Window;
  14 +import android.view.WindowManager;
  15 +import android.widget.LinearLayout;
  16 +import android.widget.LinearLayout.LayoutParams;
  17 +import android.widget.ScrollView;
  18 +import android.widget.TextView;
  19 +
  20 +import androidx.core.content.ContextCompat;
  21 +
  22 +
  23 +import com.people.comment.R;
  24 +import com.wd.foundation.wdkit.utils.UiUtils;
  25 +
  26 +import java.util.ArrayList;
  27 +import java.util.List;
  28 +
  29 +
  30 +public class ActionSheetDialog {
  31 + private Context context;
  32 + private Dialog dialog;
  33 + private TextView txt_title;
  34 + private TextView txt_cancel;
  35 + private LinearLayout lLayout_content;
  36 + private ScrollView sLayout_content;
  37 + private boolean showTitle = false;
  38 + private List<SheetItem> sheetItemList;
  39 + private Display display;
  40 +
  41 + public ActionSheetDialog(Context context) {
  42 + this.context = context;
  43 + WindowManager windowManager = (WindowManager) context
  44 + .getSystemService(Context.WINDOW_SERVICE);
  45 + display = windowManager.getDefaultDisplay();
  46 + }
  47 +
  48 + public ActionSheetDialog builder() {
  49 + // 获取Dialog布局
  50 + View view = LayoutInflater.from(context).inflate(
  51 + R.layout.view_actionsheet, null);
  52 +
  53 + // 设置Dialog最小宽度为屏幕宽度
  54 + view.setMinimumWidth(display.getWidth());
  55 +
  56 + // 获取自定义Dialog布局中的控件
  57 + sLayout_content = (ScrollView) view.findViewById(R.id.sLayout_content);
  58 + lLayout_content = (LinearLayout) view
  59 + .findViewById(R.id.lLayout_content);
  60 + txt_title = (TextView) view.findViewById(R.id.txt_title);
  61 + txt_cancel = (TextView) view.findViewById(R.id.txt_cancel);
  62 + txt_cancel.setOnClickListener(new OnClickListener() {
  63 + @Override
  64 + public void onClick(View v) {
  65 + dialog.dismiss();
  66 + }
  67 + });
  68 +
  69 + // 定义Dialog布局和参数
  70 + dialog = new Dialog(context, R.style.ActionSheetDialogStyle);
  71 + dialog.setContentView(view);
  72 + Window dialogWindow = dialog.getWindow();
  73 + dialogWindow.setGravity(Gravity.CENTER | Gravity.BOTTOM);
  74 + WindowManager.LayoutParams lp = dialogWindow.getAttributes();
  75 + lp.x = 0;
  76 + lp.y = 0;
  77 + dialogWindow.setAttributes(lp);
  78 +
  79 + return this;
  80 + }
  81 +
  82 + public ActionSheetDialog setTitle(String title) {
  83 + showTitle = true;
  84 + txt_title.setVisibility(View.VISIBLE);
  85 + txt_title.setText(TextUtils.isEmpty(title)?"":title);
  86 + return this;
  87 + }
  88 +
  89 + public ActionSheetDialog setCancelable(boolean cancel) {
  90 + dialog.setCancelable(cancel);
  91 + return this;
  92 + }
  93 +
  94 + public ActionSheetDialog setCanceledOnTouchOutside(boolean cancel) {
  95 + dialog.setCanceledOnTouchOutside(cancel);
  96 + return this;
  97 + }
  98 +
  99 + /**
  100 + *
  101 + * @param strItem
  102 + * 条目名称
  103 + * @param color
  104 + * 条目字体颜色,设置null则默认蓝色
  105 + * @param listener
  106 + * @return
  107 + */
  108 + public ActionSheetDialog addSheetItem(String strItem, SheetItemColor color,
  109 + OnSheetItemClickListener listener) {
  110 + if (sheetItemList == null) {
  111 + sheetItemList = new ArrayList<SheetItem>();
  112 + }
  113 + sheetItemList.add(new SheetItem(strItem, color, listener));
  114 + return this;
  115 + }
  116 +
  117 + /** 设置条目布局 */
  118 + private void setSheetItems() {
  119 + if (sheetItemList == null || sheetItemList.size() <= 0) {
  120 + return;
  121 + }
  122 +
  123 + int size = sheetItemList.size();
  124 +
  125 + // TODO 高度控制,非最佳解决办法
  126 + // 添加条目过多的时候控制高度
  127 + if (size >= 7) {
  128 + LayoutParams params = (LayoutParams) sLayout_content
  129 + .getLayoutParams();
  130 + params.height = display.getHeight() / 2;
  131 + sLayout_content.setLayoutParams(params);
  132 + }
  133 +
  134 + // 循环添加条目
  135 + for (int i = 1; i <= size; i++) {
  136 + final int index = i;
  137 + SheetItem sheetItem = sheetItemList.get(i - 1);
  138 + String strItem = sheetItem.name;
  139 + SheetItemColor color = sheetItem.color;
  140 + final OnSheetItemClickListener listener = (OnSheetItemClickListener) sheetItem.itemClickListener;
  141 +
  142 + TextView textView = new TextView(context);
  143 + textView.setText(TextUtils.isEmpty(strItem)?"":strItem);
  144 + textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
  145 + textView.setGravity(Gravity.CENTER);
  146 +
  147 + // 背景图片
  148 + if (size == 1) {
  149 + if (showTitle) {
  150 + textView.setBackgroundResource(R.drawable.actionsheet_bottom_selector);
  151 + } else {
  152 + textView.setBackgroundResource(R.drawable.actionsheet_single_selector);
  153 + }
  154 + } else {
  155 + if (showTitle) {
  156 + if (i >= 1 && i < size) {
  157 + textView.setBackgroundResource(R.drawable.actionsheet_middle_selector);
  158 + } else {
  159 + textView.setBackgroundResource(R.drawable.actionsheet_bottom_selector);
  160 + }
  161 + } else {
  162 + if (i == 1) {
  163 + textView.setBackgroundResource(R.drawable.actionsheet_top_selector);
  164 + } else if (i < size) {
  165 + textView.setBackgroundResource(R.drawable.actionsheet_middle_selector);
  166 + } else {
  167 + textView.setBackgroundResource(R.drawable.actionsheet_bottom_selector);
  168 + }
  169 + }
  170 + }
  171 +
  172 + // 字体颜色
  173 + if (color == null) {
  174 + textView.setTextColor(Color.parseColor(SheetItemColor.Blue
  175 + .getName()));
  176 + } else {
  177 + textView.setTextColor(Color.parseColor(color.getName()));
  178 + }
  179 +
  180 + // 高度
  181 + float scale = context.getResources().getDisplayMetrics().density;
  182 + int height = (int) (50 * scale + 1);
  183 + textView.setLayoutParams(new LayoutParams(
  184 + LayoutParams.MATCH_PARENT, height));
  185 +
  186 + // 点击事件
  187 + textView.setOnClickListener(new OnClickListener() {
  188 + @Override
  189 + public void onClick(View v) {
  190 + listener.onClick(index);
  191 + dialog.dismiss();
  192 + }
  193 + });
  194 + lLayout_content.addView(textView);
  195 + if (i!=size) {
  196 + View lineView = new View(context);
  197 + lineView.setLayoutParams(new LayoutParams(
  198 + LayoutParams.MATCH_PARENT, UiUtils.dp2px(0.5F)));
  199 + lineView.setBackgroundColor(ContextCompat.getColor(context,R.color.transparent));
  200 + lLayout_content.addView(lineView);
  201 + }
  202 +
  203 + }
  204 + }
  205 +
  206 + public void show() {
  207 + setSheetItems();
  208 + dialog.show();
  209 + }
  210 +
  211 + public interface OnSheetItemClickListener {
  212 + void onClick(int which);
  213 + }
  214 +
  215 + public class SheetItem {
  216 + String name;
  217 + OnSheetItemClickListener itemClickListener;
  218 + SheetItemColor color;
  219 +
  220 + public SheetItem(String name, SheetItemColor color,
  221 + OnSheetItemClickListener itemClickListener) {
  222 + this.name = name;
  223 + this.color = color;
  224 + this.itemClickListener = itemClickListener;
  225 + }
  226 + }
  227 +
  228 + public enum SheetItemColor {
  229 + Blue("#037BFF"), Red("#FD4A2E");
  230 +
  231 + private String name;
  232 +
  233 + private SheetItemColor(String name) {
  234 + this.name = name;
  235 + }
  236 +
  237 + public String getName() {
  238 + return name;
  239 + }
  240 +
  241 + public void setName(String name) {
  242 + this.name = name;
  243 + }
  244 + }
  245 +}
  1 +package com.people.comment.dialog;
  2 +
  3 +import android.app.Activity;
  4 +import android.content.pm.ActivityInfo;
  5 +import android.graphics.Color;
  6 +import android.graphics.drawable.ColorDrawable;
  7 +import android.os.Bundle;
  8 +import android.text.TextUtils;
  9 +import android.util.DisplayMetrics;
  10 +import android.view.Gravity;
  11 +import android.view.View;
  12 +import android.view.WindowManager;
  13 +import android.widget.ImageView;
  14 +import android.widget.TextView;
  15 +
  16 +import androidx.core.content.ContextCompat;
  17 +
  18 +import com.people.comment.R;
  19 +import com.people.comment.listener.CommitDialogListener;
  20 +import com.people.comment.manager.ExpressionManager;
  21 +import com.people.comment.utils.KeyboardHelper;
  22 +import com.wd.common.constant.PageNameConstants;
  23 +import com.wd.common.dialog.LayerDialog;
  24 +import com.wd.common.imageglide.ImageUtils;
  25 +import com.wd.common.permissions.IPmsCallBack;
  26 +import com.wd.common.permissions.PermissionsUtils;
  27 +import com.wd.common.widget.edittext.AutoAdaptTextSize;
  28 +import com.wd.foundation.bean.analytics.TraceBean;
  29 +import com.wd.foundation.bean.analytics.TrackContentBean;
  30 +import com.wd.foundation.bean.custom.video.VodDetailIntentBean;
  31 +import com.wd.foundation.wdkit.utils.SpUtils;
  32 +import com.wd.foundation.wdkit.utils.ToastNightUtil;
  33 +import com.wd.foundation.wdkitcore.constant.BaseConstants;
  34 +import com.wd.foundation.wdkitcore.storage.MemStoreUtils;
  35 +import com.wd.foundation.wdkitcore.tools.ResUtils;
  36 +import com.wd.foundation.wdkitcore.tools.StringUtils;
  37 +
  38 +import org.greenrobot.eventbus.EventBus;
  39 +import org.greenrobot.eventbus.Subscribe;
  40 +import org.greenrobot.eventbus.ThreadMode;
  41 +
  42 +import java.util.ArrayList;
  43 +import java.util.EnumSet;
  44 +import java.util.List;
  45 +
  46 +/**
  47 + * @Author LiuKun
  48 + * @date:2023/5/2
  49 + * @desc:评论弹出框
  50 + */
  51 +public class CommentCommitDialog extends LayerDialog {
  52 +
  53 + /**
  54 + * 上个页面传递过来的数据
  55 + */
  56 + public VodDetailIntentBean intentBean;
  57 + private TrackContentBean mTrackContentBean;
  58 + /**
  59 + * 输入框
  60 + */
  61 + private AutoAdaptTextSize inputEt;
  62 + /**
  63 + * 语音
  64 + */
  65 + private ImageView voiceIv;
  66 + /**
  67 + * 表情
  68 + */
  69 + private ImageView expressionIv,expressionIvGif;
  70 + /**
  71 + * 发送按钮
  72 + */
  73 + private TextView publishBtn;
  74 + private View uploadImgView;
  75 + private View showImgView;
  76 + private ImageView showImageIv;
  77 + /**
  78 + * 删除图片
  79 + */
  80 + private View delImageView;
  81 + private Activity activity;
  82 + private ExpressionManager expressionManager;
  83 + /**
  84 + * 发送文字、图片监听
  85 + */
  86 + private CommitDialogListener commitDialogListener;
  87 + private String hintStr = "";
  88 + private int maxCountLength;
  89 + /**
  90 + * 选择的gif图
  91 + */
  92 + private String gifUrl ;
  93 +
  94 + /**
  95 + * 最近历史表情
  96 + */
  97 + List<String> gifRecentListStr;
  98 +
  99 + public CommentCommitDialog(Activity activity) {
  100 + this(activity, false);
  101 + }
  102 +
  103 + public CommentCommitDialog(Activity activity, boolean isLive) {
  104 + super(activity, R.style.NoAnimBottom);
  105 + this.activity = activity;
  106 + this.maxCountLength = isLive?100:900;
  107 + }
  108 +
  109 + /**
  110 + * 初始化
  111 + */
  112 + @Override
  113 + protected void onCreate(Bundle savedInstanceState) {
  114 + super.onCreate(savedInstanceState);
  115 + getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
  116 + this.setContentView(R.layout.dialog_commit_comment);
  117 + if (!EventBus.getDefault().isRegistered(this)) {
  118 + EventBus.getDefault().register(this);
  119 + }
  120 + initDialog();
  121 + initView();
  122 + }
  123 +
  124 + /**
  125 + * 初始化弹出框
  126 + */
  127 + private void initDialog() {
  128 + this.setCanceledOnTouchOutside(true);
  129 + WindowManager manager = this.getWindow().getWindowManager();
  130 + DisplayMetrics outMetrics = new DisplayMetrics();
  131 + manager.getDefaultDisplay().getMetrics(outMetrics);
  132 + int width = outMetrics.widthPixels;
  133 + WindowManager.LayoutParams lp = this.getWindow().getAttributes();
  134 + lp.width = width;
  135 + lp.gravity = Gravity.BOTTOM;
  136 + this.getWindow().setAttributes(lp);
  137 + }
  138 +
  139 + /**
  140 + * 初始化布局控件
  141 + */
  142 + private void initView() {
  143 + showImgView = findViewById(R.id.cd_fl_img);
  144 + showImageIv = findViewById(R.id.cd_iv_img);
  145 + delImageView = findViewById(R.id.cd_iv_del_img);
  146 + delImageView.setOnClickListener(v -> {
  147 + showImgView.setVisibility(View.GONE);
  148 + publishStatus();
  149 + ImageUtils.getInstance().loadImage(showImageIv, "");
  150 + });
  151 + uploadImgView = findViewById(R.id.cd_iv_img_btn);
  152 + //跳转到选择图片界面
  153 + uploadImgView.setOnClickListener(v -> {
  154 + if (null != expressionManager) {
  155 + expressionManager.voicePressUpLift();
  156 + }
  157 + //存入临时变量,只有横屏直播间用到,showWithAddBtn
  158 + //画中画模式时,修改选择选图片键盘弹框消失问题
  159 + MemStoreUtils.put("selectPic", "1");
  160 + goSelectPic();
  161 +
  162 + });
  163 + inputEt = findViewById(R.id.cd_et_input);
  164 + inputEt.setHint(hintStr);
  165 + inputEt.setBackListener(textView -> dismiss());
  166 + //语音
  167 + voiceIv = findViewById(R.id.cd_iv_voice_btn);
  168 + //表情
  169 + expressionIv = findViewById(R.id.cd_iv_expression_btn);
  170 + //定制表情
  171 + expressionIvGif = findViewById(R.id.cd_iv_gif_btn);
  172 +
  173 + //全部表情
  174 + List<String> gifListStr = new ArrayList<>();
  175 + try {
  176 + Object obj = MemStoreUtils.getObj("default_map_group","commentgif");
  177 + if (obj instanceof List<?>) {
  178 + gifListStr = (List<String>) obj;
  179 + }
  180 + }catch (Exception e){
  181 + e.printStackTrace();
  182 + }
  183 +
  184 + //没有gif图数据隐藏定制表情
  185 + if (gifListStr == null || gifListStr.isEmpty()) {
  186 + expressionIvGif.setVisibility(View.GONE);
  187 + }
  188 +
  189 + //定制最近表情数据
  190 + gifRecentListStr = new ArrayList<>();
  191 + try {
  192 + String str = SpUtils.getGifIcons();
  193 + if(!TextUtils.isEmpty(str)) {
  194 + String[] strList = str.split(";");
  195 + for (int i = 0; i < strList.length; i++) {
  196 + gifRecentListStr.add(strList[i]);
  197 + }
  198 + }
  199 + }catch (Exception e){
  200 + e.printStackTrace();
  201 + }
  202 +
  203 + //发表按钮
  204 + publishBtn = findViewById(R.id.cd_tv_publish_btn);
  205 + publishBtn.setOnClickListener(v -> {
  206 + if (null != expressionManager) {
  207 + expressionManager.voicePressUpLift();
  208 + }
  209 + String text = getText();
  210 +
  211 + if (commitDialogListener != null) {
  212 +
  213 + if (showImgView.getVisibility() == View.VISIBLE || !TextUtils.isEmpty(text)) {
  214 +
  215 + if(showImgView.getVisibility() == View.VISIBLE ){
  216 + commitDialogListener.publish(text,gifUrl);
  217 +
  218 + }else{
  219 + commitDialogListener.publish(text,null);
  220 + }
  221 +
  222 + // 清空内容
  223 + inputEt.setText("");
  224 + showImgView.setVisibility(View.GONE);
  225 + //清除动图
  226 + gifUrl = "";
  227 +
  228 + //评论发布点击埋点
  229 + if(mTrackContentBean != null){
  230 + if (mTrackContentBean.getTraceBean() == null) {
  231 + TraceBean traceBean = new TraceBean();
  232 + mTrackContentBean.setTraceBean(traceBean);
  233 + }
  234 + // 浏览时长
  235 + TraceBean traceBean = mTrackContentBean.getTraceBean();
  236 + traceBean.duration = 0;
  237 + traceBean.shareChannel = "";
  238 + if (intentBean != null) {
  239 + traceBean.expIds = intentBean.getExpIds();
  240 + traceBean.itemId = intentBean.getItemId();
  241 + traceBean.traceId = intentBean.getTraceId();
  242 + // pageName
  243 + String pageName = intentBean.getPageName();
  244 + if (StringUtils.isBlank(pageName)) {
  245 + mTrackContentBean.setPage_name(PageNameConstants.VIDEO_DETAIL_PAGE);
  246 + }else {
  247 + mTrackContentBean.setPage_name(pageName);
  248 + }
  249 + // pageId
  250 + String pageId = intentBean.getPageId();
  251 + if (StringUtils.isBlank(pageId)) {
  252 + mTrackContentBean.setPage_id(PageNameConstants.VIDEO_DETAIL_PAGE);
  253 + }else {
  254 + mTrackContentBean.setPage_id(pageId);
  255 + }
  256 + }
  257 + mTrackContentBean.setDuration(0);
  258 + mTrackContentBean.commentAction();
  259 +// CommonTrack.getInstance().contentCommentTrack(mTrackContentBean);
  260 + }
  261 + }
  262 + }
  263 + });
  264 + //语音录入
  265 + View voiceLayout = findViewById(R.id.layout_voice);
  266 + //使用旧版表情包
  267 + View expressionLayout = findViewById(R.id.layout_expression);
  268 + //全部表情
  269 + View expressionGifLayout = findViewById(R.id.layout_expression_gif);
  270 + //最近使用表情
  271 + View expressionGifLayoutRecent = findViewById(R.id.layout_expression_gif_recent);
  272 +
  273 + //表情管理类
  274 + expressionManager = new ExpressionManager(activity, voiceLayout, expressionLayout, expressionGifLayout,
  275 + expressionGifLayoutRecent, inputEt, voiceIv, expressionIv, expressionIvGif,gifListStr,gifRecentListStr);
  276 + if (maxCountLength > 0) {
  277 + expressionManager.setMaxCountLength(maxCountLength);
  278 + }
  279 + expressionManager.setInputTextListener(() -> {
  280 + publishStatus();
  281 + });
  282 +
  283 + //更新输入框gif图
  284 + expressionManager.setGifInputTextListener(this::uploadImgGif);
  285 + //更新最近表情输入框gif图
  286 + expressionManager.setRecentGifInputTextListener(this::uploadImgGif);
  287 + }
  288 +
  289 + public void setIntentBean(VodDetailIntentBean intentBean) {
  290 + this.intentBean = intentBean;
  291 + }
  292 +
  293 + /**
  294 + * 去选择图片
  295 + */
  296 + private void goSelectPic() {
  297 + PermissionsUtils.getCameraAndSdPermission(activity, new IPmsCallBack() {
  298 + @Override
  299 + public void granted() {
  300 +// Matisse.from(activity)
  301 +// .choose(EnumSet.of(MimeType.JPEG, MimeType.PNG, MimeType.GIF, MimeType.BMP), true)
  302 +// .countable(true)
  303 +// .maxSelectable(1)
  304 +// .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
  305 +// .thumbnailScale(0.85f)
  306 +// .imageEngine(new GlideEngine())
  307 +// //这两行要连用 是否在选择图片中展示照相 和适配安卓7.0 FileProvider
  308 +// .capture(true)
  309 +// .captureStrategy(new CaptureStrategy(true, BaseConstants.FILE_PROVIDER))
  310 +// //评论框跳转
  311 +// .setSkipType(0)
  312 +// //Glide加载方式
  313 +// .imageEngine(new GlideEngine())
  314 +// //Picasso加载方式
  315 +// // .imageEngine(new PicassoEngine())
  316 +// // 单个图片限制大小15M
  317 +// .addFilter(new PicSizeFilter(15* Filter.K*Filter.K))
  318 +// //请求码
  319 +// .forResult(10001);
  320 + }
  321 +
  322 + @Override
  323 + public void notGranted() {
  324 +// ToastNightUtil.showShort("没有权限或拒绝权限");
  325 + }
  326 + });
  327 + }
  328 +
  329 + /**
  330 + * 发送按钮状态
  331 + */
  332 + private void publishStatus() {
  333 + String text = getText().trim();
  334 + if (showImgView.getVisibility() == View.VISIBLE || !TextUtils.isEmpty(text)) {
  335 + publishBtn.setBackgroundResource(R.drawable.shape_comment_input_publish);
  336 + publishBtn.setTextColor(ContextCompat.getColor(publishBtn.getContext(),
  337 + R.color.res_color_common_C8_keep));
  338 + } else {
  339 + publishBtn.setBackgroundResource(R.drawable.shape_comment_input_publish_default);
  340 + publishBtn.setTextColor(ContextCompat.getColor(publishBtn.getContext(),
  341 + R.color.res_color_general_FFFFFF_50_keep));
  342 + }
  343 + }
  344 +
  345 +
  346 + @Override
  347 + public void show() {
  348 + if ("1".equals(BaseConstants.cnCommentAllowed)){
  349 + ToastNightUtil.showShort(ResUtils.getString(R.string.res_unable_to_comment_temporarilyk));
  350 + return;
  351 + }
  352 + super.show();
  353 + }
  354 +
  355 + /**
  356 + * 带有软键盘
  357 + */
  358 + public void showWithSoftBoard() {
  359 + show();
  360 + showSoftBoard();
  361 + }
  362 +
  363 + /**
  364 + * hint为回复userName:
  365 + */
  366 + public void showUserName(String userName) {
  367 + setHint(activity.getResources().getString(R.string.str_reply_other_user, userName));
  368 + showWithSoftBoard();
  369 + }
  370 +
  371 + /**
  372 + * hint为说两句
  373 + */
  374 + public void showDefaultHint(int bestNoticer) {
  375 + if (1 == bestNoticer){
  376 + //开启最佳评论框
  377 + setHint(activity.getResources().getString(R.string.str_best_reviewer));
  378 + }else {
  379 + setHint(activity.getResources().getString(R.string.res_say_two_sentences));
  380 + }
  381 + showWithSoftBoard();
  382 + }
  383 +
  384 + /**
  385 + * 显示图片选择
  386 + */
  387 + public void showWithAddBtn() {
  388 + showWithSoftBoard();
  389 + uploadImgView.setVisibility(View.VISIBLE);
  390 + }
  391 +
  392 + /**
  393 + * 隐藏gif定制表情入口
  394 + */
  395 + public void hideWithGifBtn() {
  396 + showWithSoftBoard();
  397 + expressionIvGif.setVisibility(View.GONE);
  398 + }
  399 +
  400 + /**
  401 + * 设置提示语
  402 + */
  403 + public void setHint(String hint) {
  404 + this.hintStr = hint;
  405 + if (inputEt != null) {
  406 + inputEt.setHint(hint);
  407 + }
  408 + }
  409 +
  410 + public String getText() {
  411 + return inputEt.getText().toString();
  412 + }
  413 +
  414 + public void setCommitDialogListener(CommitDialogListener commitDialogListener) {
  415 + this.commitDialogListener = commitDialogListener;
  416 + }
  417 +
  418 +
  419 + public void closeDialog() {
  420 + dismiss();
  421 + clear();
  422 + }
  423 +
  424 + /**
  425 + * 列表监听
  426 + */
  427 + public void recycler() {
  428 +
  429 + if (EventBus.getDefault().isRegistered(this)) {
  430 + EventBus.getDefault().unregister(this);
  431 + }
  432 +
  433 + if (expressionManager != null) {
  434 + expressionManager.recycler();
  435 + }
  436 + }
  437 +
  438 + /**
  439 + * 横屏直播上传选择图片
  440 + * @param selPaths
  441 + */
  442 + @Subscribe(threadMode = ThreadMode.MAIN)
  443 + public void uploadImgCallback(ArrayList<String> selPaths) {
  444 + ArrayList<String> images = new ArrayList<>();
  445 + images.addAll(selPaths);
  446 + if (images.size() > 0) {
  447 + //接口上传图片
  448 + if (commitDialogListener != null) {
  449 + commitDialogListener.getUnloadImg(images);
  450 + }
  451 + if (images.size() > 0) {
  452 + showImgView.setVisibility(View.VISIBLE);
  453 + publishStatus();
  454 + ImageUtils.getInstance().loadImage(showImageIv, images.get(0), R.drawable.default_placeholder_img);
  455 + }
  456 + }
  457 + }
  458 +
  459 + /**
  460 + * 选择gif图片到输入框
  461 + * @param url
  462 + */
  463 + public void uploadImgGif(String url) {
  464 + if(!TextUtils.isEmpty(url)){
  465 + showImgView.setVisibility(View.VISIBLE);
  466 + publishStatus();
  467 + ImageUtils.getInstance().loadImage(showImageIv, url, R.drawable.default_placeholder_img);
  468 + gifUrl = url;
  469 + //最近表情存储
  470 + if(gifRecentListStr != null) {
  471 + if(gifRecentListStr.contains(gifUrl)){
  472 + gifRecentListStr.remove(gifUrl);
  473 + }else if (gifRecentListStr.size() > 4){
  474 + gifRecentListStr.remove(4);
  475 + }
  476 + gifRecentListStr.add(0, gifUrl);
  477 + }
  478 +
  479 + if(gifRecentListStr != null && gifRecentListStr.size() >0 ){
  480 + StringBuilder stringBuilder = new StringBuilder();
  481 + for(int i=0; i<gifRecentListStr.size(); i++){
  482 + stringBuilder.append(gifRecentListStr.get(i));
  483 + if(i < gifRecentListStr.size()-1){
  484 + stringBuilder.append(";");
  485 + }
  486 + if(!TextUtils.isEmpty(stringBuilder)){
  487 + SpUtils.saveGifIcon(stringBuilder.toString());
  488 + }
  489 + }
  490 +
  491 + }
  492 + }else{
  493 + gifUrl = "";
  494 + }
  495 +
  496 + }
  497 +
  498 +
  499 +
  500 + /**
  501 + * 消失
  502 + */
  503 + @Override
  504 + public void dismiss() {
  505 + super.dismiss();
  506 + expressionManager.resetStatus();
  507 +// resetImageStatus();
  508 + }
  509 +
  510 + /**
  511 + * 显示软键盘
  512 + */
  513 + private void showSoftBoard() {
  514 +// HandlerHelper.main().postDelayed(() -> {
  515 +// if (activity == null || activity.isDestroyed()) {
  516 +// return;
  517 +// }
  518 +// if (inputEt != null) {
  519 +// KeyboardHelper.showSoftInput(inputEt);
  520 +// inputEt.requestFocus();
  521 +// }
  522 +// }, 200);
  523 + }
  524 +
  525 + /**
  526 + * 清除所有输入
  527 + */
  528 + public void clear() {
  529 + if (inputEt != null && inputEt.getEditableText() != null) {
  530 + inputEt.getEditableText().clear();
  531 + }
  532 +
  533 + resetImageStatus();
  534 + }
  535 +
  536 + /**
  537 + * 重置图片状态
  538 + */
  539 + private void resetImageStatus() {
  540 + if (showImgView != null && showImgView.getVisibility() == View.VISIBLE) {
  541 + showImgView.setVisibility(View.GONE);
  542 + ImageUtils.getInstance().loadImage(showImageIv, "");
  543 + }
  544 + }
  545 +
  546 + /**
  547 + * 清除输入框里的内容
  548 + */
  549 + public void clearEditText() {
  550 + if (inputEt != null) {
  551 + inputEt.setText("");
  552 + }
  553 + resetImageStatus();
  554 + }
  555 + /**
  556 + *评论发布埋点数据
  557 + */
  558 + public void setTrackContentBean(TrackContentBean trackContentBean){
  559 + this.mTrackContentBean = trackContentBean;
  560 + }
  561 +
  562 + public TrackContentBean getmTrackContentBean(){
  563 + return mTrackContentBean;
  564 + }
  565 +}
  1 +
  2 +package com.people.comment.dialog;
  3 +
  4 +import android.content.Context;
  5 +import android.os.Bundle;
  6 +import android.view.View;
  7 +import android.view.ViewGroup;
  8 +import android.widget.TextView;
  9 +
  10 +import androidx.annotation.NonNull;
  11 +import androidx.core.content.ContextCompat;
  12 +
  13 +import com.google.android.material.bottomsheet.BottomSheetDialog;
  14 +import com.people.comment.R;
  15 +import com.wd.foundation.bean.custom.content.CommentItem;
  16 +
  17 +/**
  18 + * 个人主页-我的评论列表操作弹框
  19 + * * @author ouyang
  20 + * * @version [V1.0.0, 2023/5/10]
  21 + */
  22 +public class CommentOperationsDialog extends BottomSheetDialog implements View.OnClickListener {
  23 +
  24 +
  25 + /**
  26 + * 回复
  27 + */
  28 + public static final int OPERATION_TYPE_ANSWER = 1;
  29 + /**
  30 + * 删除
  31 + */
  32 + public static final int OPERATION_TYPE_DELETE = 2;
  33 + /**
  34 + * 复制
  35 + */
  36 + public static final int OPERATION_TYPE_COPY = 3;
  37 + /**
  38 + * 分享
  39 + */
  40 + public static final int OPERATION_TYPE_SHARE = 4;
  41 + /**
  42 + * 举报
  43 + */
  44 + public static final int OPERATION_TYPE_REPORT = 5;
  45 +
  46 + /**
  47 + * 是否主态
  48 + */
  49 + private boolean isSelf;
  50 +
  51 + private OnButtonClickListener listener;
  52 +
  53 + private TextView tv_share, tv_answer_delete, tv_copy;
  54 +
  55 + private CommentItem currentEditObj;
  56 +
  57 + private int currentEditPosition;
  58 +
  59 +
  60 +
  61 +
  62 + public CommentOperationsDialog(@NonNull Context context,boolean isSelf) {
  63 + super(context, R.style.BottomSheetDialog);
  64 + this.isSelf = isSelf;
  65 + }
  66 +
  67 + public void setData(CommentItem currentEditFeedObj, int currentEditPosition) {
  68 + this.currentEditObj = currentEditFeedObj;
  69 + this.currentEditPosition = currentEditPosition;
  70 + initView();
  71 + }
  72 +
  73 + @Override
  74 + protected void onCreate(Bundle savedInstanceState) {
  75 + super.onCreate(savedInstanceState);
  76 + setContentView(R.layout.comment_operations_dialog);
  77 + initOption();
  78 + TextView tv_cancel = findViewById(R.id.tv_cancel);
  79 + tv_answer_delete = findViewById(R.id.tv_answer_delete);
  80 + tv_copy = findViewById(R.id.tv_copy);
  81 + tv_share = findViewById(R.id.tv_share);
  82 + tv_cancel.setOnClickListener(this);
  83 + tv_answer_delete.setOnClickListener(this);
  84 + tv_copy.setOnClickListener(this);
  85 + tv_share.setOnClickListener(this);
  86 + initView();
  87 + }
  88 +
  89 + public void initView() {
  90 + if (tv_share == null){
  91 + return;
  92 + }
  93 + if (isSelf) {
  94 + tv_answer_delete.setText("删除");
  95 + } else {
  96 + tv_answer_delete.setText("回复");
  97 + }
  98 + }
  99 +
  100 + private void initOption() {
  101 + getDelegate().findViewById(com.google.android.material.R.id.design_bottom_sheet)
  102 + .setBackgroundColor(ContextCompat.getColor(getContext(),android.R.color.transparent));
  103 + getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
  104 + }
  105 +
  106 + @Override
  107 + public void onClick(View v) {
  108 + if (v.getId() == R.id.tv_cancel) {
  109 + dismiss();
  110 + } else if (v.getId() == R.id.tv_answer_delete) {
  111 + if (listener != null) {
  112 + if (isSelf) {
  113 + // 删除
  114 + listener.onDialogItemClick(CommentOperationsDialog.OPERATION_TYPE_DELETE, currentEditObj,currentEditPosition);
  115 + }else{
  116 + // 回复
  117 + listener.onDialogItemClick(CommentOperationsDialog.OPERATION_TYPE_ANSWER, currentEditObj,currentEditPosition);
  118 + }
  119 +
  120 + }
  121 + dismiss();
  122 + } else if (v.getId() == R.id.tv_copy) {
  123 + // 复制
  124 + if (listener != null) {
  125 + listener.onDialogItemClick(CommentOperationsDialog.OPERATION_TYPE_COPY, currentEditObj,currentEditPosition);
  126 + }
  127 + } else if (v.getId() == R.id.tv_share) {
  128 + // 分享
  129 + if (listener != null) {
  130 + listener.onDialogItemClick(CommentOperationsDialog.OPERATION_TYPE_SHARE, currentEditObj,currentEditPosition);
  131 + }
  132 + }
  133 + }
  134 +
  135 + public interface OnButtonClickListener {
  136 + void onDialogItemClick(int types, CommentItem currentObj, int currentPosition);
  137 + }
  138 +
  139 + public void setListener(OnButtonClickListener listener) {
  140 + this.listener = listener;
  141 + }
  142 +}