Merge branch 'dev_robot'

This commit is contained in:
zlzw 2022-12-22 09:59:20 +08:00
commit b1d342f791
8 changed files with 454 additions and 34 deletions

View File

@ -299,7 +299,7 @@
<string name="beautify_hip_slim">Hip</string>
<string name="beautify_head_slim">Head shrink</string>
<string name="beautify_leg_thin_slim">Thin leg</string>
<string name="toast_not_detect_body">No body tracking</string>
<string name="toast_not_detect_body">No message tracking</string>
<string name="pta_human_full_body">Body driver</string>
<string name="pta_human_half_body">Bust driver</string>

View File

@ -5,6 +5,14 @@ public class HttpCallbackModel extends BaseModel{
private int code;
private String msg;
public HttpCallbackModel() {
}
public HttpCallbackModel(int code, String msg) {
this.code = code;
this.msg = msg;
}
public int getCode() {
return code;
}

View File

@ -0,0 +1,138 @@
package com.yunbao.common.bean;
import androidx.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
/**
* 机器人bean
*/
public class LiveAiRobotBean extends BaseModel {
@SerializedName("ai_name")
private String name;
@SerializedName("ai_state")
private int status;//1= 0=
@SerializedName("ai_time")
private int time;
@SerializedName("ai_sayhi")
private int autoSeyHiNumber;// 自动打招呼已配置数量
@SerializedName("ai_gz")
private int autoRequestFollowNumber;//自动求关注已配置数量
public LiveAiRobotBean() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
public int getAutoSeyHiNumber() {
return autoSeyHiNumber;
}
public void setAutoSeyHiNumber(int autoSeyHiNumber) {
this.autoSeyHiNumber = autoSeyHiNumber;
}
public int getAutoRequestFollowNumber() {
return autoRequestFollowNumber;
}
public void setAutoRequestFollowNumber(int autoRequestFollowNumber) {
this.autoRequestFollowNumber = autoRequestFollowNumber;
}
@NonNull
@Override
public String toString() {
return "LiveAiRobotBean{" +
"name='" + name + '\'' +
", status=" + status +
", time=" + time +
", autoSeyHiNumber=" + autoSeyHiNumber +
", autoRequestFollowNumber=" + autoRequestFollowNumber +
'}';
}
/**
* 机器人消息
*/
public static class Message {
public static final int TYPE_SAY_HI=1;//自动打招呼
public static final int TYPE_FOLLOW=3;//自动求关注
@SerializedName("id")
private int id;
@SerializedName("uid")
private int uid;
@SerializedName("type")
private int type;
@SerializedName("content")
private String content;
public Message() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@NonNull
@Override
public String toString() {
return "Message{" +
"id=" + id +
", uid=" + uid +
", type=" + type +
", content='" + content + '\'' +
'}';
}
}
}

View File

@ -9,8 +9,10 @@ import com.yunbao.common.bean.CustomSidebarInfoModel;
import com.yunbao.common.bean.EnterRoomNewModel;
import com.yunbao.common.bean.FaceBookUpModel;
import com.yunbao.common.bean.HourRank;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.LinkMicUserBeanV2;
import com.yunbao.common.bean.LiveAiRobotBean;
import com.yunbao.common.bean.LiveInfoModel;
import com.yunbao.common.bean.LiveRoomActivityBanner;
import com.yunbao.common.bean.MsgSwitchDetailModel;
@ -354,42 +356,51 @@ public interface PDLiveApi {
/**
* 设置随机PK开关
*
* @param pk 1=0=
*/
@GET("/api/public/?service=Livepk.setRandomPKType")
Observable<ResponseModel<List<BaseModel>>> changeRandomPkSwitch(@Query("random_pk") int pk);
/**
* 获取自由PK次数
*/
@GET("/api/public/?service=Livepk.getActivePkNum")
Observable<ResponseModel<Integer>> getFreePkNumber();
/**
* 发起随机PK
*/
@GET("/api/public/?service=Livepk.setRandomPK")
Observable<ResponseModel<String>> randomPK();
/**
* 随机PK后调用接口给后台记录
*/
@GET("/api/public/?service=Livepk.startRandomPK")
Observable<ResponseModel<BaseModel>> startRandomPK(@Query("pkuid") String pkuid);
/**
* 自由PK开始后调用接口扣掉次数
*/
@GET("/api/public/?service=Livepk.setActivePkNum")
Observable<ResponseModel<BaseModel>> setFreePkNum();
/**
* 随机PK搜索用户
*
* @param cs 简体关键字/uid
* @param ct 繁体关键字/uid
*/
@GET("/api/public/?service=Livepk.searchUser")
Observable<ResponseModel<List<RandomPkUserBean>>> randomPkSearchUser(@Query("jian_key") String cs, @Query("fan_key") String ct);
/**
* 拒绝随机PK
*/
@GET("/api/public/?service=Livepk.setBanRandomPK")
Observable<ResponseModel<BaseModel>> setBanRandomPK();
/**
* 拒绝随机PK
*/
@ -403,6 +414,7 @@ public interface PDLiveApi {
Observable<ResponseModel<PrankHttpTurntableBean>> getAnchorPrankTurntable(
@Query("anchor_id") String anchor_id
);
/**
* 提交整蛊
*/
@ -418,6 +430,7 @@ public interface PDLiveApi {
@Query("turntable_six") String turntable_six,
@Query("status") String status
);
/**
* 转盘整蛊结束后调用的接口
*/
@ -443,6 +456,7 @@ public interface PDLiveApi {
@Query("gift_num") String gift_num,
@Query("prank_content") String prank_content
);
/**
* 删除礼物整蛊
*/
@ -451,58 +465,67 @@ public interface PDLiveApi {
@Query("anchor_id") String anchor_id,
@Query("prank_index") String prank_index
);
/**
* 设置机器人开关
*/
@GET("/api/public/?service=Live.setAnchorAiState")
Observable<ResponseModel<List<BaseModel>>> setAnchorAiState(
Observable<ResponseModel<HttpCallbackModel>> setAnchorAiState(
@Query("ai_state") String ai_state
);
/**
* 获取机器人信息
*/
@GET("/api/public/?service=Live.getAnchorAiState")
Observable<ResponseModel<List<BaseModel>>> getAnchorAiState(
Observable<ResponseModel<LiveAiRobotBean>> getAnchorAiState(
);
/**
* 修改机器人信息
*/
@GET("/api/public/?service=Live.setAnchorAiState")
Observable<ResponseModel<List<BaseModel>>> getAnchorAiState(
Observable<ResponseModel<HttpCallbackModel>> setAnchorAiState(
@Query("name") String name,
@Query("value") String value
);
/**
* 获取机器人自定义话术
*
* @param type 1(自定义打招呼) 3(自定义求关注)
*/
@GET("/api/public/?service=Live.getAiAutomaticSpeech")
Observable<ResponseModel<List<BaseModel>>> getAiAutomaticSpeech(
Observable<ResponseModel<List<LiveAiRobotBean.Message>>> getAiAutomaticSpeech(
@Query("type") String type
);
/**
* 机器人添加话术
*/
@GET("/api/public/?service=Live.addAiAutomaticSpeech")
Observable<ResponseModel<List<BaseModel>>> addAiAutomaticSpeech(
Observable<ResponseModel<HttpCallbackModel>> addAiAutomaticSpeech(
@Query("type") String type,
@Query("content") String content
);
/**
* 机器人删除话术
*/
@GET("/api/public/?service=Live.delAiAutomaticSpeech ")
Observable<ResponseModel<List<BaseModel>>> delAiAutomaticSpeech (
@Query("type") String type,
@Query("id") String id
);
/**
* 机器人修改话术
*/
@GET("/api/public/?service=Live.updateAiAutomaticSpeech ")
Observable<ResponseModel<List<BaseModel>>> updateAiAutomaticSpeech (
Observable<ResponseModel<HttpCallbackModel>> delAiAutomaticSpeech(
@Query("type") String type,
@Query("id") String id
);
/**
* 机器人修改话术
*/
@GET("/api/public/?service=Live.updateAiAutomaticSpeech ")
Observable<ResponseModel<HttpCallbackModel>> updateAiAutomaticSpeech(
@Query("type") String type,
@Query("id") String id,
@Query("content") String content
);
}

View File

@ -14,6 +14,7 @@ import com.yunbao.common.bean.EnterRoomNewModel;
import com.yunbao.common.bean.HttpCallbackModel;
import com.yunbao.common.bean.LinkMicUserBean;
import com.yunbao.common.bean.LinkMicUserBeanV2;
import com.yunbao.common.bean.LiveAiRobotBean;
import com.yunbao.common.bean.LiveInfoModel;
import com.yunbao.common.bean.LiveRoomActivityBanner;
import com.yunbao.common.bean.NobleRankHideUserListModel;
@ -21,7 +22,6 @@ import com.yunbao.common.bean.NobleTrumpetModel;
import com.yunbao.common.bean.PkRankBean;
import com.yunbao.common.bean.PrankGiftBean;
import com.yunbao.common.bean.PrankHttpTurntableBean;
import com.yunbao.common.bean.PrankTurntableBean;
import com.yunbao.common.bean.RandomPkUserBean;
import com.yunbao.common.bean.RankPkInfoBean;
import com.yunbao.common.bean.SetAttentsModel;
@ -39,7 +39,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import retrofit2.http.Query;
/**
@ -898,6 +897,132 @@ public class LiveNetManager {
}
public void getAiRobotStatus(HttpCallback<LiveAiRobotBean> callback) {
API.get().pdLiveApi(mContext)
.getAnchorAiState()
.subscribeOn(Schedulers.io())
.subscribe(responseModel -> {
if (callback != null) {
callback.onSuccess(responseModel.getData().getInfo());
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}
}).isDisposed();
}
public void setAiRobotStatus(String status, HttpCallback<HttpCallbackModel> callback) {
API.get().pdLiveApi(mContext)
.setAnchorAiState(status)
.subscribeOn(Schedulers.io())
.subscribe(responseModel -> {
if (callback != null) {
callback.onSuccess(null);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}
}).isDisposed();
}
public void setAiRobotDate(String name, String value, HttpCallback<HttpCallbackModel> callback) {
API.get().pdLiveApi(mContext)
.setAnchorAiState(name, value)
.subscribeOn(Schedulers.io())
.subscribe(responseModel -> {
if (callback != null) {
callback.onSuccess(null);
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}
}).isDisposed();
}
public void getAiRobotBody(int type, HttpCallback<List<LiveAiRobotBean.Message>> callback) {
API.get().pdLiveApi(mContext)
.getAiAutomaticSpeech(type + "")
.subscribeOn(Schedulers.io())
.subscribe(responseModel -> {
if (callback != null) {
callback.onSuccess(responseModel.getData().getInfo());
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}
}).isDisposed();
}
public void addAiRobotBody(int type, String content, HttpCallback<HttpCallbackModel> callback) {
API.get().pdLiveApi(mContext)
.addAiAutomaticSpeech(type + "", content)
.subscribeOn(Schedulers.io())
.subscribe(responseModel -> {
if (callback != null) {
callback.onSuccess(new HttpCallbackModel(responseModel.getData().getCode(), responseModel.getData().getMsg()));
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}
}).isDisposed();
}
public void updateAiRobotBody(int type, int id, String content, HttpCallback<HttpCallbackModel> callback) {
API.get().pdLiveApi(mContext)
.updateAiAutomaticSpeech(type + "", id + "", content)
.subscribeOn(Schedulers.io())
.subscribe(responseModel -> {
if (callback != null) {
callback.onSuccess(new HttpCallbackModel(responseModel.getData().getCode(), responseModel.getData().getMsg()));
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}
}).isDisposed();
}
public void delAiRobotBody(int type, int id, HttpCallback<HttpCallbackModel> callback) {
API.get().pdLiveApi(mContext)
.delAiAutomaticSpeech(type + "", id + "")
.subscribeOn(Schedulers.io())
.subscribe(responseModel -> {
if (callback != null) {
callback.onSuccess(new HttpCallbackModel(responseModel.getData().getCode(), responseModel.getData().getMsg()));
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(throwable.getMessage());
}
}
}).isDisposed();
}
/**
* 直播间取消网络请求
*/

View File

@ -2,23 +2,29 @@ package com.yunbao.live.dialog;
import android.app.ActionBar;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import com.yunbao.common.bean.LiveAiRobotBean;
import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.live.R;
import androidx.annotation.Nullable;
import java.util.List;
/**
* 机器人设置
*/
public class LiveRobotSettingDialogFragment extends AbsDialogFragment implements View.OnClickListener {
private static String TAG = "AI机器人";
@Override
protected int getLayoutId() {
@ -43,15 +49,64 @@ public class LiveRobotSettingDialogFragment extends AbsDialogFragment implements
params.gravity = Gravity.BOTTOM;
window.setAttributes(params);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Bundle bundle = getArguments();
if (bundle == null) {
return;
initDate();
}
private void initDate() {
LiveNetManager.get(mContext)
.getAiRobotStatus(new HttpCallback<LiveAiRobotBean>() {
@Override
public void onSuccess(LiveAiRobotBean data) {
Log.i(TAG, "onSuccess: " + data.toString());
initListType1();
}
@Override
public void onError(String error) {
}
});
}
private void initListType1() {
LiveNetManager.get(mContext)
.getAiRobotBody(LiveAiRobotBean.Message.TYPE_SAY_HI, new HttpCallback<List<LiveAiRobotBean.Message>>() {
@Override
public void onSuccess(List<LiveAiRobotBean.Message> data) {
Log.i(TAG, "onSuccess: " + data.size());
for (LiveAiRobotBean.Message message : data) {
Log.i(TAG, "onSuccess: message=" + message.toString());
}
initListType2();
}
@Override
public void onError(String error) {
}
});
}
private void initListType2() {
LiveNetManager.get(mContext)
.getAiRobotBody(LiveAiRobotBean.Message.TYPE_FOLLOW, new HttpCallback<List<LiveAiRobotBean.Message>>() {
@Override
public void onSuccess(List<LiveAiRobotBean.Message> 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

View File

@ -1,11 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="#000">
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="14dp"
android:text="自動發言機器人設置"
android:textColor="#CCCCCC"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/robot_status"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/border_translucent">
android:layout_marginTop="18dp"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView6">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:text="機器人開關"
android:textColor="#FFF" />
<ImageView
android:layout_width="46dp"
android:layout_height="23dp"
android:layout_marginEnd="10dp"
app:srcCompat="@mipmap/special_icon_off" />
</LinearLayout>
<LinearLayout
android:id="@+id/robot_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="18dp"
android:orientation="horizontal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/robot_status">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_weight="1"
android:text="機器人開關"
android:textColor="#FFF" />
<TextView
android:id="@+id/textView7"
android:layout_width="96dp"
android:layout_height="27dp"
android:layout_marginEnd="10dp"
android:background="@drawable/bg_prank_coin"
android:textColor="#FFF"
android:gravity="center"
android:text="TextView" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -7,7 +7,9 @@ import android.widget.ImageView;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.dialog.LiveRobotSettingDialogFragment;
import com.yunbao.main.R;
import com.yunbao.main.activity.MainActivity;
/**
* Created by cxf on 2018/9/22.
@ -36,6 +38,11 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
img_trophy = (ImageView) findViewById(R.id.img_trophy);
ImgLoader.display(mContext, "https://downs.yaoulive.com/gif_trophy.gif", img_trophy);
img_trophy.setOnClickListener(v -> {
LiveRobotSettingDialogFragment fragment=new LiveRobotSettingDialogFragment();
fragment.show(((MainActivity)mContext).getSupportFragmentManager(),"LiveRobotSettingDialogFragment");
});
}
@Override