From a069562bbe044b583a1535cbef5e9584acd0fbea Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Sat, 24 Dec 2022 10:20:51 +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 --- .../views/LiveRobotSettingCustomPopup.java | 38 +++++++++++++++++++ .../res/layout/dialog_live_robot_setting.xml | 1 + 2 files changed, 39 insertions(+) diff --git a/common/src/main/java/com/yunbao/common/views/LiveRobotSettingCustomPopup.java b/common/src/main/java/com/yunbao/common/views/LiveRobotSettingCustomPopup.java index 4b66f3e4e..de72c505c 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveRobotSettingCustomPopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveRobotSettingCustomPopup.java @@ -7,6 +7,7 @@ import android.view.View; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; +import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; @@ -31,6 +32,9 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View private AppCompatTextView automaticGreetingNumber, automaticMessageNumber; private TextView robotNameText; private String time = ""; + private ImageView robotState; + + private int robotStateInt = 1; public LiveRobotSettingCustomPopup(@NonNull Context context) { super(context); @@ -53,10 +57,13 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View private void intiView() { robotNameSetting = findViewById(R.id.robot_name_setting); robotNameText = findViewById(R.id.robot_name_text); + robotState = findViewById(R.id.robot_state); 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); + robotState.setOnClickListener(this); + robotNameSetting.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { @@ -145,6 +152,33 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View //键盘输入法管理器 InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(robotNameSetting, 0); + } else if (viewID == R.id.robot_state) { + int state = 0; + if (robotStateInt == 1) { + state = 0; + } else { + state = 1; + } + // 修改助手名字 + int finalState = state; + LiveNetManager.get(getContext()) + .setAiRobotDate("ai_state", String.valueOf(state), new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + if (finalState == 1) { + robotState.setImageResource(R.mipmap.special_icon_on); + robotStateInt=1; + } else { + robotState.setImageResource(R.mipmap.special_icon_off); + robotStateInt=0; + } + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); } } @@ -157,6 +191,10 @@ public class LiveRobotSettingCustomPopup extends BottomPopupView implements View automaticGreetingNumber.setText(String.valueOf(data.getAutoSeyHiNumber())); automaticMessageNumber.setText(String.valueOf(data.getAutoRequestFollowNumber())); time = String.valueOf(data.getTime()); + robotStateInt = data.getStatus(); + if (data.getStatus() == 1) { + robotState.setImageResource(R.mipmap.special_icon_on); + } } @Override diff --git a/common/src/main/res/layout/dialog_live_robot_setting.xml b/common/src/main/res/layout/dialog_live_robot_setting.xml index 56cc25d65..9e4b2e54c 100644 --- a/common/src/main/res/layout/dialog_live_robot_setting.xml +++ b/common/src/main/res/layout/dialog_live_robot_setting.xml @@ -38,6 +38,7 @@ android:textSize="15sp" />