update 随机PK拒绝对话框
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.yunbao.live.presenter;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
@@ -10,6 +11,7 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
@@ -18,6 +20,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -26,9 +29,11 @@ import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.http.HttpClient;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMRTCManager;
|
||||
import com.yunbao.common.manager.RandomPkManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DialogUitl;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.ScreenDimenUtil;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
@@ -47,9 +52,14 @@ import com.yunbao.live.socket.SocketSendBean;
|
||||
import com.yunbao.live.views.LiveLinkMicPkViewHolder;
|
||||
import com.yunbao.live.views.LivePushRyViewHolder;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
import cn.rongcloud.rtc.api.RCRTCMixConfig;
|
||||
@@ -76,7 +86,6 @@ import static com.lzy.okgo.utils.HttpUtils.runOnUiThread;
|
||||
import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
|
||||
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
|
||||
import static com.yunbao.live.activity.LiveRyAnchorActivity.isDRPK;
|
||||
import static com.yunbao.live.views.AbsRyLivePushViewHolder.leave;
|
||||
import static com.yunbao.live.views.AbsRyLivePushViewHolder.mPreView;
|
||||
import static com.yunbao.live.views.AbsRyLivePushViewHolder.mPreView1;
|
||||
import static com.yunbao.live.views.LivePushRyViewHolder.contexts;
|
||||
@@ -579,7 +588,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
mApplyNmae = u.getUserNiceName();
|
||||
if (by != 1) {
|
||||
if (mIsApplyDialogShow == false) {
|
||||
showApplyDialog(u);
|
||||
// showApplyDialog(u);
|
||||
showPkDialog(u);
|
||||
}
|
||||
} else {
|
||||
isPK();
|
||||
@@ -993,46 +1003,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
});
|
||||
|
||||
} else {
|
||||
rtcRoom.getLocalUser().responseJoinOtherRoom(u.getId(), u.getId(), false, false, "extra", new IRCRTCResultCallback() {
|
||||
|
||||
@Override
|
||||
public void onFailed(RTCErrorCode errorCode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
final SocketSendBean msg1 = new SocketSendBean()
|
||||
.param("_method_", SOCKET_LINK_MIC_PK)
|
||||
.param("action", 3);
|
||||
msg1.create();
|
||||
|
||||
String targetId = u.getId();
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
|
||||
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
|
||||
|
||||
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
|
||||
@Override
|
||||
public void onAttached(io.rong.imlib.model.Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(io.rong.imlib.model.Message message) {
|
||||
Log.e("ry", "发送成功");
|
||||
if (SocketRyClient.mSocketHandler != null) {
|
||||
SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
|
||||
Log.e("ry", "发送失敗" + u.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
mApplyUid = null;
|
||||
mApplyStream = null;
|
||||
@@ -1160,6 +1131,132 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机PK拒绝对话框
|
||||
*/
|
||||
public void showPkDialog(UserBean u) {
|
||||
new DialogUitl.Builder(mContext)
|
||||
.setHtmlCode(Html.fromHtml(
|
||||
"<font color='#999999' size='12'>有人向您发起PK请求。</font><br/>" +
|
||||
"<font color='#FB4F4F' size='12'>若拒绝PK,将会120分钟内不会再收到任何随机PK请求。</font>"
|
||||
))
|
||||
.setConfrimString("接受")
|
||||
.setCancelString("拒絕")
|
||||
.setView(R.layout.dialog_live_random_pk)
|
||||
.setSimpleCallbackView(new DialogUitl.SimpleCallbackView() {
|
||||
boolean clickCancel = false;
|
||||
String titleVal;
|
||||
TimerTask task;
|
||||
|
||||
@Override
|
||||
public void onShow(Dialog dialog, View title, View context, View confirmBtn, View cancelBtn) {
|
||||
task = new TimerTask() {
|
||||
int time = 11;
|
||||
final Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (titleVal == null) {
|
||||
titleVal = ((TextView) title).getText().toString();
|
||||
}
|
||||
handler.post(() -> ((TextView) title).setText(titleVal + " " + time));
|
||||
if (time-- == 0) {
|
||||
handler.post(() -> showClose(dialog, title, context, confirmBtn, cancelBtn));
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
new Timer().schedule(task, 1000, 1000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, View title, View context, View confirmBtn, View cancelBtn) {
|
||||
dialog.dismiss();
|
||||
apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(Dialog dialog, View title, View context, View confirmBtn, View cancelBtn) {
|
||||
if (!clickCancel) {
|
||||
titleVal = "拒絕PK提示";
|
||||
((TextView) context).setText(Html.fromHtml(
|
||||
"<font color='#999999' size='12'>若拒絕PK,將會關閉你的隨機PK開關。</br>" +
|
||||
"並且120分鍾不會收到任何隨機PK請求。</font>"
|
||||
));
|
||||
((TextView) cancelBtn).setText("堅持拒絕");
|
||||
clickCancel = true;
|
||||
return;
|
||||
}
|
||||
showClose(dialog, title, context, confirmBtn, cancelBtn);
|
||||
}
|
||||
|
||||
void showClose(Dialog dialog, View title, View context, View confirmBtn, View cancelBtn) {
|
||||
task.cancel();
|
||||
((TextView) title).setText("您因拒絕隨機PK,被限制關閉中");
|
||||
((TextView) confirmBtn).setText("确定");
|
||||
((TextView) context).setText("隨機PK可打開時間:" + new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()).format(new Date(System.currentTimeMillis() + 7200000)));//7200000ms=120m=2h
|
||||
((TextView) context).setTextSize(12);
|
||||
((TextView) context).setTextColor(Color.parseColor("#999999"));
|
||||
|
||||
cancelBtn.setVisibility(View.GONE);
|
||||
confirmBtn.setOnClickListener(v -> {
|
||||
refuse();
|
||||
dialog.dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
void refuse() {
|
||||
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() {
|
||||
|
||||
@Override
|
||||
public void onFailed(RTCErrorCode errorCode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
final SocketSendBean msg1 = new SocketSendBean()
|
||||
.param("_method_", SOCKET_LINK_MIC_PK)
|
||||
.param("action", 3);
|
||||
msg1.create();
|
||||
|
||||
String targetId = u.getId();
|
||||
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
|
||||
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
|
||||
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
|
||||
|
||||
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
|
||||
@Override
|
||||
public void onAttached(io.rong.imlib.model.Message message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(io.rong.imlib.model.Message message) {
|
||||
Log.e("ry", "发送成功");
|
||||
if (SocketRyClient.mSocketHandler != null) {
|
||||
SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
|
||||
Log.e("ry", "发送失敗" + u.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
LiveNetManager.get(mContext).setBanRandomPK(null);
|
||||
}
|
||||
|
||||
void apply() {
|
||||
isPK();
|
||||
}
|
||||
})
|
||||
.build().show();
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示申请多人PK的弹窗
|
||||
*/
|
||||
@@ -1276,7 +1373,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
* 2:无论为true或false,双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局。一旦主动设置过合流布局,后续音视频直播过程中设置的自动合流参数将失效。
|
||||
* <P/>
|
||||
*/
|
||||
IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() {
|
||||
IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
}
|
||||
@@ -1352,7 +1449,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
});
|
||||
|
||||
} else {
|
||||
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(),false, "extra", new IRCRTCResultCallback() {
|
||||
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() {
|
||||
|
||||
@Override
|
||||
public void onFailed(RTCErrorCode errorCode) {
|
||||
@@ -1878,7 +1975,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
}
|
||||
if (mLiveLinkMicPkViewHolder != null) {
|
||||
if (!TextUtils.isEmpty(winUid)) {
|
||||
if ("0".equals(winUid)) {
|
||||
if ("0" .equals(winUid)) {
|
||||
mLiveLinkMicPkViewHolder.end(0);
|
||||
mLiveLinkMicPkViewHolder.hideTime();
|
||||
if (mHandler != null) {
|
||||
@@ -1997,7 +2094,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
|
||||
if (mIsAnchor) {
|
||||
((LiveRyAnchorActivity) mContext).setPkBtnVisible(true);
|
||||
}
|
||||
// ToastUtil.show(R.string.link_mic_refuse_pk);
|
||||
// ToastUtil.show(R.string.link_mic_refuse_pk);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -224,9 +224,21 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
|
||||
mLiveRyLinkMicPkPresenter.onLinkMicPkApply(userBean1, "", 1);
|
||||
} else {
|
||||
Log.e("ry", extra);
|
||||
/*
|
||||
* {
|
||||
* "pkhead": "https://downs.yaoulive.com/20220906170849_79c553dc1319fb5c215e06e01674eba4?imageView2/2/w/600/h/600",
|
||||
* "pkname": "用户_98274",
|
||||
* "pkuid": "98274",
|
||||
* "randomPk": true,
|
||||
* "uid": "98274"
|
||||
* }
|
||||
*/
|
||||
UserBean userBean1 = new UserBean();
|
||||
if (!extra.equals("")) {
|
||||
JSONObject map = JSONObject.parseObject(extra);
|
||||
userBean1.setAvatar(map.getString("pkhead"));
|
||||
userBean1.setUserNiceName(map.getString("pkname"));
|
||||
userBean1.setRandomPk(map.containsKey("randomPk") ? map.getBoolean("randomPk") : false);
|
||||
userBean1.setId(map.getString("uid"));
|
||||
userBean1.setUserNiceName(map.getString("pkname"));
|
||||
userBean1.setAvatar(map.getString("pkhead"));
|
||||
|
||||
Reference in New Issue
Block a user