From 9158424a2515d30ab6d249977d24b236ba79742a Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Fri, 23 Dec 2022 18:28:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=BA=E5=99=A8=E4=BA=BA=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8F=91=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/adapter/RobotMessageAdapter.java | 51 +++++ .../yunbao/common/bean/LiveAiRobotBean.java | 12 +- .../common/event/LiveRobotMessageEvent.java | 16 ++ .../com/yunbao/common/http/PDLiveApi.java | 6 +- .../common/http/live/LiveNetManager.java | 7 + .../yunbao/common/views/InputCustomPopup.java | 92 ++++++++ .../views/LiveRobotMessageCustomPopup.java | 181 ++++++++++++++++ .../views/LiveRobotSettingCustomPopup.java | 196 ++++++++++++++++++ .../common/views/RobotMessageViewHolder.java | 77 +++++++ .../main/res/drawable/background_81c16d.xml | 0 .../src/main/res/drawable/bg_prank_coin.xml | 0 .../res/layout/dialog_live_robot_message.xml | 48 +++-- .../res/layout/dialog_live_robot_setting.xml | 16 +- .../main/res/layout/input_custom_popup.xml | 69 ++++++ .../main/res/layout/view_robot_message.xml | 43 ++++ .../src/main/res/mipmap-xxhdpi/icon_close.png | Bin 0 -> 2524 bytes .../LiveRobotMessageDialogFragment.java | 37 ---- .../LiveRobotSettingDialogFragment.java | 109 +--------- .../live/views/LiveNewReadyRyViewHolder.java | 29 +-- 19 files changed, 797 insertions(+), 192 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/adapter/RobotMessageAdapter.java create mode 100644 common/src/main/java/com/yunbao/common/event/LiveRobotMessageEvent.java create mode 100644 common/src/main/java/com/yunbao/common/views/InputCustomPopup.java create mode 100644 common/src/main/java/com/yunbao/common/views/LiveRobotMessageCustomPopup.java create mode 100644 common/src/main/java/com/yunbao/common/views/LiveRobotSettingCustomPopup.java create mode 100644 common/src/main/java/com/yunbao/common/views/RobotMessageViewHolder.java rename {live => common}/src/main/res/drawable/background_81c16d.xml (100%) rename {live => common}/src/main/res/drawable/bg_prank_coin.xml (100%) rename {live => common}/src/main/res/layout/dialog_live_robot_message.xml (77%) rename {live => common}/src/main/res/layout/dialog_live_robot_setting.xml (93%) create mode 100644 common/src/main/res/layout/input_custom_popup.xml create mode 100644 common/src/main/res/layout/view_robot_message.xml create mode 100644 common/src/main/res/mipmap-xxhdpi/icon_close.png delete mode 100644 live/src/main/java/com/yunbao/live/dialog/LiveRobotMessageDialogFragment.java diff --git a/common/src/main/java/com/yunbao/common/adapter/RobotMessageAdapter.java b/common/src/main/java/com/yunbao/common/adapter/RobotMessageAdapter.java new file mode 100644 index 000000000..a9745714a --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/RobotMessageAdapter.java @@ -0,0 +1,51 @@ +package com.yunbao.common.adapter; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.LiveAiRobotBean; +import com.yunbao.common.views.RobotMessageViewHolder; + +import java.util.ArrayList; +import java.util.List; + +public class RobotMessageAdapter extends RecyclerView.Adapter { + private List messageList = new ArrayList<>(); + + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View robotMessageView = LayoutInflater.from(parent.getContext()).inflate(R.layout.view_robot_message, parent, false); + return new RobotMessageViewHolder(robotMessageView); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + RobotMessageViewHolder messageViewHolder = (RobotMessageViewHolder) holder; + messageViewHolder.setData(messageList.get(position), position + 1); + + } + + @Override + public int getItemCount() { + return messageList.size(); + } + + + public void setDataAll(List messages) { + messageList.clear(); + messageList.addAll(messages); + notifyDataSetChanged(); + } + + // 删除数据 + public void removeData(int position) { + messageList.remove(position); + //删除动画 + notifyItemRemoved(position); + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/LiveAiRobotBean.java b/common/src/main/java/com/yunbao/common/bean/LiveAiRobotBean.java index 26ba27052..44e8b9f95 100644 --- a/common/src/main/java/com/yunbao/common/bean/LiveAiRobotBean.java +++ b/common/src/main/java/com/yunbao/common/bean/LiveAiRobotBean.java @@ -15,9 +15,9 @@ public class LiveAiRobotBean extends BaseModel { @SerializedName("ai_time") private int time; @SerializedName("ai_sayhi") - private String autoSeyHiNumber;// 自动打招呼已配置数量 + private int autoSeyHiNumber;// 自动打招呼已配置数量 @SerializedName("ai_gz") - private String autoRequestFollowNumber;//自动求关注已配置数量 + private int autoRequestFollowNumber;//自动求关注已配置数量 public LiveAiRobotBean() { } @@ -46,19 +46,19 @@ public class LiveAiRobotBean extends BaseModel { this.time = time; } - public String getAutoSeyHiNumber() { + public int getAutoSeyHiNumber() { return autoSeyHiNumber; } - public void setAutoSeyHiNumber(String autoSeyHiNumber) { + public void setAutoSeyHiNumber(int autoSeyHiNumber) { this.autoSeyHiNumber = autoSeyHiNumber; } - public String getAutoRequestFollowNumber() { + public int getAutoRequestFollowNumber() { return autoRequestFollowNumber; } - public void setAutoRequestFollowNumber(String autoRequestFollowNumber) { + public void setAutoRequestFollowNumber(int autoRequestFollowNumber) { this.autoRequestFollowNumber = autoRequestFollowNumber; } diff --git a/common/src/main/java/com/yunbao/common/event/LiveRobotMessageEvent.java b/common/src/main/java/com/yunbao/common/event/LiveRobotMessageEvent.java new file mode 100644 index 000000000..815b58813 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/LiveRobotMessageEvent.java @@ -0,0 +1,16 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; + +public class LiveRobotMessageEvent extends BaseModel { + private int index = -1; + + public int getIndex() { + return index; + } + + public LiveRobotMessageEvent setIndex(int index) { + this.index = index; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 91d73d34c..1edb1f6ca 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -505,7 +505,7 @@ public interface PDLiveApi { * 机器人添加话术 */ @GET("/api/public/?service=Live.addAiAutomaticSpeech") - Observable> addAiAutomaticSpeech( + Observable>> addAiAutomaticSpeech( @Query("type") String type, @Query("content") String content ); @@ -514,7 +514,7 @@ public interface PDLiveApi { * 机器人删除话术 */ @GET("/api/public/?service=Live.delAiAutomaticSpeech ") - Observable> delAiAutomaticSpeech( + Observable>> delAiAutomaticSpeech( @Query("type") String type, @Query("id") String id ); @@ -523,7 +523,7 @@ public interface PDLiveApi { * 机器人修改话术 */ @GET("/api/public/?service=Live.updateAiAutomaticSpeech ") - Observable> updateAiAutomaticSpeech( + Observable>> updateAiAutomaticSpeech( @Query("type") String type, @Query("id") String id, @Query("content") String content diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 41a7dce15..d83668492 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -903,6 +903,7 @@ public class LiveNetManager { API.get().pdLiveApi(mContext) .getAnchorAiState() .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) .subscribe(responseModel -> { if (callback != null) { callback.onSuccess(responseModel.getData().getInfo()); @@ -921,6 +922,7 @@ public class LiveNetManager { API.get().pdLiveApi(mContext) .setAnchorAiState(status) .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) .subscribe(responseModel -> { if (callback != null) { callback.onSuccess(null); @@ -941,6 +943,7 @@ public class LiveNetManager { API.get().pdLiveApi(mContext) .setAnchorAiState(map) .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) .subscribe(responseModel -> { if (callback != null) { callback.onSuccess(null); @@ -959,6 +962,7 @@ public class LiveNetManager { API.get().pdLiveApi(mContext) .getAiAutomaticSpeech(type + "") .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) .subscribe(responseModel -> { if (callback != null) { callback.onSuccess(responseModel.getData().getInfo()); @@ -977,6 +981,7 @@ public class LiveNetManager { API.get().pdLiveApi(mContext) .addAiAutomaticSpeech(type + "", content) .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) .subscribe(responseModel -> { if (callback != null) { callback.onSuccess(new HttpCallbackModel(responseModel.getData().getCode(), responseModel.getData().getMsg())); @@ -995,6 +1000,7 @@ public class LiveNetManager { API.get().pdLiveApi(mContext) .updateAiAutomaticSpeech(type + "", id + "", content) .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) .subscribe(responseModel -> { if (callback != null) { callback.onSuccess(new HttpCallbackModel(responseModel.getData().getCode(), responseModel.getData().getMsg())); @@ -1013,6 +1019,7 @@ public class LiveNetManager { API.get().pdLiveApi(mContext) .delAiAutomaticSpeech(type + "", id + "") .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) .subscribe(responseModel -> { if (callback != null) { callback.onSuccess(new HttpCallbackModel(responseModel.getData().getCode(), responseModel.getData().getMsg())); diff --git a/common/src/main/java/com/yunbao/common/views/InputCustomPopup.java b/common/src/main/java/com/yunbao/common/views/InputCustomPopup.java new file mode 100644 index 000000000..8ad8f995a --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/InputCustomPopup.java @@ -0,0 +1,92 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.text.TextUtils; +import android.view.View; +import android.widget.EditText; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.animator.PopupAnimator; +import com.lxj.xpopup.core.CenterPopupView; +import com.yunbao.common.R; +import com.yunbao.common.utils.ToastUtil; + +/** + * 输入弹窗 + */ +public class InputCustomPopup extends CenterPopupView { + private String message = ""; + + public InputCustomPopup(@NonNull Context context, String message) { + super(context); + this.message = message; + } + + public InputCustomPopup(@NonNull Context context) { + super(context); + } + + // 返回自定义弹窗的布局 + @Override + protected int getImplLayoutId() { + return R.layout.input_custom_popup; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + EditText content = findViewById(R.id.content); + content.setText(message); + findViewById(R.id.btn_cancel).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + dismiss(); // 关闭弹窗 + } + }); + findViewById(R.id.btn_confirm).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + String textContent = content.getText().toString(); + if (TextUtils.isEmpty(textContent)) { + ToastUtil.show("输入内容不可为空"); + return; + } + if (listener != null) { + listener.onConfirm(textContent); + } + dismiss(); // 关闭弹窗 + } + }); + } + + // 设置最大宽度,看需要而定, + @Override + protected int getMaxWidth() { + return super.getMaxWidth(); + } + + // 设置最大高度,看需要而定 + @Override + protected int getMaxHeight() { + return super.getMaxHeight(); + } + + // 设置自定义动画器,看需要而定 + @Override + protected PopupAnimator getPopupAnimator() { + return super.getPopupAnimator(); + } + + public interface InputCustomListener { + void onConfirm(String text); + } + + private InputCustomListener listener; + + public InputCustomPopup setListener(InputCustomListener listener) { + this.listener = listener; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/views/LiveRobotMessageCustomPopup.java b/common/src/main/java/com/yunbao/common/views/LiveRobotMessageCustomPopup.java new file mode 100644 index 000000000..953e9c7fe --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/LiveRobotMessageCustomPopup.java @@ -0,0 +1,181 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; + +import com.lxj.xpopup.XPopup; +import com.lxj.xpopup.core.BottomPopupView; +import com.yunbao.common.R; +import com.yunbao.common.adapter.RobotMessageAdapter; +import com.yunbao.common.bean.HttpCallbackModel; +import com.yunbao.common.bean.LiveAiRobotBean; +import com.yunbao.common.event.LiveRobotMessageEvent; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.ToastUtil; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.List; + +public class LiveRobotMessageCustomPopup extends BottomPopupView { + private static String TAG = "AI机器人"; + private RecyclerView robotMessages; + private RobotMessageAdapter robotMessageAdapter; + + private EditText robotNameSetting; + private TextView robotTime; + private String robotTimeString = ""; + + public LiveRobotMessageCustomPopup(@NonNull Context context, String robotTime) { + super(context); + this.robotTimeString = robotTime; + } + + public LiveRobotMessageCustomPopup(@NonNull Context context) { + super(context); + } + + // 返回自定义弹窗的布局 + @Override + protected int getImplLayoutId() { + return R.layout.dialog_live_robot_message; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + Bus.getOn(this); + initView(); + initDate(); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onLiveRobotMessageEvent(LiveRobotMessageEvent event) { + if (event.getIndex() > 0) { + robotMessageAdapter.removeData(event.getIndex()); + } else { + initDate(); + } + + } + + @Override + public void onDestroy() { + super.onDestroy(); + Bus.getOff(this); + } + + + private void initView() { + robotMessages = (RecyclerView) findViewById(R.id.robot_messages); + robotNameSetting = findViewById(R.id.robot_name_setting); + robotTime = findViewById(R.id.robot_time); + robotMessageAdapter = new RobotMessageAdapter(); + robotMessages.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); + robotMessages.setAdapter(robotMessageAdapter); + robotTime.setText(robotTimeString); + findViewById(R.id.bt_cancel).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + dismiss(); + } + }); + robotTime.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + robotTime.setVisibility(GONE); + robotNameSetting.setVisibility(VISIBLE); + robotNameSetting.setText(robotTime.getText().toString()); + //输入框,获取焦点 不然无法弹出键盘 + robotNameSetting.requestFocus(); + //键盘输入法管理器 + InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(robotNameSetting, 0); + } + }); + robotNameSetting.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_DONE) { + // 修改助手名字 + LiveNetManager.get(getContext()) + .setAiRobotDate("ai_time", robotNameSetting.getText().toString(), new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + robotNameSetting.setVisibility(GONE); + robotTime.setVisibility(VISIBLE); + robotTime.setText(robotNameSetting.getText().toString()); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + + } + return false; + } + }); + //添加消息语 + findViewById(R.id.robot_add_content).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + new XPopup.Builder(getContext()) + .asCustom(new InputCustomPopup(getContext()).setListener(new InputCustomPopup.InputCustomListener() { + @Override + public void onConfirm(String text) { + //添加消息语 + LiveNetManager.get(getContext()) + .addAiRobotBody(LiveAiRobotBean.Message.TYPE_FOLLOW, text, new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + initDate(); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } + })) + .show(); + } + }); + } + + private void initDate() { + + LiveNetManager.get(getContext()) + .getAiRobotBody(LiveAiRobotBean.Message.TYPE_FOLLOW, new HttpCallback>() { + @Override + public void onSuccess(List data) { + Log.i(TAG, "onSuccess: " + data.size()); + for (LiveAiRobotBean.Message message : data) { + Log.i(TAG, "onSuccess: message=" + message.toString()); + } + robotMessageAdapter.setDataAll(data); + } + + @Override + public void onError(String error) { + + } + }); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/LiveRobotSettingCustomPopup.java b/common/src/main/java/com/yunbao/common/views/LiveRobotSettingCustomPopup.java new file mode 100644 index 000000000..4b66f3e4e --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/LiveRobotSettingCustomPopup.java @@ -0,0 +1,196 @@ +package com.yunbao.common.views; + +import android.content.Context; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.appcompat.widget.AppCompatTextView; + +import com.lxj.xpopup.XPopup; +import com.lxj.xpopup.core.BasePopupView; +import com.lxj.xpopup.core.BottomPopupView; +import com.lxj.xpopup.interfaces.XPopupCallback; +import com.yunbao.common.R; +import com.yunbao.common.bean.HttpCallbackModel; +import com.yunbao.common.bean.LiveAiRobotBean; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.ToastUtil; + +import java.util.List; + +public class LiveRobotSettingCustomPopup extends BottomPopupView implements View.OnClickListener { + private static String TAG = "AI机器人"; + private EditText robotNameSetting; + private AppCompatTextView automaticGreetingNumber, automaticMessageNumber; + private TextView robotNameText; + private String time = ""; + + public LiveRobotSettingCustomPopup(@NonNull Context context) { + super(context); + } + + // 返回自定义弹窗的布局 + @Override + protected int getImplLayoutId() { + return R.layout.dialog_live_robot_setting; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + intiView(); + initDate(); + } + + private void intiView() { + robotNameSetting = findViewById(R.id.robot_name_setting); + robotNameText = findViewById(R.id.robot_name_text); + automaticGreetingNumber = findViewById(R.id.automatic_greeting_number); + automaticMessageNumber = findViewById(R.id.automatic_message_number); + findViewById(R.id.automatic_message_sending).setOnClickListener(this); + robotNameText.setOnClickListener(this); + robotNameSetting.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + if (actionId == EditorInfo.IME_ACTION_DONE) { + // 修改助手名字 + LiveNetManager.get(getContext()) + .setAiRobotDate("ai_name", robotNameSetting.getText().toString(), new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + robotNameSetting.setVisibility(GONE); + robotNameText.setVisibility(VISIBLE); + robotNameText.setText(robotNameSetting.getText().toString()); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + + } + return false; + } + }); + } + + @Override + public void onClick(View v) { + int viewID = v.getId(); + if (viewID == R.id.automatic_message_sending) { + new XPopup.Builder(getContext()) + .setPopupCallback(new XPopupCallback() { + @Override + public void onCreated(BasePopupView popupView) { + + } + + @Override + public void beforeShow(BasePopupView popupView) { + + } + + @Override + public void onShow(BasePopupView popupView) { + + } + + @Override + public void onDismiss(BasePopupView popupView) { + initDate(); + } + + @Override + public void beforeDismiss(BasePopupView popupView) { + + } + + @Override + public boolean onBackPressed(BasePopupView popupView) { + return false; + } + + @Override + public void onKeyBoardStateChanged(BasePopupView popupView, int height) { + + } + + @Override + public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) { + + } + + @Override + public void onClickOutside(BasePopupView popupView) { + + } + }) + .asCustom(new LiveRobotMessageCustomPopup(getContext(), time)) + .show(); + } else if (viewID == R.id.robot_name_text) { + robotNameText.setVisibility(GONE); + robotNameSetting.setVisibility(VISIBLE); + robotNameSetting.setText(robotNameText.getText().toString()); + //输入框,获取焦点 不然无法弹出键盘 + robotNameSetting.requestFocus(); + //键盘输入法管理器 + InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(robotNameSetting, 0); + } + } + + private void initDate() { + LiveNetManager.get(getContext()) + .getAiRobotStatus(new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(LiveAiRobotBean data) { + robotNameText.setText(data.getName()); + automaticGreetingNumber.setText(String.valueOf(data.getAutoSeyHiNumber())); + automaticMessageNumber.setText(String.valueOf(data.getAutoRequestFollowNumber())); + time = String.valueOf(data.getTime()); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + + initListType1(); + initListType2(); + } + + + private void initListType1() { + LiveNetManager.get(getContext()) + .getAiRobotBody(LiveAiRobotBean.Message.TYPE_SAY_HI, new HttpCallback>() { + @Override + public void onSuccess(List data) { + Log.i(TAG, "onSuccess 自动打招呼 : " + data.size()); + for (LiveAiRobotBean.Message message : data) { + Log.i(TAG, "onSuccess: message=" + message.toString()); + } + + + } + + @Override + public void onError(String error) { + + } + }); + } + + private void initListType2() { + + } +} diff --git a/common/src/main/java/com/yunbao/common/views/RobotMessageViewHolder.java b/common/src/main/java/com/yunbao/common/views/RobotMessageViewHolder.java new file mode 100644 index 000000000..f182a0c12 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/RobotMessageViewHolder.java @@ -0,0 +1,77 @@ +package com.yunbao.common.views; + +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.lxj.xpopup.XPopup; +import com.yunbao.common.R; +import com.yunbao.common.bean.HttpCallbackModel; +import com.yunbao.common.bean.LiveAiRobotBean; +import com.yunbao.common.event.LiveRobotMessageEvent; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.ToastUtil; + + +public class RobotMessageViewHolder extends RecyclerView.ViewHolder { + private TextView serialNumber, messageText; + private ImageView btnDelete; + + public RobotMessageViewHolder(@NonNull View itemView) { + super(itemView); + serialNumber = itemView.findViewById(R.id.serial_number); + messageText = itemView.findViewById(R.id.message_text); + btnDelete = itemView.findViewById(R.id.btn_delete); + } + + public void setData(LiveAiRobotBean.Message message, int index) { + serialNumber.setText(String.valueOf(index)); + messageText.setText(message.getContent()); + btnDelete.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + LiveNetManager.get(itemView.getContext()) + .delAiRobotBody(LiveAiRobotBean.Message.TYPE_FOLLOW, message.getId(), new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + Bus.get().post(new LiveRobotMessageEvent().setIndex(index - 1)); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } + }); + messageText.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + new XPopup.Builder(itemView.getContext()) + .asCustom(new InputCustomPopup(itemView.getContext(), message.getContent()).setListener(new InputCustomPopup.InputCustomListener() { + @Override + public void onConfirm(String text) { + LiveNetManager.get(itemView.getContext()) + .updateAiRobotBody(LiveAiRobotBean.Message.TYPE_FOLLOW, message.getId(), text, new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + Bus.get().post(new LiveRobotMessageEvent()); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + } + })) + .show(); + } + }); + } +} diff --git a/live/src/main/res/drawable/background_81c16d.xml b/common/src/main/res/drawable/background_81c16d.xml similarity index 100% rename from live/src/main/res/drawable/background_81c16d.xml rename to common/src/main/res/drawable/background_81c16d.xml diff --git a/live/src/main/res/drawable/bg_prank_coin.xml b/common/src/main/res/drawable/bg_prank_coin.xml similarity index 100% rename from live/src/main/res/drawable/bg_prank_coin.xml rename to common/src/main/res/drawable/bg_prank_coin.xml diff --git a/live/src/main/res/layout/dialog_live_robot_message.xml b/common/src/main/res/layout/dialog_live_robot_message.xml similarity index 77% rename from live/src/main/res/layout/dialog_live_robot_message.xml rename to common/src/main/res/layout/dialog_live_robot_message.xml index 570cce7b2..ef60a75bc 100644 --- a/live/src/main/res/layout/dialog_live_robot_message.xml +++ b/common/src/main/res/layout/dialog_live_robot_message.xml @@ -15,6 +15,7 @@ app:layout_constraintTop_toTopOf="parent"> + - + + + + + diff --git a/live/src/main/res/layout/dialog_live_robot_setting.xml b/common/src/main/res/layout/dialog_live_robot_setting.xml similarity index 93% rename from live/src/main/res/layout/dialog_live_robot_setting.xml rename to common/src/main/res/layout/dialog_live_robot_setting.xml index 43ed93407..56cc25d65 100644 --- a/live/src/main/res/layout/dialog_live_robot_setting.xml +++ b/common/src/main/res/layout/dialog_live_robot_setting.xml @@ -89,8 +89,22 @@ android:inputType="text" android:maxLines="1" android:textColor="#FFF" - android:textSize="12sp" /> + android:textSize="12sp" + android:visibility="gone" /> + diff --git a/common/src/main/res/layout/input_custom_popup.xml b/common/src/main/res/layout/input_custom_popup.xml new file mode 100644 index 000000000..a7d7aeabb --- /dev/null +++ b/common/src/main/res/layout/input_custom_popup.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_robot_message.xml b/common/src/main/res/layout/view_robot_message.xml new file mode 100644 index 000000000..7a85c2a32 --- /dev/null +++ b/common/src/main/res/layout/view_robot_message.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/icon_close.png b/common/src/main/res/mipmap-xxhdpi/icon_close.png new file mode 100644 index 0000000000000000000000000000000000000000..7842d906ace66ddc1adb9781ca3ceab5738c4a1a GIT binary patch literal 2524 zcmV<22_yE2P)1^@s6$I7^K00001b5ch_0Itp) z=>Px;mPtfGRCr$HTnlUz=Mnz?y~8$!14?;=00A)=EMB361}GssYAEInP1}SjC9Nt{ z(B1A9L|TPw8=>01{|;m&QG|kMlZaO4O~JG!2oR(o0u)G~JOeHi1m$5H^Dw^st66Rr zzs|S!*fZyjWLdhMe`fygX6K)oe{6;%lGp3asI06UD1^w;G_8juNu7ldZEBcMCWNSz zB%mUEPvNhHi&j}$u5kjmD1OnHrEwRRxNHCZz%Xy5kw*kCl zO?_NkPXK)4a5(Y{3JT7~B`LHxAz;X|Jf1NY2)zc0uqzrF8i4gqr}ORn{QS~r7S`pB z3kc5-1@Pwcyitp`Q4GoB zoYNQEAT-l{t093qg2{pl(v>@nl`X*)msmY zWy_Yet*)-V0H8yZ3Q~>zQ_lJ8HI1$ZhN`N|g%B%KZD%pqt7)1xG!O`!GS=1tBa~cS z{y*>vWB=tz)%#0TqY+~cNUA?LWp<#e*f=k zd4?>@Ll|TKj74BWYbH&agh7J_;n=Zb*uQ^&Lc}u0(6M7j+`W4jPo7ZMFClcEbDmWT z3`J20onI$JJk`!imY_w87P`2TCr@Jc?%fa~_KrWvnmKbOdiLyzva&L)Tel9?)iE`+ z>TOZew80ce&DTUxl+P1co(~;56cZ*)FcqIUa|R_PB{2b#o}P}`vuC4Qw{E7qHEY(O zyu3V7-`#S~`R{cwmM&fD3I>CBVz|?2)R@782V>&Ii6HkTI)DB=cI?=JV32AiYt*u3 zOU#)w2c0{2HWwT^bO;9z9<(OF0+$ftZ+^f3ySkMgk0)1>q_EYT1$kjvva_=>Wy%y2 zkV}^?Vf*&&mRvkDGZXXX%|nL{&+@+m2M*xy;luHm)X>^8&iOZVFcd{m0QeHE!H}1g zm4&HOr^4ZI=pU7qmSW46EsX|2m&=8@bLXOc`}U?;d-v|e(W6IgF;mmD7Yr~y1n@Ik zw1kBA>C*>!d3kU;pWZHByLJtmH*dz{$B*l&ZQHi3?h*9cAPT@IPMomKM8?=O9Sm8P z_cO-E+NLQaxL2=Um@#99dCJ_laRVDSZp5QUk4)9%3FHyv8ANmf?b@{qr%#`@+q@-) zXPg7@g5BCke)sO(^^+kjElpQ<>((u7*suW)9z4)v0|C*hRV)1&1zI|R&Yn%k?O~+t zy=#C$BLL4{&PdDReBPx?7yX3D$jHzo-MMoI`}XZaZf-8<^e}*+Kzs3G)OSI#TKB#I z#ytSfUeH*@MX|0^r%pN`bYj#c$}YEV-HIz$u0$a*Zq~I%%&2UN_8!HD`Sa(SuLW(V zs;Wv4tXHpIjeB=d3i!CmJcA7F-McrYPoHiERQjy4vJ%C`#khT&-rVF7W9$RNGp;bk zdL~ab(63)VOq({%%sp!Ae)#aA9#n7MyqQdsxZxRJ0C+K3ng08LPskF*JQ^J z#@G)GFn$Bz9lOD(Tgl$LcTbNGHLFiLZYdAx+O?~04xKF9wr#`Z%hZjul}6}bsH*y! z5Q4nJHX1Qv1jdaUXUeDCf`GVx|9(B4l#tDuH48m@^w6JC@?~?*LG8abIv8%ZySKyP zpm|GMXw;}t7(IHlDVqW##RJMZ!x1%eD0Qb4o=DR)J+9c4jUMHkKlKbEMNuf#>yv0S z#*Q6}kt0W%VjHSQ!s(;lhO`8>QBiV#m_R zrA`^uEdvJ*H0ABtvj@kIACF{)mFMMERaKpeii#eaV9;oDT3XtF5>>F#JHKGT0uU${ zE?m&teepDK2@q-_QY(>&ysM}vAy+(WIp_MfR_oqGmgUuqu_adEw8BGxP+x*hjzrOz zF=H@n*f5+rbqdt^ikBow8dF$Us5ew=f#LCZ`bm;>Cee-Icn!93{c+B@8Pw`sJj=5D zDPzpMf3(q%CKpXvr_bm6lVM0bFgza5AW4!=0(e?DG++AC<#G-2dc8Dzu2X}ri4cIpd22Jt+I3k3|ZVqTL#(X}X@0a2B(kK|T zh;k2y!|{1Dh#z}gF4q*V*BiDliUHDG39^P!?(sxdG6`zFlJu zrx{~3di9ad=c}}`Q7b$N2g6WGJ=OH|^jsmtOgiTQbg^Pk7#^CYrRn7oNs=}e78V|h zLsrfoT4juGi@2rVxT=m(DT9zS1=9a3By! mTq89M97zMij&Cy2GXDojl3i65vPCff0000() { - @Override - public void onSuccess(HttpCallbackModel data) { - - } - - @Override - public void onError(String error) { - ToastUtil.show(error); - } - }); - - } - return false; - } - }); - } - - private void initDate() { - robotNameSetting.setText(getArguments().getString("Name", "1")); - automaticGreetingNumber.setText(getArguments().getString("AutoSeyHiNumber", "1")); - automaticMessageNumber.setText(getArguments().getString("AutoRequestFollowNumber", "1")); - initListType1(); - initListType2(); - } - - private void initListType1() { - LiveNetManager.get(mContext) - .getAiRobotBody(LiveAiRobotBean.Message.TYPE_SAY_HI, new HttpCallback>() { - @Override - public void onSuccess(List data) { - Log.i(TAG, "onSuccess 自动打招呼 : " + data.size()); - for (LiveAiRobotBean.Message message : data) { - Log.i(TAG, "onSuccess: message=" + message.toString()); - } - - - } - - @Override - public void onError(String error) { - - } - }); - } - - private void initListType2() { - LiveNetManager.get(mContext) - .getAiRobotBody(LiveAiRobotBean.Message.TYPE_FOLLOW, new HttpCallback>() { - @Override - public void onSuccess(List data) { - Log.i(TAG, "onSuccess: " + data.size()); - for (LiveAiRobotBean.Message message : data) { - Log.i(TAG, "onSuccess: message=" + message.toString()); - } - - } - - @Override - public void onError(String error) { - - } - }); - } - - @Override - public void onClick(View v) { - int viewID = v.getId(); - if (viewID == R.id.automatic_message_sending) { - Bundle mArguments = new Bundle(); - LiveRobotMessageDialogFragment fragment = new LiveRobotMessageDialogFragment(); - fragment.setArguments(mArguments); - fragment.show(getChildFragmentManager(), "LiveRobotMessageDialogFragment"); - } } diff --git a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java index 032294d3f..57be40428 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java @@ -16,14 +16,13 @@ import android.widget.TextView; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.content.ContextCompat; +import com.lxj.xpopup.XPopup; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; -import com.yunbao.common.bean.LiveAiRobotBean; import com.yunbao.common.bean.LiveClassBean; import com.yunbao.common.bean.UserBean; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; -import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.ImageResultCallback; import com.yunbao.common.utils.DialogUitl; @@ -33,6 +32,7 @@ import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.AbsViewHolder; +import com.yunbao.common.views.LiveRobotSettingCustomPopup; import com.yunbao.faceunity.FaceManager; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; @@ -42,7 +42,6 @@ import com.yunbao.live.dialog.LiveFaceUnityDialogFragment; import com.yunbao.live.dialog.LiveNewRoomClassDialogFragment; import com.yunbao.live.dialog.LiveNewRoomTypeDialogFragment; import com.yunbao.live.dialog.LiveNewWishListDialogFragment; -import com.yunbao.live.dialog.LiveRobotSettingDialogFragment; import com.yunbao.live.dialog.LiveTimeDialogFragment; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; @@ -220,27 +219,9 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl RCRTCCameraOutputStream cameraStream = RCRTCEngine.getInstance().getDefaultVideoStream(); cameraStream.setPreviewMirror(!cameraStream.isPreviewMirror()); } else if (i == R.id.btn_robot) { - if (mContext instanceof LiveRyAnchorActivity) { - LiveNetManager.get(mContext) - .getAiRobotStatus(new com.yunbao.common.http.base.HttpCallback() { - @Override - public void onSuccess(LiveAiRobotBean data) { - Bundle mArguments = new Bundle(); - mArguments.putString("Name", data.getName()); - mArguments.putString("AutoSeyHiNumber", data.getAutoSeyHiNumber()); - mArguments.putString("AutoRequestFollowNumber", data.getAutoRequestFollowNumber()); - LiveRobotSettingDialogFragment fragment = new LiveRobotSettingDialogFragment(); - fragment.setArguments(mArguments); - fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveRobotSettingDialogFragment"); - } - - @Override - public void onError(String error) { - ToastUtil.show(error); - } - }); - - } + new XPopup.Builder(mContext) + .asCustom(new LiveRobotSettingCustomPopup(mContext)) + .show(); } }