新增打招呼弹窗震动&声音

同步PD修复问题:
修复:
1:开播闪屏问题
2:游戏房消息重复(或不显示)
3:模拟器或部分机型滑动声网直播间会白屏问题
4:PK条在平板模式下显示太高问题
5:PK没断开能收到其他人邀请的问题
This commit is contained in:
zlzw 2024-06-16 11:05:48 +08:00
parent d09b01dbad
commit 4c9f3d9936
20 changed files with 974 additions and 748 deletions

View File

@ -190,7 +190,7 @@
android:value="false" /> android:value="false" />
<meta-data <meta-data
android:name="firebase_analytics_collection_enabled" android:name="firebase_analytics_collection_enabled"
android:value="false" /> android:value="true" />
<receiver <receiver
android:name="com.shayu.phonelive.utils.CustomMessageReceiver" android:name="com.shayu.phonelive.utils.CustomMessageReceiver"

View File

@ -4,7 +4,7 @@
<!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" />--> <!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" />-->
<!-- <uses-permission android:name="android.permission.INTERNET" />--> <!-- <uses-permission android:name="android.permission.INTERNET" />-->
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />--> <!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />-->
<uses-permission android:name="android.permission.VIBRATE" />
<application <application
android:allowBackup="true" android:allowBackup="true"
tools:replace="allowBackup"> tools:replace="allowBackup">

View File

@ -3,8 +3,13 @@ package com.yunbao.common.dialog;
import android.app.Dialog; import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Handler; import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.os.Vibrator;
import android.util.Log; import android.util.Log;
import android.widget.TextView; import android.widget.TextView;
@ -30,6 +35,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import io.rong.imkit.IMCenter; import io.rong.imkit.IMCenter;
import io.rong.imkit.config.RongConfigCenter;
import io.rong.imkit.utils.RouteUtils; import io.rong.imkit.utils.RouteUtils;
import io.rong.imlib.IRongCallback; import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient; import io.rong.imlib.RongIMClient;
@ -123,6 +129,7 @@ public class MessageSayHiNotifyDialog extends AbsDialogCenterPopupWindow {
) )
); );
showTag(); showTag();
playNotificationSound();
} }
private void showTag() { private void showTag() {
@ -172,4 +179,22 @@ public class MessageSayHiNotifyDialog extends AbsDialogCenterPopupWindow {
} }
}); });
} }
public void playNotificationSound() {
try {
Uri ringUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
MediaPlayer mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(mContext, ringUri);
mMediaPlayer.setAudioStreamType(AudioManager.STREAM_NOTIFICATION);
mMediaPlayer.setLooping(false);
mMediaPlayer.prepare();
mMediaPlayer.start();
Vibrator vibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(new long[]{150, 250, 150, 250}, -1);
} catch (Exception e) {
e.printStackTrace();
}
}
} }

View File

@ -143,6 +143,9 @@ public class RandomPkManager {
.randomPK(new HttpCallback<String>() { .randomPK(new HttpCallback<String>() {
@Override @Override
public void onSuccess(String data) { public void onSuccess(String data) {
if (debugUid != null) {
pkUid = data = debugUid;
}
try { try {
Integer.parseInt(data);//检测返回的data是否为数字uid不是的话开始下一轮 Integer.parseInt(data);//检测返回的data是否为数字uid不是的话开始下一轮
} catch (Exception e) { } catch (Exception e) {
@ -152,9 +155,8 @@ public class RandomPkManager {
return; return;
} }
pkUid = data; pkUid = data;
if (debugUid != null) {
pkUid = data = debugUid; ToastUtil.showDebug("随机PK:"+pkUid+"|"+data);
}
for (OnRandomPkTimer pkTimer : randomPkTimer) { for (OnRandomPkTimer pkTimer : randomPkTimer) {
pkTimer.onStartPK(data); pkTimer.onStartPK(data);
} }

View File

@ -17,7 +17,7 @@ ext {
// //
swReleaseModel : true, //true false swReleaseModel : false, //true false
baiduAppId : "23774720", baiduAppId : "23774720",
baiduAppKey : "zgCgFhUKEOV7I3ZXDFpTfnRB", baiduAppKey : "zgCgFhUKEOV7I3ZXDFpTfnRB",
@ -31,6 +31,6 @@ ext {
// //
isUploadLog : true, isUploadLog : true,
// //
isPluginModel : true, isPluginModel : false,
] ]
} }

View File

@ -41,6 +41,7 @@ dependencies {
api "$AGORA_RTC_SDK" api "$AGORA_RTC_SDK"
} }
api project(path: ':FaceUnity') api project(path: ':FaceUnity')
api project(path: ':common')
} }
// Because the components are created only during the afterEvaluate phase, you must // Because the components are created only during the afterEvaluate phase, you must

View File

@ -3,7 +3,7 @@ package io.agora.beautyapi.faceunity.agora;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
import android.view.SurfaceView; import android.view.TextureView;
import android.widget.FrameLayout; import android.widget.FrameLayout;
@ -166,8 +166,8 @@ public class SWAuManager extends BaseCacheManager {
*/ */
public void updateMyChannelView(FrameLayout frameLayout, int uid) { public void updateMyChannelView(FrameLayout frameLayout, int uid) {
mRtcEngine.setupLocalVideo(null); mRtcEngine.setupLocalVideo(null);
SurfaceView surfaceView = new SurfaceView(mContext); TextureView surfaceView = new TextureView(mContext);
surfaceView.setZOrderMediaOverlay(true); //surfaceView.setZOrderMediaOverlay(true);
frameLayout.addView(surfaceView); frameLayout.addView(surfaceView);
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid); VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid);
@ -185,8 +185,8 @@ public class SWAuManager extends BaseCacheManager {
} else { } else {
uid = Integer.parseInt(strUid); uid = Integer.parseInt(strUid);
} }
// 创建一个 SurfaceView 对象并将其作为 FrameLayout 的子对象 // 创建一个 TextureView 对象并将其作为 FrameLayout 的子对象
SurfaceView surfaceView = new SurfaceView(mContext); TextureView surfaceView = new TextureView(mContext);
audienceContainer.addView(surfaceView); audienceContainer.addView(surfaceView);
// 启用视频模块 // 启用视频模块
@ -228,8 +228,8 @@ public class SWAuManager extends BaseCacheManager {
@Override @Override
public void run() { public void run() {
L.eSw("onJoinChannelSuccess:" + channel + " uid " + uid + " elapsed: " + elapsed); L.eSw("onJoinChannelSuccess:" + channel + " uid " + uid + " elapsed: " + elapsed);
SurfaceView surfaceView = new SurfaceView(mContext); TextureView surfaceView = new TextureView(mContext);
surfaceView.setZOrderMediaOverlay(true); // surfaceView.setZOrderMediaOverlay(true);
pkContainer1.addView(surfaceView); pkContainer1.addView(surfaceView);
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, strUid); VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, strUid);
mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection); mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection);
@ -308,8 +308,8 @@ public class SWAuManager extends BaseCacheManager {
mContext.runOnUiThread(new Runnable() { mContext.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
SurfaceView surfaceView = new SurfaceView(mContext); TextureView surfaceView = new TextureView(mContext);
surfaceView.setZOrderMediaOverlay(true); // surfaceView.setZOrderMediaOverlay(true);
frameLayout.addView(surfaceView); frameLayout.addView(surfaceView);
VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, Integer.parseInt(toUid)); VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, Integer.parseInt(toUid));
mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection); mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection);
@ -389,10 +389,10 @@ public class SWAuManager extends BaseCacheManager {
//设置对方主播视图 //设置对方主播视图
public void setupRemoteVideo(int uid) { public void setupRemoteVideo(int uid) {
SurfaceView surfaceView = new SurfaceView(mContext); TextureView surfaceView = new TextureView(mContext);
surfaceView.setZOrderMediaOverlay(true); // surfaceView.setZOrderMediaOverlay(true);
audienceContainer.addView(surfaceView); audienceContainer.addView(surfaceView);
// SurfaceView 对象传入声网实时互动 SDK设置远端视图 // TextureView 对象传入声网实时互动 SDK设置远端视图
mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid)); mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid));
} }

View File

@ -1 +1 @@
apply plugin: 'com.android.library' apply plugin: 'img-optimizer' apply plugin: 'kotlin-android' android { namespace "com.yunbao.live" compileSdk rootProject.ext.android.compileSdkVersion aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false packagingOptions { pickFirst "lib/armeabi/libyuvutils.so" pickFirst "lib/arm64-v8a/libyuvutils.so" pickFirst "lib/armeabi-v7a/libyuvutils.so" pickFirst "lib/armeabi/libyuvtools.so" pickFirst "lib/arm64-v8a/libyuvtools.so" pickFirst "lib/armeabi-v7a/libyuvtools.so" exclude "lib/arm64-v8a/libmmcv_api_handgesture.so" exclude "lib/arm64-v8a/libmmcv_api_express.so" exclude "lib/arm64-v8a/libMediaEncoder.so" exclude "lib/arm64-v8a/libarcore_sdk_c.so" exclude "lib/arm64-v8a/libmediadecoder.so" exclude "lib/arm64-v8a/libMediaMuxer.so" exclude "lib/arm64-v8a/libarcore_sdk_jni.so" exclude "lib/arm64-v8a/libMediaUtils.so" exclude "lib/arm64-v8a/libcosmosffmpeg.so" } defaultConfig { minSdkVersion rootProject.ext.android.minSdkVersion targetSdkVersion rootProject.ext.android.targetSdkVersion versionCode rootProject.ext.android.versionCode versionName rootProject.ext.android.versionName manifestPlaceholders = rootProject.ext.manifestPlaceholders ndk { //abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64" if (rootProject.ext.manifestPlaceholders.isGooglePlay == 0) { abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" } else { abiFilters "armeabi-v7a", "arm64-v8a" } } javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } } aaptOptions { cruncherEnabled = false useNewCruncher = false } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } kotlinOptions { allWarningsAsErrors = true } compileOptions { sourceCompatibility JavaVersion.VERSION_18 targetCompatibility JavaVersion.VERSION_18 } } repositories { flatDir { dirs 'libs', '../libs' } mavenCentral() } dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0' implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation (name:'../libs/beautysdk-202202241203',ext:'aar') implementation (name:'../libs/svgaplayer-release-v1.2.1',ext:'aar') //socket.io implementation('io.socket:socket.io-client:1.0.0') { exclude group: 'org.json', module: 'json' } //common api project(path:':lib_faceunity')//新娱美颜 api project(':Share')//分享 annotationProcessor rootProject.ext.dependencies["arouter-compiler"] //工具 api rootProject.ext.dependencies["blank-utilcode"] implementation 'com.eightbitlab:blurview:1.6.6' implementation 'com.google.code.gson:gson:2.8.6' implementation "com.getkeepsafe.relinker:relinker:1.4.4" } apply plugin: 'com.android.library' apply plugin: 'img-optimizer' apply plugin: 'kotlin-android' android { namespace "com.yunbao.live" compileSdk rootProject.ext.android.compileSdkVersion aaptOptions.cruncherEnabled = false aaptOptions.useNewCruncher = false packagingOptions { pickFirst "lib/armeabi/libyuvutils.so" pickFirst "lib/arm64-v8a/libyuvutils.so" pickFirst "lib/armeabi-v7a/libyuvutils.so" pickFirst "lib/armeabi/libyuvtools.so" pickFirst "lib/arm64-v8a/libyuvtools.so" pickFirst "lib/armeabi-v7a/libyuvtools.so" exclude "lib/arm64-v8a/libmmcv_api_handgesture.so" exclude "lib/arm64-v8a/libmmcv_api_express.so" exclude "lib/arm64-v8a/libMediaEncoder.so" exclude "lib/arm64-v8a/libarcore_sdk_c.so" exclude "lib/arm64-v8a/libmediadecoder.so" exclude "lib/arm64-v8a/libMediaMuxer.so" exclude "lib/arm64-v8a/libarcore_sdk_jni.so" exclude "lib/arm64-v8a/libMediaUtils.so" exclude "lib/arm64-v8a/libcosmosffmpeg.so" } defaultConfig { minSdkVersion rootProject.ext.android.minSdkVersion targetSdkVersion rootProject.ext.android.targetSdkVersion versionCode rootProject.ext.android.versionCode versionName rootProject.ext.android.versionName manifestPlaceholders = rootProject.ext.manifestPlaceholders ndk { //abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64" if (rootProject.ext.manifestPlaceholders.isGooglePlay == 0) { abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" } else { abiFilters "armeabi-v7a", "arm64-v8a" } } javaCompileOptions { annotationProcessorOptions { arguments = [AROUTER_MODULE_NAME: project.getName()] } } } aaptOptions { cruncherEnabled = false useNewCruncher = false } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } kotlinOptions { allWarningsAsErrors = true } compileOptions { sourceCompatibility JavaVersion.VERSION_18 targetCompatibility JavaVersion.VERSION_18 } } repositories { flatDir { dirs 'libs', '../libs' } mavenCentral() } dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.0.0' implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) implementation (name:'../libs/beautysdk-202202241203',ext:'aar') implementation (name:'../libs/svgaplayer-release-v1.2.1',ext:'aar') //socket.io implementation('io.socket:socket.io-client:1.0.0') { exclude group: 'org.json', module: 'json' } //common api project(path:':lib_faceunity')//声网-新娱美颜 api project(path:':FaceUnity')//融云-新娱美颜 api project(path:':common')//公共库 api project(':Share')//分享 annotationProcessor rootProject.ext.dependencies["arouter-compiler"] //工具 api rootProject.ext.dependencies["blank-utilcode"] implementation 'com.eightbitlab:blurview:1.6.6' implementation 'com.google.code.gson:gson:2.8.6' implementation "com.getkeepsafe.relinker:relinker:1.4.4" }

View File

@ -169,6 +169,10 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
public static boolean isSw; public static boolean isSw;
public static boolean PKing = false;
public static int isDRPK = 0;
public static int DRPKing = -1; //-1 未发起多人PK 0 多人PK前 1 多人PK中 2多人PK后
@Override @Override
protected void main() { protected void main() {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

View File

@ -170,8 +170,6 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
private int mReqCount; private int mReqCount;
private boolean mPaused; private boolean mPaused;
String mBeautySdkType; String mBeautySdkType;
public static int isDRPK = 0;
public static boolean PKing = false;
public static int pk_nub; public static int pk_nub;
public static int backIndex = 0;//0=未判断1=已判断 public static int backIndex = 0;//0=未判断1=已判断
private FaceManager manager; private FaceManager manager;

View File

@ -165,9 +165,8 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
private int mReqCount; private int mReqCount;
private boolean mPaused; private boolean mPaused;
String mBeautySdkType; String mBeautySdkType;
public static int isDRPK = 0;
public static int DRPKing = -1; //-1 未发起多人PK 0 多人PK前 1 多人PK中 2多人PK后
public static boolean PKing = false;
public static int pk_nub; public static int pk_nub;
public static int backIndex = 0;//0=未判断1=已判断 public static int backIndex = 0;//0=未判断1=已判断
private FaceManager manager; private FaceManager manager;

View File

@ -1,6 +1,7 @@
package com.yunbao.live.adapter; package com.yunbao.live.adapter;
import android.content.Context; import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -10,6 +11,8 @@ import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.makeramen.roundedimageview.RoundedImageView; import com.makeramen.roundedimageview.RoundedImageView;
import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.RandomPkUserBean; import com.yunbao.common.bean.RandomPkUserBean;
@ -18,6 +21,8 @@ import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.LiveHttpUtil; import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
@ -134,6 +139,15 @@ public class FreePkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
ToastUtil.show(mContext.getString(R.string.free_pk_num_null)); ToastUtil.show(mContext.getString(R.string.free_pk_num_null));
return; return;
} }
//检查自己是不是在PK中
LiveHttpUtil.livePkCheckLive(IMLoginManager.get(AppManager.getInstance().getMainActivity()).getUserInfo().getId() + "", "", "", new com.yunbao.common.http.HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
if (obj != null) {
if (TextUtils.equals(obj.getString("ispk"), "0")) {//自己不在PK可以发起邀请
LiveHttpUtil.getMicList(liveUid, 0, new com.yunbao.common.http.HttpCallback() { LiveHttpUtil.getMicList(liveUid, 0, new com.yunbao.common.http.HttpCallback() {
@Override @Override
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(int code, String msg, String[] info) {
@ -188,6 +202,18 @@ public class FreePkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
} }
} }
}); });
}else{
if (WordUtil.isNewZh()) {
ToastUtil.show("請先關閉PK");
} else {
ToastUtil.show("Please disable the PK");
}
}
}
}
}
});
}); });
mFollow.setOnClickListener(v -> { mFollow.setOnClickListener(v -> {

View File

@ -0,0 +1,160 @@
package com.yunbao.live.presenter;
import android.text.TextUtils;
import android.util.Log;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.AppManager;
public abstract class AbsLinkMicPkPresenter {
private boolean isSw = false;
protected boolean mIsPk;//是否已经Pk了
public static String mPkUid;//正在Pk的对方主播的uid
public static String oldmPkUid;//正在Pk的对方主播的uid
public boolean mIsPkEnd;//pk是否结束进入惩罚时间
private static boolean init = false;
public AbsLinkMicPkPresenter(boolean isSw) {
this.isSw = isSw;
}
public static String mApplyUid;//正在申请Pk的主播的uid
protected String mApplyUrl;//正在申请Pk的主播的头像
protected String mApplyNmae;//正在申请Pk的主播的名字
protected boolean mIsApplyDialogShow;//是否显示了申请PK的弹窗
/**
* 主播与主播PK 主播收到其他主播发过来的多人PK申请的回调
*/
public void onLinkDRMicPkApply(UserBean u) {
Log.e("ry", "多人收到");
showDRApplyDialogTmp(u);
}
/**
* 主播与主播PK 主播收到其他主播发过来的PK申请的回调
*/
public void onLinkMicPkApply(UserBean u, String stream, int by) {
Log.e("ry", u.getUserNiceName() + "单人收到" + u.getAvatar());
mApplyUid = u.getId();
mApplyUrl = u.getAvatar();
mApplyNmae = u.getUserNiceName();
if (by != 1) {
if (mIsApplyDialogShow == false) {
if (u.isRandomPk()) {
showPkDialogTmp(u);
} else {
showApplyDialogTmp(u);
}
}
} else {
isPKTmp(u);
}
}
protected void checkPK(OnItemClickListener<Boolean> onItemClickListener) {
LiveHttpUtil.livePkCheckLive(IMLoginManager.get(AppManager.getInstance().getMainActivity()).getUserInfo().getId() + "", "", "", new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
if (obj != null) {
if (TextUtils.equals(obj.getString("ispk"), "1")) {
onItemClickListener.onItemClick(true, 0);
return;
}
}
}
onItemClickListener.onItemClick(false, 0);
}
});
}
protected void showDRApplyDialogTmp(UserBean u) {
checkPK((bean, position) -> {
if(bean){
onDRPkRefuse(u);
return;
}
showDRApplyDialog(u);
});
}
protected void showApplyDialogTmp(UserBean u) {
checkPK((bean, position) -> {
if(bean){
onPkRefuse(u);
return;
}
showApplyDialog(u);
});
}
protected void showPkDialogTmp(UserBean u) {
checkPK((bean, position) -> {
if(bean){
onPkRefuse(u);
return;
}
showPkDialog(u);
});
}
protected void isPKTmp(UserBean u) {
isPK(u);
}
protected void onDRPkApplyTmp(UserBean u) {
onDRPkApply(u);
}
protected void onDRPkTimeoutTmp(UserBean u) {
onDRPkTimeout(u);
}
protected void onDRPkRefuseTmp(UserBean u) {
onDRPkRefuse(u);
}
protected void onPkApplyTmp(UserBean u) {
onPkApply(u);
}
protected void onPkTimeoutTmp(UserBean u) {
onPkTimeout(u);
}
protected void onPkRefuseTmp(UserBean u) {
onPkRefuse(u);
}
protected abstract void showDRApplyDialog(UserBean u);//多人PK弹窗
protected abstract void showApplyDialog(UserBean u);//PK弹窗
protected abstract void showPkDialog(UserBean u);//随机PK弹框
protected abstract void isPK(UserBean bean);
protected abstract void onDRPkApply(UserBean u);
protected abstract void onDRPkTimeout(UserBean u);
protected abstract void onDRPkRefuse(UserBean u);
protected abstract void onPkApply(UserBean u);
protected abstract void onPkTimeout(UserBean u);
protected abstract void onPkRefuse(UserBean u);
}

View File

@ -111,7 +111,7 @@ import io.rong.message.TextMessage;
* 主播与主播PK逻辑 * 主播与主播PK逻辑
*/ */
public class LiveRyLinkMicPkPresenter implements View.OnClickListener { public class LiveRyLinkMicPkPresenter extends AbsLinkMicPkPresenter implements View.OnClickListener {
private static final int WHAT_PK_WAIT_RECEIVE = 0;//收到pk申请等待 what private static final int WHAT_PK_WAIT_RECEIVE = 0;//收到pk申请等待 what
private static final int WHAT_PK_WAIT_SEND = 1;//发送pk申请等待 what private static final int WHAT_PK_WAIT_SEND = 1;//发送pk申请等待 what
@ -125,17 +125,11 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
private boolean mIsAnchor;//自己是否是主播 private boolean mIsAnchor;//自己是否是主播
private SocketRyClient mSocketRyClient; private SocketRyClient mSocketRyClient;
private ViewGroup mPkContainer; private ViewGroup mPkContainer;
private boolean mIsApplyDialogShow;//是否显示了申请PK的弹窗
private boolean mAcceptPk;//是否接受连麦 private boolean mAcceptPk;//是否接受连麦
private boolean mIsPk;//是否已经Pk了
public static String mApplyUid;//正在申请Pk的主播的uid
private String mApplyUrl;//正在申请Pk的主播的头像
private String mApplyNmae;//正在申请Pk的主播的名字
private String mApplyStream;//正在申请Pk的主播的stream private String mApplyStream;//正在申请Pk的主播的stream
private String mLiveUid;//自己主播的uid private String mLiveUid;//自己主播的uid
private String mUrl;//主播的头像 private String mUrl;//主播的头像
public static String mPkUid;//正在Pk的对方主播的uid
public static String oldmPkUid;//正在Pk的对方主播的uid
private ProgressTextView mLinkMicWaitProgress; private ProgressTextView mLinkMicWaitProgress;
private int mPkWaitCount;//Pk弹窗等待倒计时Live private int mPkWaitCount;//Pk弹窗等待倒计时Live
private int mPkTimeCount;//pk时间 private int mPkTimeCount;//pk时间
@ -144,7 +138,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
private LiveLinkMicPkViewHolder mLiveLinkMicPkViewHolder; private LiveLinkMicPkViewHolder mLiveLinkMicPkViewHolder;
private String mPkTimeString1; private String mPkTimeString1;
private String mPkTimeString2; private String mPkTimeString2;
private boolean mIsPkEnd;//pk是否结束进入惩罚时间
private boolean mPkSend;//pk请求是否已经发送 private boolean mPkSend;//pk请求是否已经发送
private int mPkSendWaitCount;//发送pk请求后的等待时间 private int mPkSendWaitCount;//发送pk请求后的等待时间
private String mSelfStream; private String mSelfStream;
@ -214,6 +207,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
}; };
public LiveRyLinkMicPkPresenter(Context context, ILiveLinkMicViewHolder linkMicViewHolder, boolean isAnchor, View root) { public LiveRyLinkMicPkPresenter(Context context, ILiveLinkMicViewHolder linkMicViewHolder, boolean isAnchor, View root) {
super(false);
mContext = context; mContext = context;
mIsAnchor = isAnchor; mIsAnchor = isAnchor;
mRoot = root; mRoot = root;
@ -254,6 +248,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
public LiveRyLinkMicPkPresenter(Context context, LivePushRyViewHolder linkMicViewHolder, boolean isAnchor, View root) { public LiveRyLinkMicPkPresenter(Context context, LivePushRyViewHolder linkMicViewHolder, boolean isAnchor, View root) {
super(false);
mContext = context; mContext = context;
mIsAnchor = isAnchor; mIsAnchor = isAnchor;
mRoot = root; mRoot = root;
@ -516,14 +511,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
} }
/**
* 主播与主播PK 主播收到其他主播发过来的多人PK申请的回调
*/
public void onLinkDRMicPkApply(UserBean u) {
Log.e("ry", "多人收到");
showDRApplyDialog(u);
}
/** /**
* 主播与主播PK 主播收到其他主播发过来的多人PK申请同意了的回调 * 主播与主播PK 主播收到其他主播发过来的多人PK申请同意了的回调
*/ */
@ -660,26 +647,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
/**
* 主播与主播PK 主播收到其他主播发过来的PK申请的回调
*/
public void onLinkMicPkApply(UserBean u, String stream, int by) {
Log.e("ry", u.getUserNiceName() + "单人收到" + u.getAvatar());
mApplyUid = u.getId();
mApplyUrl = u.getAvatar();
mApplyNmae = u.getUserNiceName();
if (by != 1) {
if (mIsApplyDialogShow == false) {
if (u.isRandomPk()) {
showPkDialog(u);
} else {
showApplyDialog(u);
}
}
} else {
isPK(u);
}
}
/** /**
* 主播与主播PK PK主播发过来的已经接受 * 主播与主播PK PK主播发过来的已经接受
@ -829,7 +797,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
private void isPK(UserBean bean) { @Override
protected void isPK(UserBean bean) {
ScreenDimenUtil util = ScreenDimenUtil.getInstance(); ScreenDimenUtil util = ScreenDimenUtil.getInstance();
int mScreenWdith = util.getScreenWdith(); int mScreenWdith = util.getScreenWdith();
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
@ -964,6 +933,312 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
} }
@Override
protected void onDRPkApply(UserBean u) {
HttpClient.getInstance().get("Livepk.changeLive", "Livepk.changeLive")
.params("uid", CommonAppConfig.getInstance().getUid())
.params("pkuid", u.getId())
.params("type", "1")
.params("sign", "1")
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msgs, String[] info) {
if (code == 0) {
Log.i("多人PK", "1code = " + code + ", msgs = " + msgs + ", info = " + Arrays.deepToString(info) + " mApplyUid = " + mApplyUid);
HttpClient.getInstance().get("live.getdrnum", "live.getdrnum")
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
Log.i(TAG, "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
if (info.length > 0) {
JSONObject datas = JSONObject.parseObject(info[0]);
boolean agree = true;
if (datas.getIntValue("pk_num_day") <= 0) {
ToastUtil.show("多人PK次数已用完");
agree = false;
}
boolean finalAgree = agree;
IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, agree, SOCKET_LIVE_DRPK, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
if (finalAgree == true) {
HttpClient.getInstance().get("live.joinDRPKroom", "live.joinDRPKroom")
.params("uid", CommonAppConfig.getInstance().getUid())
.params("roomid", u.getId())
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
Log.i("多人PK", "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LIVE_DRPK)
.param("action", 10)
.param("uid", CommonAppConfig.getInstance().getUid());
msg1.create();
String targetId = "g" + CommonAppConfig.getInstance().getUid();
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
RongcloudIMManager.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", "发送失敗");
}
});
if (info.length == 0) {
return;
}
JSONObject obj = JSONObject.parseObject(info[0]);
JSONArray users = obj.getJSONArray("userlist");
//添加水印
// RCRTCRect rect = new RCRTCRect(0.5f, 0.5f, 0.2f);
// RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(fromText(50, mNameText), rect);
dRjoinOtherRoom(u.getId(), 1);
for (int i = 0; i < users.size(); i++) {
JSONObject user = users.getJSONObject(i);
Log.e("ry", mApplyUid + "VS" + user.getString("id") + "列表");
if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid())) {
if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid()) && !user.getString("id").equals(u.getId())) {
/**
* 向指定用户发送跨房间连麦请求
* <P>
* 1: inviterAutoMix为true时
*
* 1.1如果被邀请方在加入邀请方房间之前发布了资源当被邀请方加入邀请者房间成功后服务器会把被邀请方流资源合并到邀请方视图 ·默认仅悬浮布局合流
*
* 1.2如果被邀请方在加入邀请方房间之前没有发布过资源将会在被邀请方发布资源成功后服务器会把被邀请方流资源合并到邀请方视图默认仅悬浮布局合流
*
* 2:无论为true或false双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局一旦主动设置过合流布局后续音视频直播过程中设置的自动合流参数将失效
* <P/>
*/
IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() {
@Override
public void onSuccess() {
}
@Override
public void onFailed(RTCErrorCode errorCode) {
}
});
}
}
}
}
});
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
ToastUtil.show("接受失败");
}
});
} else {
ToastUtil.show(msg);
}
}
});
}
}
});
/*LiveHttpUtil.livePkCheckLive(u.getId(), "", "", new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
if (obj != null) {
if (obj.getString("ispk").equals("0")) {
}else{
ToastUtil.show(mContext.getString(R.string.pking_over));
}
}
}
}});*/
}
@Override
protected void onDRPkTimeout(UserBean u) {
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", 8);
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);
RongcloudIMManager.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", "发送失敗" + mApplyUid);
}
});
}
});
}
@Override
protected void onDRPkRefuse(UserBean u) {
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);
RongcloudIMManager.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", "发送失敗");
}
});
}
});
}
@Override
protected void onPkApply(UserBean u) {
LiveHttpUtil.livePkCheckLive(u.getId(), "", "", new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
if (obj != null) {
if (obj.getString("ispk").equals("0")) {
isPKTmp(u);
} else {
ToastUtil.show(mContext.getString(R.string.pking_over));
}
}
}
}
});
}
@Override
protected void onPkTimeout(UserBean u) {
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", 8);
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);
RongcloudIMManager.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());
}
});
}
});
}
@Override
protected void onPkRefuse(UserBean u) {
onPkTimeoutTmp(u);
}
//与用户连麦 //与用户连麦
public void setUserMic(String liveid) { public void setUserMic(String liveid) {
JSONObject msg1 = new JSONObject(); JSONObject msg1 = new JSONObject();
@ -1032,7 +1307,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
/** /**
* 显示申请PK的弹窗 * 显示申请PK的弹窗
*/ */
private void showApplyDialog(UserBean u) { @Override
protected void showApplyDialog(UserBean u) {
mIsApplyDialogShow = true; mIsApplyDialogShow = true;
mAcceptPk = false; mAcceptPk = false;
View v = LayoutInflater.from(mContext).inflate(R.layout.dialog_link_mic_pk_wait, null); View v = LayoutInflater.from(mContext).inflate(R.layout.dialog_link_mic_pk_wait, null);
@ -1050,63 +1326,10 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE); mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
} }
if (mAcceptPk) { if (mAcceptPk) {
onPkApplyTmp(u);
LiveHttpUtil.livePkCheckLive(u.getId(), "", "", new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
if (obj != null) {
if (obj.getString("ispk").equals("0")) {
isPK(u);
}else{
ToastUtil.show(mContext.getString(R.string.pking_over));
}
}
}}});
} else { } else {
if (mPkWaitCount < 0) { if (mPkWaitCount < 0) {
rtcRoom.getLocalUser().responseJoinOtherRoom(u.getId(), u.getId(), false, false, "extra", new IRCRTCResultCallback() { onPkTimeoutTmp(u);
@Override
public void onFailed(RTCErrorCode errorCode) {
}
@Override
public void onSuccess() {
final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LINK_MIC_PK)
.param("action", 8);
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);
RongcloudIMManager.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; mApplyUid = null;
@ -1260,7 +1483,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
/** /**
* 随机PK拒绝对话框 * 随机PK拒绝对话框
*/ */
public void showPkDialog(UserBean u) { @Override
protected void showPkDialog(UserBean u) {
new DialogUitl.Builder(mContext) new DialogUitl.Builder(mContext)
.setHtmlCode(Html.fromHtml( .setHtmlCode(Html.fromHtml(
"<font color='#999999' size='12'>有人向您发起PK请求。</font><br/>" + "<font color='#999999' size='12'>有人向您发起PK请求。</font><br/>" +
@ -1333,7 +1557,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
void apply() { void apply() {
isPK(u); isPKTmp(u);
} }
}) })
.build().show(); .build().show();
@ -1388,7 +1612,8 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
/** /**
* 显示申请多人PK的弹窗 * 显示申请多人PK的弹窗
*/ */
private void showDRApplyDialog(UserBean u) { @Override
protected void showDRApplyDialog(UserBean u) {
mApplyUid = u.getId(); mApplyUid = u.getId();
mIsApplyDialogShow = true; mIsApplyDialogShow = true;
mAcceptPk = false; mAcceptPk = false;
@ -1407,236 +1632,14 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE); mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
} }
if (mAcceptPk) { if (mAcceptPk) {
HttpClient.getInstance().get("Livepk.changeLive", "Livepk.changeLive") onDRPkApplyTmp(u);
.params("uid", CommonAppConfig.getInstance().getUid())
.params("pkuid", u.getId())
.params("type", "1")
.params("sign", "1")
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msgs, String[] info) {
if (code == 0) {
Log.i("多人PK", "1code = " + code + ", msgs = " + msgs + ", info = " + Arrays.deepToString(info) + " mApplyUid = " + mApplyUid);
HttpClient.getInstance().get("live.getdrnum", "live.getdrnum")
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
Log.i(TAG, "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
if (info.length > 0) {
JSONObject datas = JSONObject.parseObject(info[0]);
boolean agree = true;
if (datas.getIntValue("pk_num_day") <= 0) {
ToastUtil.show("多人PK次数已用完");
agree = false;
}
boolean finalAgree = agree;
IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, agree, SOCKET_LIVE_DRPK, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
if (finalAgree == true) {
HttpClient.getInstance().get("live.joinDRPKroom", "live.joinDRPKroom")
.params("uid", CommonAppConfig.getInstance().getUid())
.params("roomid", u.getId())
.execute(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
Log.i("多人PK", "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LIVE_DRPK)
.param("action", 10)
.param("uid", CommonAppConfig.getInstance().getUid());
msg1.create();
String targetId = "g" + CommonAppConfig.getInstance().getUid();
Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
RongcloudIMManager.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", "发送失敗");
}
});
if (info.length == 0) {
return;
}
JSONObject obj = JSONObject.parseObject(info[0]);
JSONArray users = obj.getJSONArray("userlist");
//添加水印
// RCRTCRect rect = new RCRTCRect(0.5f, 0.5f, 0.2f);
// RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(fromText(50, mNameText), rect);
dRjoinOtherRoom(u.getId(), 1);
for (int i = 0; i < users.size(); i++) {
JSONObject user = users.getJSONObject(i);
Log.e("ry", mApplyUid + "VS" + user.getString("id") + "列表");
if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid())) {
if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid()) && !user.getString("id").equals(u.getId())) {
/**
* 向指定用户发送跨房间连麦请求
* <P>
* 1: inviterAutoMix为true时
*
* 1.1如果被邀请方在加入邀请方房间之前发布了资源当被邀请方加入邀请者房间成功后服务器会把被邀请方流资源合并到邀请方视图 ·默认仅悬浮布局合流
*
* 1.2如果被邀请方在加入邀请方房间之前没有发布过资源将会在被邀请方发布资源成功后服务器会把被邀请方流资源合并到邀请方视图默认仅悬浮布局合流
*
* 2:无论为true或false双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局一旦主动设置过合流布局后续音视频直播过程中设置的自动合流参数将失效
* <P/>
*/
IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() {
@Override
public void onSuccess() {
}
@Override
public void onFailed(RTCErrorCode errorCode) {
}
});
}
}
}
}
});
}
}
@Override
public void onFailed(RTCErrorCode errorCode) {
ToastUtil.show("接受失败");
}
});
} else {
ToastUtil.show(msg);
}
}
});
}
}
});
/*LiveHttpUtil.livePkCheckLive(u.getId(), "", "", new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
if (obj != null) {
if (obj.getString("ispk").equals("0")) {
}else{
ToastUtil.show(mContext.getString(R.string.pking_over));
}
}
}
}});*/
} else { } else {
if (mPkWaitCount < 0) { if (mPkWaitCount < 0) {
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() { onDRPkTimeoutTmp(u);
@Override
public void onFailed(RTCErrorCode errorCode) {
}
@Override
public void onSuccess() {
final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LINK_MIC_PK)
.param("action", 8);
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);
RongcloudIMManager.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", "发送失敗" + mApplyUid);
}
});
}
});
} else { } else {
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() { onDRPkRefuseTmp(u);
@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);
RongcloudIMManager.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", "发送失敗");
}
});
}
});
} }
mApplyUid = null; mApplyUid = null;
mApplyStream = null; mApplyStream = null;

View File

@ -107,7 +107,7 @@ import io.rong.message.TextMessage;
* 主播与主播PK逻辑 * 主播与主播PK逻辑
*/ */
public class LiveSwLinkMicPkPresenter implements View.OnClickListener { public class LiveSwLinkMicPkPresenter extends AbsLinkMicPkPresenter implements View.OnClickListener {
private static final int WHAT_PK_WAIT_RECEIVE = 0;//收到pk申请等待 what private static final int WHAT_PK_WAIT_RECEIVE = 0;//收到pk申请等待 what
private static final int WHAT_PK_WAIT_SEND = 1;//发送pk申请等待 what private static final int WHAT_PK_WAIT_SEND = 1;//发送pk申请等待 what
@ -123,15 +123,11 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
private ViewGroup mPkContainer; private ViewGroup mPkContainer;
private boolean mIsApplyDialogShow;//是否显示了申请PK的弹窗 private boolean mIsApplyDialogShow;//是否显示了申请PK的弹窗
private boolean mAcceptPk;//是否接受连麦 private boolean mAcceptPk;//是否接受连麦
private boolean mIsPk;//是否已经Pk了
public static String mApplyUid;//正在申请Pk的主播的uid
private String mApplyUrl;//正在申请Pk的主播的头像 private String mApplyUrl;//正在申请Pk的主播的头像
private String mApplyNmae;//正在申请Pk的主播的名字 private String mApplyNmae;//正在申请Pk的主播的名字
private String mApplyStream;//正在申请Pk的主播的stream private String mApplyStream;//正在申请Pk的主播的stream
private String mLiveUid;//自己主播的uid private String mLiveUid;//自己主播的uid
private String mUrl;//主播的头像 private String mUrl;//主播的头像
public static String mPkUid;//正在Pk的对方主播的uid
public static String oldmPkUid;//正在Pk的对方主播的uid
private ProgressTextView mLinkMicWaitProgress; private ProgressTextView mLinkMicWaitProgress;
private int mPkWaitCount;//Pk弹窗等待倒计时Live private int mPkWaitCount;//Pk弹窗等待倒计时Live
private int mPkTimeCount;//pk时间 private int mPkTimeCount;//pk时间
@ -140,7 +136,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
private LiveLinkMicPkViewHolder mLiveLinkMicPkViewHolder; private LiveLinkMicPkViewHolder mLiveLinkMicPkViewHolder;
private String mPkTimeString1; private String mPkTimeString1;
private String mPkTimeString2; private String mPkTimeString2;
private boolean mIsPkEnd;//pk是否结束进入惩罚时间
private boolean mPkSend;//pk请求是否已经发送 private boolean mPkSend;//pk请求是否已经发送
private int mPkSendWaitCount;//发送pk请求后的等待时间 private int mPkSendWaitCount;//发送pk请求后的等待时间
private String mSelfStream; private String mSelfStream;
@ -169,6 +165,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
} }
public LiveSwLinkMicPkPresenter(Context context, ILiveLinkMicViewHolder linkMicViewHolder, boolean isAnchor, View root) { public LiveSwLinkMicPkPresenter(Context context, ILiveLinkMicViewHolder linkMicViewHolder, boolean isAnchor, View root) {
super(true);
mContext = context; mContext = context;
mIsAnchor = isAnchor; mIsAnchor = isAnchor;
mRoot = root; mRoot = root;
@ -209,6 +206,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
} }
public LiveSwLinkMicPkPresenter(Context context, LivePushSwViewHolder linkMicViewHolder, boolean isAnchor, View root) { public LiveSwLinkMicPkPresenter(Context context, LivePushSwViewHolder linkMicViewHolder, boolean isAnchor, View root) {
super(true);
mContext = context; mContext = context;
mIsAnchor = isAnchor; mIsAnchor = isAnchor;
mRoot = root; mRoot = root;
@ -456,13 +454,6 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
} }
} }
/**
* 主播与主播PK 主播收到其他主播发过来的多人PK申请的回调
*/
public void onLinkDRMicPkApply(UserBean u) {
Log.e("ry", "多人收到");
showDRApplyDialog(u);
}
public void onLinkDRMicPkQuit(String uid) { public void onLinkDRMicPkQuit(String uid) {
HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", mApplyUid).execute(new HttpCallback() { HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", mApplyUid).execute(new HttpCallback() {
@ -571,7 +562,6 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
} }
SWManager.get().setDrPkNumClarity(drPkbeans.size()); SWManager.get().setDrPkNumClarity(drPkbeans.size());
if (drPkbeans.size() == 1) { if (drPkbeans.size() == 1) {
mLiveAnchorViewHolder.closeEndPkBt(); mLiveAnchorViewHolder.closeEndPkBt();
@ -619,30 +609,6 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
mLiveAnchorViewHolder.showEndPkBt(); mLiveAnchorViewHolder.showEndPkBt();
} }
/**
* 主播与主播PK 主播收到其他主播发过来的PK申请的回调
*/
public void onLinkMicPkApply(UserBean u, String stream, int by) {
Log.e("ry", u.getUserNiceName() + "单人收到" + u.getAvatar());
mApplyUid = u.getId();
mApplyUrl = u.getAvatar();
mApplyNmae = u.getUserNiceName();
if (by != 1) {
Log.e("ry", "1" + u.getUserNiceName() + "单人收到" + u.getAvatar());
if (mIsApplyDialogShow == false) {
if (u.isRandomPk()) {
Log.e("ry", "2" + u.getUserNiceName() + "单人收到" + u.getAvatar());
showPkDialog(u);
} else {
Log.e("ry", "3" + u.getUserNiceName() + "单人收到" + u.getAvatar());
showApplyDialog(u);
}
}
} else {
Log.e("ry", "4" + u.getUserNiceName() + "单人收到" + u.getAvatar());
isPK(u);
}
}
/** /**
* 主播与主播PK PK主播发过来的已经接受 * 主播与主播PK PK主播发过来的已经接受
@ -658,7 +624,8 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
LivePushSwViewHolder.btn_close.setVisibility(View.VISIBLE); LivePushSwViewHolder.btn_close.setVisibility(View.VISIBLE);
} }
private void isPK(UserBean bean) { @Override
protected void isPK(UserBean bean) {
EventBus.getDefault().post(new AnchorInfoEvent(false, bean.getId(), bean.getUserNiceName(), bean.getAvatar())); EventBus.getDefault().post(new AnchorInfoEvent(false, bean.getId(), bean.getUserNiceName(), bean.getAvatar()));
ScreenDimenUtil util = ScreenDimenUtil.getInstance(); ScreenDimenUtil util = ScreenDimenUtil.getInstance();
int mScreenWdith = util.getScreenWdith(); int mScreenWdith = util.getScreenWdith();
@ -720,273 +687,8 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
}); });
} }
/**
* 显示申请PK的弹窗
*/
private void showApplyDialog(UserBean u) {
mIsApplyDialogShow = true;
mAcceptPk = false;
View v = LayoutInflater.from(mContext).inflate(R.layout.dialog_link_mic_pk_wait, null);
mLinkMicWaitProgress = v.findViewById(R.id.pk_wait_progress);
v.findViewById(R.id.btn_refuse).setOnClickListener(this);
v.findViewById(R.id.btn_accept).setOnClickListener(this);
mPkWaitCount = LINK_MIC_COUNT_MAX;
mPkPopWindow = new PopupWindow(v, DpUtil.dp2px(280), ViewGroup.LayoutParams.WRAP_CONTENT, true);
mPkPopWindow.setBackgroundDrawable(new ColorDrawable());
mPkPopWindow.setOutsideTouchable(true);
mPkPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override @Override
public void onDismiss() { protected void onDRPkApply(UserBean u) {
if (mHandler != null) {
mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
}
if (mAcceptPk) {
LiveHttpUtil.livePkCheckLive(u.getId(), "", "", new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
if (obj != null) {
if (obj.getString("ispk").equals("0")) {
isPK(u);
} else {
ToastUtil.show(mContext.getString(R.string.pking_over));
}
}
}
}
});
} else {
if (mPkWaitCount < 0) {
final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 8);
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 (SocketSwClient.mSocketHandler != null) {
SocketSwClient.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;
}
mIsApplyDialogShow = false;
mLinkMicWaitProgress = null;
mPkPopWindow = null;
}
});
mPkPopWindow.showAtLocation(mRoot, Gravity.CENTER, 0, 0);
if (mHandler != null) {
mHandler.sendEmptyMessageAtTime(WHAT_PK_WAIT_RECEIVE, getNextSecondTime());
}
}
private String TAG = "多人PK";
public void editPkRoom(String uid){
SWManager.get().exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), uid);
}
/**
* 退出多人PK
*/
public void leaveDRRoom() {
//清理PK上面对方的头像
EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
Log.e("ry", "退出多人OKKK" + inputStreamList.size());
isDRPK = 0;
DRPKing = -1;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (btn_close != null) {
btn_close.setVisibility(View.GONE);
livePushSwViewHolder.timeTitle.setVisibility(View.GONE);
}
}
});
mLiveAnchorViewHolder.closeEndPkBt();
livePushSwViewHolder.exitChannelDrPk(drPkbeans);
leaveHandler.removeCallbacks(leaveRunnable);
}
private Handler leaveHandler = new Handler(Looper.getMainLooper());
private Runnable leaveRunnable = new Runnable() {
@Override
public void run() {
//恢复全屏画面
livePushSwViewHolder.dr_pk_view.setVisibility(View.GONE);
//删除之前其他主播的画面
livePushSwViewHolder.dr1_preview.removeAllViews();
livePushSwViewHolder.dr2_preview.removeAllViews();
livePushSwViewHolder.dr3_preview.removeAllViews();
livePushSwViewHolder.dr4_preview.removeAllViews();
livePushSwViewHolder.cameraPreview3.removeAllViews();
leaveHandler.removeCallbacks(leaveRunnable);
livePushSwViewHolder.timeTitle.setVisibility(View.GONE);
livePushSwViewHolder.mPreView.removeView(detailsView1);
livePushSwViewHolder.cameraPreview3.setVisibility(View.GONE);
}
};
/**
* 随机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将会10分钟内不会再收到任何随机PK请求。</font>")).setConfirmString("接受").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();
task.cancel();
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>" + "並且10分鍾不會收到任何隨機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"));
refusePk(u);
cancelBtn.setVisibility(View.GONE);
confirmBtn.setOnClickListener(v -> {
dialog.dismiss();
});
}
void apply() {
isPK(u);
}
}).build().show();
}
private void refusePk(UserBean u) {
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra_randm_pk", new IRCRTCResultCallback() {
@Override
public void onFailed(RTCErrorCode errorCode) {
}
@Override
public void onSuccess() {
final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK)
// .param("randomPk",u.isRandomPk()+"")
.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 (SocketSwClient.mSocketHandler != null) {
SocketSwClient.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);
}
/**
* 显示申请多人PK的弹窗
*/
private void showDRApplyDialog(UserBean u) {
mApplyUid = u.getId();
mIsApplyDialogShow = true;
mAcceptPk = false;
View v = LayoutInflater.from(mContext).inflate(R.layout.dialog_link_mic_pk_wait, null);
mLinkMicWaitProgress = v.findViewById(R.id.pk_wait_progress);
v.findViewById(R.id.btn_refuse).setOnClickListener(this);
v.findViewById(R.id.btn_accept).setOnClickListener(this);
mPkWaitCount = LINK_MIC_COUNT_MAX;
mPkPopWindow = new PopupWindow(v, DpUtil.dp2px(280), ViewGroup.LayoutParams.WRAP_CONTENT, true);
mPkPopWindow.setBackgroundDrawable(new ColorDrawable());
mPkPopWindow.setOutsideTouchable(true);
mPkPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
if (mHandler != null) {
mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
}
if (mAcceptPk) {
HttpClient.getInstance().get("Livepk.changeLive", "Livepk.changeLive").params("uid", CommonAppConfig.getInstance().getUid()).params("pkuid", u.getId()).params("type", "1").params("sign", "1").execute(new HttpCallback() { HttpClient.getInstance().get("Livepk.changeLive", "Livepk.changeLive").params("uid", CommonAppConfig.getInstance().getUid()).params("pkuid", u.getId()).params("type", "1").params("sign", "1").execute(new HttpCallback() {
@Override @Override
public void onSuccess(int code, String msgs, String[] info) { public void onSuccess(int code, String msgs, String[] info) {
@ -1146,8 +848,10 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
} }
} }
}); });
} else { }
if (mPkWaitCount < 0) {
@Override
protected void onDRPkTimeout(UserBean u) {
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() { IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() {
@Override @Override
@ -1186,8 +890,10 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
}); });
} }
}); });
}
} else { @Override
protected void onDRPkRefuse(UserBean u) {
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() { IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra", new IRCRTCResultCallback() {
@Override @Override
@ -1227,6 +933,300 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
} }
}); });
} }
@Override
protected void onPkApply(UserBean u) {
LiveHttpUtil.livePkCheckLive(u.getId(), "", "", new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
if (obj != null) {
if (obj.getString("ispk").equals("0")) {
isPKTmp(u);
} else {
ToastUtil.show(mContext.getString(R.string.pking_over));
}
}
}
}
});
}
@Override
protected void onPkTimeout(UserBean u) {
final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 8);
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 (SocketSwClient.mSocketHandler != null) {
SocketSwClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + "");
}
}
@Override
public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
Log.e("ry", "发送失敗" + u.getId());
}
});
}
@Override
protected void onPkRefuse(UserBean u) {
onPkTimeoutTmp(u);
}
/**
* 显示申请PK的弹窗
*/
@Override
protected void showApplyDialog(UserBean u) {
mIsApplyDialogShow = true;
mAcceptPk = false;
View v = LayoutInflater.from(mContext).inflate(R.layout.dialog_link_mic_pk_wait, null);
mLinkMicWaitProgress = v.findViewById(R.id.pk_wait_progress);
v.findViewById(R.id.btn_refuse).setOnClickListener(this);
v.findViewById(R.id.btn_accept).setOnClickListener(this);
mPkWaitCount = LINK_MIC_COUNT_MAX;
mPkPopWindow = new PopupWindow(v, DpUtil.dp2px(280), ViewGroup.LayoutParams.WRAP_CONTENT, true);
mPkPopWindow.setBackgroundDrawable(new ColorDrawable());
mPkPopWindow.setOutsideTouchable(true);
mPkPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
if (mHandler != null) {
mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
}
if (mAcceptPk) {
onPkApplyTmp(u);
} else {
if (mPkWaitCount < 0) {
onPkTimeoutTmp(u);
}
mApplyUid = null;
mApplyStream = null;
}
mIsApplyDialogShow = false;
mLinkMicWaitProgress = null;
mPkPopWindow = null;
}
});
mPkPopWindow.showAtLocation(mRoot, Gravity.CENTER, 0, 0);
if (mHandler != null) {
mHandler.sendEmptyMessageAtTime(WHAT_PK_WAIT_RECEIVE, getNextSecondTime());
}
}
private String TAG = "多人PK";
public void editPkRoom(String uid) {
SWManager.get().exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), uid);
}
/**
* 退出多人PK
*/
public void leaveDRRoom() {
//清理PK上面对方的头像
EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
Log.e("ry", "退出多人OKKK" + inputStreamList.size());
isDRPK = 0;
DRPKing = -1;
runOnUiThread(new Runnable() {
@Override
public void run() {
if (btn_close != null) {
btn_close.setVisibility(View.GONE);
livePushSwViewHolder.timeTitle.setVisibility(View.GONE);
}
}
});
mLiveAnchorViewHolder.closeEndPkBt();
livePushSwViewHolder.exitChannelDrPk(drPkbeans);
leaveHandler.removeCallbacks(leaveRunnable);
}
private Handler leaveHandler = new Handler(Looper.getMainLooper());
private Runnable leaveRunnable = new Runnable() {
@Override
public void run() {
//恢复全屏画面
livePushSwViewHolder.dr_pk_view.setVisibility(View.GONE);
//删除之前其他主播的画面
livePushSwViewHolder.dr1_preview.removeAllViews();
livePushSwViewHolder.dr2_preview.removeAllViews();
livePushSwViewHolder.dr3_preview.removeAllViews();
livePushSwViewHolder.dr4_preview.removeAllViews();
livePushSwViewHolder.cameraPreview3.removeAllViews();
leaveHandler.removeCallbacks(leaveRunnable);
livePushSwViewHolder.timeTitle.setVisibility(View.GONE);
livePushSwViewHolder.mPreView.removeView(detailsView1);
livePushSwViewHolder.cameraPreview3.setVisibility(View.GONE);
}
};
/**
* 随机PK拒绝对话框
*/
@Override
protected 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将会10分钟内不会再收到任何随机PK请求。</font>")).setConfirmString("接受").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();
task.cancel();
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>" + "並且10分鍾不會收到任何隨機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"));
refusePk(u);
cancelBtn.setVisibility(View.GONE);
confirmBtn.setOnClickListener(v -> {
dialog.dismiss();
});
}
void apply() {
isPKTmp(u);
}
}).build().show();
}
private void refusePk(UserBean u) {
IMRTCManager.getInstance().responseJoinOtherRoom(u.getId(), false, "extra_randm_pk", new IRCRTCResultCallback() {
@Override
public void onFailed(RTCErrorCode errorCode) {
}
@Override
public void onSuccess() {
final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK)
// .param("randomPk",u.isRandomPk()+"")
.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 (SocketSwClient.mSocketHandler != null) {
SocketSwClient.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);
}
/**
* 显示申请多人PK的弹窗
*/
@Override
protected void showDRApplyDialog(UserBean u) {
mApplyUid = u.getId();
mIsApplyDialogShow = true;
mAcceptPk = false;
View v = LayoutInflater.from(mContext).inflate(R.layout.dialog_link_mic_pk_wait, null);
mLinkMicWaitProgress = v.findViewById(R.id.pk_wait_progress);
v.findViewById(R.id.btn_refuse).setOnClickListener(this);
v.findViewById(R.id.btn_accept).setOnClickListener(this);
mPkWaitCount = LINK_MIC_COUNT_MAX;
mPkPopWindow = new PopupWindow(v, DpUtil.dp2px(280), ViewGroup.LayoutParams.WRAP_CONTENT, true);
mPkPopWindow.setBackgroundDrawable(new ColorDrawable());
mPkPopWindow.setOutsideTouchable(true);
mPkPopWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
@Override
public void onDismiss() {
if (mHandler != null) {
mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
}
if (mAcceptPk) {
onDRPkApplyTmp(u);
} else {
if (mPkWaitCount < 0) {
onDRPkTimeoutTmp(u);
} else {
onDRPkRefuseTmp(u);
}
mApplyUid = null; mApplyUid = null;
mApplyStream = null; mApplyStream = null;
} }

View File

@ -218,6 +218,8 @@ import pl.droidsonroids.gif.GifImageView;
*/ */
public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickListener { public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickListener {
private static final int PK_LINE_HEIGHT = (960 + DpUtil.dp2px(65));//单人PK席位高度线
private static final int PK_BOTTOM = ScreenDimenUtil.getInstance().getScreenWdith() / 2;
public static Context Contexts; public static Context Contexts;
private int mOffsetY; private int mOffsetY;
private ViewGroup mRoot; private ViewGroup mRoot;
@ -1807,7 +1809,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
} }
} }
}); });
} }
@ -2779,7 +2780,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
ScreenDimenUtil util = ScreenDimenUtil.getInstance(); ScreenDimenUtil util = ScreenDimenUtil.getInstance();
int mScreenWdith = util.getScreenWdith(); int mScreenWdith = util.getScreenWdith();
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) lt_pk_line.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) lt_pk_line.getLayoutParams();
params.height = mScreenWdith * 720 / 1120; params.height = mScreenWdith * 720 / PK_LINE_HEIGHT;
//params.bottomMargin = (mScreenWdith * 720 / 960);
lt_pk_line.requestLayout(); lt_pk_line.requestLayout();
lt_pk_line.setVisibility(View.VISIBLE); lt_pk_line.setVisibility(View.VISIBLE);
@ -2837,7 +2839,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
ScreenDimenUtil util = ScreenDimenUtil.getInstance(); ScreenDimenUtil util = ScreenDimenUtil.getInstance();
int mScreenWdith = util.getScreenWdith(); int mScreenWdith = util.getScreenWdith();
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) lt_pk_line.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) lt_pk_line.getLayoutParams();
params.height = mScreenWdith * 720 / 1120; params.height = mScreenWdith * 720 / PK_LINE_HEIGHT;
//params.bottomMargin=(mScreenWdith * 720 / 960);
lt_pk_line.requestLayout(); lt_pk_line.requestLayout();
lt_pk_line.setVisibility(View.VISIBLE); lt_pk_line.setVisibility(View.VISIBLE);

View File

@ -696,7 +696,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (mLivePlayViewHolder != null && data.getEnterRoomInfo().getIsconnection() != null && data.getEnterRoomInfo().getIsconnection().equals("1")) { if (mLivePlayViewHolder != null && data.getEnterRoomInfo().getIsconnection() != null && data.getEnterRoomInfo().getIsconnection().equals("1")) {
JSONArray array = pkInfo.getJSONArray("userlist"); JSONArray array = pkInfo.getJSONArray("userlist");
//判断是否是多人连麦 //判断是否是多人连麦
if (array.size() > 0) {//多人連麥 if (array!=null&& !array.isEmpty()) {//多人連麥
if (mLivePlayViewHolder != null) { if (mLivePlayViewHolder != null) {
List<DrPkbean> drPkbeans = new ArrayList<>(); List<DrPkbean> drPkbeans = new ArrayList<>();
for (int j = 0; j < array.size(); j++) { for (int j = 0; j < array.size(); j++) {
@ -782,6 +782,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
} }
if (mLivePlayViewHolder != null) { if (mLivePlayViewHolder != null) {
JSONArray array = pkInfo.getJSONArray("userlist"); JSONArray array = pkInfo.getJSONArray("userlist");
if(array==null){
array=new JSONArray();
}
List<DrPkbean> drPkbeans = new ArrayList<>(); List<DrPkbean> drPkbeans = new ArrayList<>();
for (int j = 0; j < array.size(); j++) { for (int j = 0; j < array.size(); j++) {
UserBean userBean = new UserBean(); UserBean userBean = new UserBean();
@ -2379,7 +2382,10 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
* @param time * @param time
*/ */
public void upDataPkScore(JSONArray pkScores, int time) { public void upDataPkScore(JSONArray pkScores, int time) {
L.eSw("upDataPkScore" + time); L.eSw("upDataPkScore" + time+"|"+pkScores);
if(pkScores==null){
return;
}
this.pkScores = pkScores; this.pkScores = pkScores;
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
String liveId = mLiveBean.getUid(); String liveId = mLiveBean.getUid();

View File

@ -1493,6 +1493,7 @@
<RelativeLayout <RelativeLayout
android:id="@+id/lt_pk_line" android:id="@+id/lt_pk_line"
android:layout_width="match_parent" android:layout_width="match_parent"
tools:visibility="visible"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/live_top" android:layout_marginTop="@dimen/live_top"
android:visibility="gone"> android:visibility="gone">

View File

@ -9,6 +9,7 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.lxj.xpopup.XPopup; import com.lxj.xpopup.XPopup;
import com.yunbao.common.dialog.MessageSayHiNotifyDialog;
import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.dialog.SkitCheckInWasSuccessfulPopup; import com.yunbao.common.dialog.SkitCheckInWasSuccessfulPopup;
@ -59,9 +60,6 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
// img_trophy.setOnLongClickListener(new View.OnLongClickListener() { // img_trophy.setOnLongClickListener(new View.OnLongClickListener() {
// @Override // @Override
// public boolean onLongClick(View view) { // public boolean onLongClick(View view) {
// new XPopup.Builder(mContext)
// .asCustom(new SkitCheckInWasSuccessfulPopup(mContext))
// .show();
// return true; // return true;
// } // }
// }); // });

View File

@ -43,7 +43,7 @@
<string name="dialog_msg_status_online_config">在線</string> <string name="dialog_msg_status_online_config">在線</string>
<string name="dialog_msg_status_offline_config">離線</string> <string name="dialog_msg_status_offline_config">離線</string>
<string name="dialog_msg_hi_config_save">保存設置</string> <string name="dialog_msg_hi_config_save">保存設置</string>
<string name="dialog_msg_hi_config_clear">保存設置</string> <string name="dialog_msg_hi_config_clear">清除設置</string>
<string name="dialog_msg_hi_config_audio">語音</string> <string name="dialog_msg_hi_config_audio">語音</string>
<string name="dialog_msg_hi_config_text">文案</string> <string name="dialog_msg_hi_config_text">文案</string>
<string name="dialog_msg_hi_config_image">圖片</string> <string name="dialog_msg_hi_config_image">圖片</string>