Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -17,6 +17,7 @@ import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
@@ -31,17 +32,22 @@ import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.blankj.utilcode.util.GsonUtils;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.core.BasePopupView;
|
||||
import com.lxj.xpopup.interfaces.XPopupCallback;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.tencent.trtc.TRTCCloudDef;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.AiAutomaticSpeechModel;
|
||||
import com.yunbao.common.bean.IMLoginModel;
|
||||
import com.yunbao.common.bean.LinkMicUserBean;
|
||||
import com.yunbao.common.bean.LiveAiRobotBean;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.bean.LiveUserGiftBean;
|
||||
import com.yunbao.common.bean.MicUserBean;
|
||||
@@ -52,6 +58,7 @@ import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.IMRTCManager;
|
||||
import com.yunbao.common.manager.RandomPkManager;
|
||||
@@ -99,11 +106,13 @@ import com.yunbao.live.views.LivePushRyViewHolder;
|
||||
import com.yunbao.live.views.LiveRoomViewHolder;
|
||||
import com.yunbao.live.views.LiveRyAnchorViewHolder;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
|
||||
@@ -284,6 +293,52 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
switch (functionID) {
|
||||
case Constants.LIVE_ROBOT:
|
||||
new XPopup.Builder(mContext)
|
||||
.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) {
|
||||
EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.UPDATA_ROBOT));
|
||||
}
|
||||
|
||||
@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 LiveRobotSettingCustomPopup(mContext))
|
||||
.show();
|
||||
break;
|
||||
@@ -674,6 +729,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
* @param data createRoom返回的数据
|
||||
*/
|
||||
public void startLiveSuccess(String data, int liveType, int liveTypeVal) {
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((" + data);
|
||||
mLiveType = liveType;
|
||||
mLiveTypeVal = liveTypeVal;
|
||||
//处理createRoom返回的数据
|
||||
@@ -774,6 +830,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
if (CommonAppConfig.GAME_ENABLE) {
|
||||
mGameList = JSON.parseArray(obj.getString("game_switch"), Integer.class);
|
||||
}
|
||||
getAiRobotStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -861,6 +918,10 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
LiveHttpUtil.stopLive(mStream, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (robotRunnable != null) {
|
||||
robotHandler.removeCallbacks(robotRunnable);
|
||||
robotRunnable = null;
|
||||
}
|
||||
if (code == 0) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
JSONObject datas = obj.getJSONObject("data");
|
||||
@@ -1506,6 +1567,9 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
mLiveRoomViewHolder.aiAutomaticSpeech((event.getAiAutomaticSpeechModel()));
|
||||
}
|
||||
break;
|
||||
case UPDATA_ROBOT:
|
||||
getAiRobotStatus();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1532,4 +1596,118 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取机器人配置;取得求关注时间间隔
|
||||
*/
|
||||
private long robotTime = 0;
|
||||
|
||||
private void getAiRobotStatus() {
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((");
|
||||
LiveNetManager.get(mContext)
|
||||
.getAiRobotStatus(new com.yunbao.common.http.base.HttpCallback<LiveAiRobotBean>() {
|
||||
@Override
|
||||
public void onSuccess(LiveAiRobotBean data) {
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((" + data.toString());
|
||||
if (data.getStatus() == 1) {
|
||||
if (robotRunnable != null) {
|
||||
robotHandler.removeCallbacks(robotRunnable);
|
||||
robotRunnable = null;
|
||||
}
|
||||
robotRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((data.getName())" + data.getName());
|
||||
String robotName = data.getName();
|
||||
//发送消息
|
||||
LiveNetManager.get(mContext)
|
||||
.getAiRobotBody(LiveAiRobotBean.Message.TYPE_FOLLOW,
|
||||
new com.yunbao.common.http.base.HttpCallback<List<LiveAiRobotBean.Message>>() {
|
||||
@Override
|
||||
public void onSuccess(List<LiveAiRobotBean.Message> messageList) {
|
||||
Random random = new Random();
|
||||
int randNumber = random.nextInt(messageList.size()) - 1;
|
||||
if (randNumber < 0) {
|
||||
randNumber = 0;
|
||||
}
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((data.randNumber())" + randNumber);
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((data)" + messageList.toString());
|
||||
sendRobotMessage(robotName, messageList.get(randNumber).getContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((data.error())" + error);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
robotTime = data.getTime() * 60 * 1000;
|
||||
Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((robotTime)" + robotTime);
|
||||
robotHandler.postDelayed(robotRunnable, robotTime);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//机器人求关注轮询器
|
||||
private Handler robotHandler = new Handler();
|
||||
private Runnable robotRunnable = null;
|
||||
|
||||
/**
|
||||
* '{"msg":
|
||||
* [{"_method_":"aiAutomaticSpeech",
|
||||
* "ct":{"name_color":"#f19ec2","ai_name":"'+_this.robotInfo.ai_name+'",
|
||||
* "content":"'+content+'","user_name":"",
|
||||
* "icon":"https://downs.yaoulive.com/xzs_tab.png",
|
||||
* "system_bubble":"https://downs.yaoulive.com/xzs_qipao.9.png"},
|
||||
* "msgtype":"10"}],"retcode":"000000","retmsg":"OK"}'
|
||||
*/
|
||||
private void sendRobotMessage(String name, String content) {
|
||||
Log.e("随机打招呼", name + "==========00000000000000++++" + content);
|
||||
AiAutomaticSpeechModel aiAutomaticSpeechModel = new AiAutomaticSpeechModel();
|
||||
aiAutomaticSpeechModel.setAiName(name)
|
||||
.setIcon("https://downs.yaoulive.com/xzs_tab.png")
|
||||
.setNameColor("#f19ec2")
|
||||
.setSystemBubble("https://downs.yaoulive.com/xzs_qipao.9.png")
|
||||
.setUserName("")
|
||||
.setContent(content);
|
||||
SocketSendBean msg =
|
||||
new SocketSendBean()
|
||||
.param("_method_", "aiAutomaticSpeechNew")
|
||||
.param("msgtype", "10")
|
||||
.param("ct", GsonUtils.toJson(aiAutomaticSpeechModel, AiAutomaticSpeechModel.class));
|
||||
msg.create();
|
||||
String targetId = "g" + mLiveUid;
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
|
||||
TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
|
||||
Message message = Message.obtain(targetId, conversationType, messageContent);
|
||||
|
||||
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
|
||||
@Override
|
||||
public void onAttached(Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Message message) {
|
||||
if (SocketRyClient.mSocketHandler != null) {
|
||||
SocketRyClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
|
||||
Log.e("tx", "aaa" + errorCode.toString());
|
||||
ToastUtil.show(errorCode.code + ":" + errorCode.msg);
|
||||
}
|
||||
});
|
||||
robotHandler.postDelayed(robotRunnable, robotTime);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +255,8 @@ public class LiveAudienceEvent extends BaseModel {
|
||||
DISCONNEXT_PK_TIME(50, "单人Pk结束"),
|
||||
UP_PK_TWO(51, "PK头像信息"),
|
||||
CUSTOM_FULL_SERVICE_NOTIFY(51, "全服通知"),
|
||||
CHANGE_VIEW(52, "更改连胜位置");
|
||||
CHANGE_VIEW(52, "更改连胜位置"),
|
||||
UPDATA_ROBOT(53, "更新机器人消息");
|
||||
|
||||
private int type;
|
||||
private String name;
|
||||
|
||||
@@ -529,6 +529,7 @@ public class SocketRyClient {
|
||||
}
|
||||
break;
|
||||
case Constants.AI_AUTOMATIC_SPEECH:
|
||||
case Constants.AI_AUTOMATIC_SPEECH_LIVE:
|
||||
//{"name_color":"#f19ec2","ai_name":"助手小小P","content":"@1 ","user_name":"1","icon":"https://downs.yaoulive.com/xzs_tab.png","system_bubble":"https://downs.yaoulive.com/xzs_qipao.9.png"}
|
||||
AiAutomaticSpeechModel aiAutomaticSpeechModel = GsonUtils.fromJson(map.getString("ct"), AiAutomaticSpeechModel.class);
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
|
||||
@@ -11,12 +11,15 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.core.BasePopupView;
|
||||
import com.lxj.xpopup.interfaces.XPopupCallback;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.LiveClassBean;
|
||||
@@ -25,6 +28,7 @@ import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.ProcessImageUtil;
|
||||
@@ -32,7 +36,9 @@ 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.LiveClarityCustomPopup;
|
||||
import com.yunbao.common.views.LiveRobotSettingCustomPopup;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.faceunity.FaceManager;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveActivity;
|
||||
@@ -59,7 +65,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
private ProcessImageUtil mImageUtil;
|
||||
private File mAvatarFile;
|
||||
private TextView mLiveClass;
|
||||
private TextView mLiveTypeTextView;//房间类型TextView
|
||||
private TextView mLiveTypeTextView, liveClarity;//房间类型TextView
|
||||
private TextView mLiveWishListTextView;//心愿单TextView
|
||||
private int mLiveClassID;//直播频道id
|
||||
private int mLiveType;//房间类型
|
||||
@@ -70,6 +76,8 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
private LiveClassBean classBean;
|
||||
private FaceManager manager;
|
||||
private TextView faceTextView;//提示人脸未检测到的TextView
|
||||
private ImageView imgClarity;
|
||||
private int selectClarity = 1;
|
||||
|
||||
public LiveNewReadyRyViewHolder(Context context, ViewGroup parentView, int liveSdk) {
|
||||
super(context, parentView, liveSdk);
|
||||
@@ -90,6 +98,8 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
@Override
|
||||
public void init() {
|
||||
mRootView = (ConstraintLayout) findViewById(R.id.traceroute_rootview);
|
||||
imgClarity = (ImageView) findViewById(R.id.img_clarity);
|
||||
liveClarity = (TextView) findViewById(R.id.live_clarity);
|
||||
mRootView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -163,6 +173,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
findViewById(R.id.btn_start_live).setOnClickListener(this);
|
||||
findViewById(R.id.btn_wishlist).setOnClickListener(this);
|
||||
findViewById(R.id.btn_horizontally).setOnClickListener(this);
|
||||
|
||||
if (manager != null) {
|
||||
manager.setFaceStatusChanged(new FaceManager.FaceStatusChanged() {
|
||||
final Handler handler = new Handler(Looper.getMainLooper());
|
||||
@@ -180,6 +191,83 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
|
||||
});
|
||||
//新美颜
|
||||
setFaceUnity(true);
|
||||
|
||||
}
|
||||
//设置清晰度
|
||||
selectClarity = IMLoginManager.get(mContext).getSelectClarity();
|
||||
setSelectClarity(selectClarity);
|
||||
ViewClicksAntiShake
|
||||
.clicksAntiShake(
|
||||
findViewById(R.id.btn_live_clarity), () -> {
|
||||
LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, selectClarity);
|
||||
new XPopup.Builder(mContext)
|
||||
.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) {
|
||||
setSelectClarity(liveClarityCustomPopup.getSelectClarity());
|
||||
}
|
||||
|
||||
@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(liveClarityCustomPopup)
|
||||
.show();
|
||||
});
|
||||
}
|
||||
|
||||
private void setSelectClarity(int selectClarity) {
|
||||
this.selectClarity = selectClarity;
|
||||
IMLoginManager.get(mContext).setSelectClarity(selectClarity);
|
||||
switch (selectClarity) {
|
||||
case 0:
|
||||
imgClarity.setImageResource(R.mipmap.icon_sd);
|
||||
liveClarity.setText(R.string.standard_clear);
|
||||
break;
|
||||
case 1:
|
||||
imgClarity.setImageResource(R.mipmap.icon_hd);
|
||||
liveClarity.setText(R.string.high_definition);
|
||||
break;
|
||||
case 2:
|
||||
imgClarity.setImageResource(R.mipmap.icon_fhd);
|
||||
liveClarity.setText(R.string.ultra_hd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,43 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btn_live_clarity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_clarity"
|
||||
android:layout_width="18dp"
|
||||
android:layout_height="18dp"
|
||||
android:layout_weight="1"
|
||||
app:srcCompat="@mipmap/icon_fhd" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/live_clarity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/high_definition"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="5dp"
|
||||
android:layout_height="10dp"
|
||||
android:layout_weight="1"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@mipmap/icon_live_more" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/btn_room_type"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -62,7 +99,7 @@
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/btn_live_clarity"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
@@ -94,11 +131,11 @@
|
||||
android:id="@+id/btn_live_class"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="25dp"
|
||||
android:layout_marginStart="75dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintStart_toEndOf="@+id/btn_room_type"
|
||||
app:layout_constraintEnd_toStartOf="@+id/btn_wishlist"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
|
||||
Reference in New Issue
Block a user