diff --git a/FaceUnity/build.gradle b/FaceUnity/build.gradle
index 440319b62..254ca57ee 100644
--- a/FaceUnity/build.gradle
+++ b/FaceUnity/build.gradle
@@ -39,6 +39,7 @@ android {
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
+ //abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64"
abiFilters "armeabi-v7a", "arm64-v8a"
}
}
@@ -72,10 +73,10 @@ dependencies {
implementation rootProject.ext.dependencies["recyclerview-androidx"]
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//common
- implementation project(path: ':common')
+ api project(path: ':common')
- implementation 'com.faceunity:core:8.3.1'
- implementation 'com.faceunity:model:8.3.1'
+ api 'com.faceunity:core:8.7.0'
+ api 'com.faceunity:model:8.7.0'
//implementation 'com.faceunity:nama:8.3.1' //底层库-标准版
diff --git a/FaceUnity/src/androidTest/java/com/yunbao/faceunity/ExampleInstrumentedTest.java b/FaceUnity/src/androidTest/java/com/yunbao/faceunity/ExampleInstrumentedTest.java
deleted file mode 100644
index d1ea2eda2..000000000
--- a/FaceUnity/src/androidTest/java/com/yunbao/faceunity/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.yunbao.faceunity;
-
-import android.content.Context;
-
-import androidx.test.platform.app.Instrimport com.yunbao.common.utils.MobclickAgent;ntationRegistry;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
- assertEquals("com.yunbao.faceunity.test", appContext.getPackageName());
- }
-}
\ No newline at end of file
diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java b/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java
index 9cbef67ef..0c3c09d6e 100644
--- a/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java
+++ b/FaceUnity/src/main/java/com/yunbao/faceunity/FaceManager.java
@@ -96,11 +96,17 @@ public class FaceManager implements SensorEventListener {
faceUnityView.setIFaceUnityInter(new FaceUnityView.IFaceUnityInter() {
@Override
public void onPause() {
+ if(onMirrorChanged!=null){
+ onMirrorChanged.onChange(false);
+ }
pauseFace = true;
}
@Override
public void onStart() {
+ if(onMirrorChanged!=null){
+ onMirrorChanged.onChange(true);
+ }
pauseFace = false;
}
});
@@ -295,7 +301,18 @@ public class FaceManager implements SensorEventListener {
}
+ OnMirrorChanged onMirrorChanged;
+
+ public void setOnMirrorChanged(OnMirrorChanged onMirrorChanged) {
+ this.onMirrorChanged = onMirrorChanged;
+ }
+
public interface FaceStatusChanged {
void onFaceChanged(int num);
}
+
+
+ public interface OnMirrorChanged{
+ void onChange(boolean falg);
+ }
}
diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FURenderer.java b/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FURenderer.java
index 19ff7db23..12fd910f8 100644
--- a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FURenderer.java
+++ b/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FURenderer.java
@@ -52,10 +52,10 @@ public class FURenderer extends IFURenderer {
/* 特效FURenderKit*/
- private FURenderKit mFURenderKit;
+ public FURenderKit mFURenderKit;
/* AI道具*/
- public static String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor_lite.bundle";
+ public static String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor.bundle";
public static String BUNDLE_AI_HUMAN = "model" + File.separator + "ai_human_processor.bundle";
/* GL 线程 ID */
diff --git a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FaceUnityConfig.java b/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FaceUnityConfig.java
index 7ca84f925..b6a2d51de 100644
--- a/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FaceUnityConfig.java
+++ b/FaceUnity/src/main/java/com/yunbao/faceunity/utils/FaceUnityConfig.java
@@ -15,7 +15,7 @@ public class FaceUnityConfig {
/************************** 算法Model ******************************/
// 人脸识别
- public static String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor_lite.bundle";
+ public static String BUNDLE_AI_FACE = "model" + File.separator + "ai_face_processor.bundle";
// 手势
public static String BUNDLE_AI_HAND = "model" + File.separator + "ai_hand_processor.bundle";
diff --git a/Share/build.gradle b/Share/build.gradle
index 82ae79327..7537b689a 100644
--- a/Share/build.gradle
+++ b/Share/build.gradle
@@ -40,6 +40,7 @@ android {
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
+ //abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64"
}
}
aaptOptions {
diff --git a/Share/src/androidTest/java/com/yunbao/share/ExampleInstrumentedTest.java b/Share/src/androidTest/java/com/yunbao/share/ExampleInstrumentedTest.java
deleted file mode 100644
index 73039a6f1..000000000
--- a/Share/src/androidTest/java/com/yunbao/share/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.yunbao.share;
-
-import android.content.Context;
-
-import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
- assertEquals("com.yunbao.share.test", appContext.getPackageName());
- }
-}
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 256ba9cb8..f7811b158 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -229,6 +229,7 @@ android {
ndk {
// TODO: 谷歌商城需要兼容两个平台
abiFilters "armeabi-v7a", "arm64-v8a"
+ //abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64"
}
javaCompileOptions {
annotationProcessorOptions {
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
index 87cfa033e..1c250b06d 100644
--- a/app/proguard-rules.pro
+++ b/app/proguard-rules.pro
@@ -190,6 +190,8 @@ rx.internal.util.atomic.LinkedQueueNode* consumerNode;
-keep class org.greenrobot.eventbus.android.AndroidComponentsImpl*
#--------ARouter
+
+-keep public class com.alibaba.android.arouter.**{*;}
-keep public class com.alibaba.android.arouter.routes.**{*;}
-keep public class com.alibaba.android.arouter.facade.**{*;}
-keep class * implements com.alibaba.android.arouter.facade.template.ISyringe{*;}
@@ -308,6 +310,8 @@ rx.internal.util.atomic.LinkedQueueNode* consumerNode;
-keep class com.shayu.lib_google.**{*;}
-keep class com.shayu.lib_huawei.**{*;}
+-keep class io.agora.**{*;}
+
-keep class com.qiniu.**{*;}
-keep class com.qiniu.**{public ();}
-ignorewarnings
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f980b5087..641ab1b77 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -89,6 +89,11 @@
+
+
+
+
+
@@ -160,6 +165,12 @@
+
+
diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java
index e4815b9e9..a98655d52 100644
--- a/app/src/main/java/com/shayu/phonelive/AppContext.java
+++ b/app/src/main/java/com/shayu/phonelive/AppContext.java
@@ -29,10 +29,12 @@ import com.google.gson.Gson;
import com.pandoralive.shayu.R;
import com.shayu.phonelive.utils.LogUtils;
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
+import com.yunbao.common.http.Data;
import com.tencent.imsdk.v2.V2TIMManager;
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
import com.tencent.imsdk.v2.V2TIMUserInfo;
import com.yunbao.common.utils.MobclickAgent;
+import com.yunbao.common.manager.OpenAdManager;
import com.yalantis.ucrop.UCropActivity;
import com.yunbao.common.BuildConfig;
import com.yunbao.common.CommonAppConfig;
@@ -59,9 +61,11 @@ import com.yunbao.common.utils.MessageSayHiNotifyManager;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.activity.LiveActivity;
-import com.yunbao.live.activity.SudGameActivity;
+import com.yunbao.live.activity.SudRyGameActivity;
+import com.yunbao.live.activity.SudSwGameActivity;
import com.yunbao.live.socket.SocketReceiveBean;
import com.yunbao.live.socket.SocketRyClient;
+import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.utils.LiveImDeletUtil;
import com.yunbao.live.views.PortraitLiveManager;
import com.yunbao.live.views.RecommendLiveRoomProvider;
@@ -82,6 +86,7 @@ import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Date;
import java.util.List;
import io.rong.imkit.config.RongConfigCenter;
@@ -111,7 +116,7 @@ public class AppContext extends CommonAppContext {
private static final class AdjustLifecycleCallbacks implements ActivityLifecycleCallbacks {
@Override
- public void onActivityResumed(Activity activity) {
+ public void onActivityResumed(@NonNull Activity activity) {
Log.e("打招呼定时器", "onActivityResumed: " + activity);
MessageChatNotifyManager.getInstance().restart(activity);
if (activity instanceof LiveActivity) {
@@ -126,7 +131,11 @@ public class AppContext extends CommonAppContext {
MessageSayHiNotifyManager.getInstance().stop();
return;
}
- if (activity instanceof SudGameActivity) {
+ if (activity instanceof SudRyGameActivity) {
+ MessageSayHiNotifyManager.getInstance().stop();
+ return;
+ }
+ if (activity instanceof SudSwGameActivity) {
MessageSayHiNotifyManager.getInstance().stop();
return;
}
@@ -157,7 +166,7 @@ public class AppContext extends CommonAppContext {
}
@Override
- public void onActivityPaused(Activity activity) {
+ public void onActivityPaused(@NonNull Activity activity) {
}
@Override
@@ -172,10 +181,11 @@ public class AppContext extends CommonAppContext {
@Override
public void onActivityDestroyed(@NonNull Activity activity) {
+ AppManager.getInstance().removeActivity(activity);
for (WeakReference reference : activities) {
if (reference.get() == activity) {
activities.remove(reference);
- return;
+ break;
}
}
AppManager.getInstance().removeActivity(activity);
@@ -184,11 +194,12 @@ public class AppContext extends CommonAppContext {
@Override
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
activities.add(new WeakReference<>(activity));
- if(activity instanceof LoginActivity){
+ if (activity instanceof LoginActivity) {
AppManager.getInstance().clear();
}
CrashSaveBean.getInstance().setActivitySize(activities);
AppManager.getInstance().addActivity(activity);
+ OpenAdManager.getInstance().dismiss();
}
@Override
@@ -279,7 +290,7 @@ public class AppContext extends CommonAppContext {
RongcloudIMManager.addRongcloudIMOnReceiveMessageListener(new RongIMClient.OnReceiveMessageWrapperListener() {
@Override
public boolean onReceived(io.rong.imlib.model.Message message, int i, boolean b, boolean b1) {
- Log.e("wewe", message.getConversationType() + "112121");
+ Log.e("wewe", message.getConversationType() + "112121 " + message.getContent());
MessageIMManager.get(sInstance).getSystemForRongcloud(message);
//融云直播间聊天
Message msg = Message.obtain();
@@ -303,7 +314,30 @@ public class AppContext extends CommonAppContext {
}
if (content.getContent().contains("_method_")) {
msg.obj = content.getContent();
- //观众页面
+ String time = String.valueOf(new Date().getTime());
+ //声网
+ if (SocketSwClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
+ SocketSwClient.mSocketHandler.sendMessage(msg);
+ } else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知
+ SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class);
+ JSONObject map = received.getMsg().getJSONObject(0);
+ sendStartAnchorLive(map);
+ } else if (message.getTargetId().contains("v")) {
+ String contentJson = ((TextMessage) message.getContent()).getContent();
+ Log.e("wewe", contentJson);
+ SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
+ if (sudGameSocketImEvent.getMsg().isEmpty()) {
+ return false;
+ }
+ sudGameSocketImEvent.getMsg().get(0).setTime(time);
+ Bus.get().post(sudGameSocketImEvent);
+ }
+ //主播页面
+ if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketSwClient.mSocketHandler != null) {
+ SocketSwClient.mSocketHandler.sendMessage(msg);
+ }
+
+ //融云
if (SocketRyClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
SocketRyClient.mSocketHandler.sendMessage(msg);
} else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知
@@ -314,6 +348,10 @@ public class AppContext extends CommonAppContext {
String contentJson = ((TextMessage) message.getContent()).getContent();
Log.e("wewe", contentJson);
SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
+ if (sudGameSocketImEvent.getMsg().isEmpty()) {
+ return false;
+ }
+ sudGameSocketImEvent.getMsg().get(0).setTime(time);
Bus.get().post(sudGameSocketImEvent);
}
//主播页面
diff --git a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java
index 9aeb9d016..03d1652cc 100644
--- a/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java
+++ b/app/src/main/java/com/shayu/phonelive/activity/LauncherActivity.java
@@ -113,6 +113,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
res.updateConfiguration(config, res.getDisplayMetrics());
return res;
}
+
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
@@ -144,7 +145,11 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
}
};
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
- LogUtil.uploadErrorLog(AppContext.sInstance);
+ try {
+ LogUtil.uploadErrorLog(AppContext.sInstance);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
SpUtil.getInstance().setBooleanValue("NOTIFICATION", NotificationManagerCompat.from(this).areNotificationsEnabled());
}
@@ -229,7 +234,7 @@ public class LauncherActivity extends AppCompatActivity implements View.OnClickL
} else {
checkUidAndToken();
}
- }else{
+ } else {
ToastUtil.show(getString(R.string.net_error));
}
}
diff --git a/baidu/build.gradle b/baidu/build.gradle
index 5078c923d..e8264e585 100644
--- a/baidu/build.gradle
+++ b/baidu/build.gradle
@@ -31,7 +31,7 @@ android {
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
- abiFilters "armeabi-v7a","arm64-v8a"
+ abiFilters "armeabi-v7a","arm64-v8a","x86","x86_64"
}
}
buildTypes {
diff --git a/beauty/build.gradle b/beauty/build.gradle
index 613c86161..1a371ced8 100644
--- a/beauty/build.gradle
+++ b/beauty/build.gradle
@@ -31,7 +31,7 @@ android {
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
- abiFilters "armeabi-v7a","arm64-v8a"
+ abiFilters "armeabi-v7a","arm64-v8a","x86","x86_64"
}
}
aaptOptions {
diff --git a/build.gradle b/build.gradle
index c090eb224..67466e7ed 100644
--- a/build.gradle
+++ b/build.gradle
@@ -53,4 +53,10 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}
-
+ext {
+ IS_PUBLISH_LOCAL=true
+ LIB_VERSION="1.0.6"
+ AGORA_RTC_SDK= 'io.agora.rtc:agora-special-full:4.2.6.12'
+// AGORA_RTC_SDK= "${rootProject.rootDir.absolutePath}/sdk"
+// AGORA_RTC_SDK="io.agora.rtc:full-sdk:4.2.6"
+}
diff --git a/common/build.gradle b/common/build.gradle
index e1cc40c2d..dc6938055 100644
--- a/common/build.gradle
+++ b/common/build.gradle
@@ -1,5 +1,6 @@
apply plugin: 'com.android.library'
apply plugin: 'img-optimizer'
+apply plugin: 'kotlin-android'
android {
@@ -13,7 +14,7 @@ android {
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
- abiFilters "armeabi-v7a", "arm64-v8a"
+ abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64"
}
javaCompileOptions {
@@ -248,6 +249,7 @@ dependencies {
api 'com.github.FlyJingFish:GradientTextView:1.2.4'
//轮播 一屏显示多个
api 'com.github.xiaohaibin:XBanner:androidx_v1.2.6'
-
-
+ //声网SDK
+ //api 'io.agora.rtc:agora-special-full:4.2.6.245'
+ api 'com.xj.marqueeView:marqueeView:0.1.20'
}
diff --git a/common/src/main/java/com/yunbao/common/CommonAppConfig.java b/common/src/main/java/com/yunbao/common/CommonAppConfig.java
index bb2d113d0..04756b1b8 100644
--- a/common/src/main/java/com/yunbao/common/CommonAppConfig.java
+++ b/common/src/main/java/com/yunbao/common/CommonAppConfig.java
@@ -40,6 +40,7 @@ public class CommonAppConfig {
//是否为插件包模式
public static final boolean IS_PLUGIN_MODEL = getMetaDataBoolean("IS_PLUGIN_MODEL");
public static final String BUILD_TIME = getMetaDataString("BUILD_TIME");
+ public static final boolean IS_SW_RELEASE = getMetaDataBoolean("SW_RELEASE_MODEL");
//外部sd卡
public static final String DCMI_PATH = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath();
@@ -79,7 +80,29 @@ public class CommonAppConfig {
public static boolean isGetNewWrap = false;//是否获取到新的包裹礼物
public static int alert_time = 1;
public static int alert_end_time = 1;
+ public static String SWToken = ""; //声网Token
+ public static final String SWChannelPrefix = "g";
+ //测试服
+ public static final String SWAPPId_debug = "4cf0376582d742ac8a96778b25b1079e";
+ //正式服
+ public static final String SWAPPId = "d4a5879524d74c20a7bdd667b0f2ca21";
+ public static String getSwAppId() {
+ if (IS_SW_RELEASE) {
+ return SWAPPId;
+ } else {
+ return SWAPPId_debug;
+ }
+ }
+
+ /**
+ * 获取通道
+ *
+ * @return
+ */
+ public static String getChannelName() {
+ return SWChannelPrefix + getInstance().getUid();
+ }
private CommonAppConfig() {
diff --git a/common/src/main/java/com/yunbao/common/Constants.java b/common/src/main/java/com/yunbao/common/Constants.java
index fb7003cc0..af7850d0c 100644
--- a/common/src/main/java/com/yunbao/common/Constants.java
+++ b/common/src/main/java/com/yunbao/common/Constants.java
@@ -269,7 +269,9 @@ public class Constants {
public static final String LIVE_PK_RANDOM_START="RankingStartRandomPK";
public static final int LIVE_SDK_KSY = 0;//金山推流
public static final int LIVE_SDK_TX = 1;//腾讯推流
+ public static final int LIVE_SDK_SW = 2;//声网
+ public static final String LIVE_SDK_IS_SW = "liveSdkIsSw"; //是否是聲網
public static final int LINK_MIC_TYPE_NORMAL = 0;//观众与主播连麦
public static final int LINK_MIC_TYPE_ANCHOR = 1;//主播与主播连麦
diff --git a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java
index 2a1046b0d..dc238840c 100644
--- a/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java
+++ b/common/src/main/java/com/yunbao/common/activity/WebViewActivity.java
@@ -435,7 +435,7 @@ public class WebViewActivity extends AbsActivity {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (liveBean == null) {
return;
}
@@ -451,7 +451,7 @@ public class WebViewActivity extends AbsActivity {
}
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)));
} else {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk),isSw);
}
finish();
}
diff --git a/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java b/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java
index 2ab378200..013a58bd3 100644
--- a/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java
+++ b/common/src/main/java/com/yunbao/common/adapter/CustomDrawerPopupAdapter.java
@@ -40,12 +40,15 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter {
private final int RIGHTS_INTERESTS = 4;
private final int RECOMMEND = 5;
private String liveId;
+ private boolean mIs_shengwang;
+
private List list = new ArrayList<>();
private List infoModels = new ArrayList<>();
- public CustomDrawerPopupAdapter(Context mContext) {
+ public CustomDrawerPopupAdapter(Context mContext,boolean mIs_shengwang) {
this.mContext = mContext;
+ this.mIs_shengwang = mIs_shengwang;
}
@@ -114,6 +117,7 @@ public class CustomDrawerPopupAdapter extends RecyclerView.Adapter {
map.put("num", "9");
map.put("live_recommend", "sidebar");
map.put("refresh", "1");
+ map.put(" is_shengwang", mIs_shengwang?"1":"0");
//推荐位
MainNetManager.get((Activity) mContext)
.anchorRecommend(map, new com.yunbao.common.http.base.HttpCallback() {
diff --git a/common/src/main/java/com/yunbao/common/bean/CheckLiveModel.java b/common/src/main/java/com/yunbao/common/bean/CheckLiveModel.java
index ccb6274c8..4b4f7ca30 100644
--- a/common/src/main/java/com/yunbao/common/bean/CheckLiveModel.java
+++ b/common/src/main/java/com/yunbao/common/bean/CheckLiveModel.java
@@ -2,6 +2,7 @@ package com.yunbao.common.bean;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
+import com.yunbao.common.BuildConfig;
public class CheckLiveModel extends BaseModel {
@@ -13,6 +14,16 @@ public class CheckLiveModel extends BaseModel {
private String typeMsg;
@SerializedName("live_sdk")
private String liveSdk;
+ @SerializedName("is_shengwang")
+ private String isShengwang;
+
+ public String getIsShengwang() {
+ return isShengwang;
+ }
+
+ public void setIsShengwang(String isShengwang) {
+ this.isShengwang = isShengwang;
+ }
public static CheckLiveModel objectFromData(String str) {
diff --git a/common/src/main/java/com/yunbao/common/bean/ConfigBean.java b/common/src/main/java/com/yunbao/common/bean/ConfigBean.java
index a2a307dce..ec6d14242 100644
--- a/common/src/main/java/com/yunbao/common/bean/ConfigBean.java
+++ b/common/src/main/java/com/yunbao/common/bean/ConfigBean.java
@@ -2,6 +2,8 @@ package com.yunbao.common.bean;
import com.alibaba.fastjson.annotation.JSONField;
import com.google.gson.annotations.SerializedName;
+import com.yunbao.common.BuildConfig;
+import com.yunbao.common.utils.StringUtil;
import java.util.Arrays;
import java.util.List;
@@ -59,6 +61,9 @@ public class ConfigBean extends BaseModel {
private String txPlayUgcLicenceUrl;//腾讯短视频鉴权
private String txVideoUgcKey;
private String google_isup;
+
+ private String sud_game_speech;
+
@SerializedName("is_return_user")//是否需要弹窗(0否,1是)
private String isReturnUser="";
@SerializedName("popup_img_url")//弹窗图片地址
@@ -182,6 +187,20 @@ public class ConfigBean extends BaseModel {
'}';
}
+
+ public boolean isSw(){
+ return getSud_game_speech().equals("1");
+ }
+
+ @JSONField(name = "sud_game_speech")
+ public String getSud_game_speech() {
+ return sud_game_speech;
+ }
+
+ public void setSud_game_speech(String sud_game_speech) {
+ this.sud_game_speech = sud_game_speech;
+ }
+
@JSONField(name = "apk_ver")
public String getVersion() {
return version;
diff --git a/common/src/main/java/com/yunbao/common/bean/EnterRoomInfoModel.java b/common/src/main/java/com/yunbao/common/bean/EnterRoomInfoModel.java
index ec265a735..d32508ad6 100644
--- a/common/src/main/java/com/yunbao/common/bean/EnterRoomInfoModel.java
+++ b/common/src/main/java/com/yunbao/common/bean/EnterRoomInfoModel.java
@@ -114,6 +114,17 @@ public class EnterRoomInfoModel extends BaseModel {
@SerializedName("gift_wall_lighten_total")
private String giftWallLightenTotal;
+ @SerializedName("connection_info")
+ private LivePkMicModel connectionInfo;
+
+ public LivePkMicModel getConnectionInfo() {
+ return connectionInfo;
+ }
+
+ public void setConnectionInfo(LivePkMicModel connectionInfo) {
+ this.connectionInfo = connectionInfo;
+ }
+
public String getGiftWallLightenNumber() {
return giftWallLightenNumber;
}
diff --git a/common/src/main/java/com/yunbao/common/bean/EnterRoomNewModel.java b/common/src/main/java/com/yunbao/common/bean/EnterRoomNewModel.java
index 7ecda8f0f..bc915a619 100644
--- a/common/src/main/java/com/yunbao/common/bean/EnterRoomNewModel.java
+++ b/common/src/main/java/com/yunbao/common/bean/EnterRoomNewModel.java
@@ -41,6 +41,7 @@ public class EnterRoomNewModel extends BaseModel {
private SudGameDateModel sudGameDateModel;
@SerializedName("quick_gift_remaining_quantity")
private int quickGiftRemainingQuantity;//剩余的小PD礼物数量
+
@SerializedName("if_viewing_duration_complete")
private int ifViewingDurationComplete;//通过观看时间获取小PD礼物的次数
@SerializedName("sendMoneyLongStatus")
diff --git a/common/src/main/java/com/yunbao/common/bean/LivePkMicModel.java b/common/src/main/java/com/yunbao/common/bean/LivePkMicModel.java
new file mode 100644
index 000000000..8a152613a
--- /dev/null
+++ b/common/src/main/java/com/yunbao/common/bean/LivePkMicModel.java
@@ -0,0 +1,36 @@
+package com.yunbao.common.bean;
+
+import com.google.gson.annotations.SerializedName;
+
+public class LivePkMicModel extends BaseModel {
+ @SerializedName("pkuid")
+ private String pkuid;
+ @SerializedName("pkuname")
+ private String pkuname;
+ @SerializedName("pkuimg")
+ private String pkuimg;
+
+ public String getPkuid() {
+ return pkuid;
+ }
+
+ public void setPkuid(String pkuid) {
+ this.pkuid = pkuid;
+ }
+
+ public String getPkuname() {
+ return pkuname;
+ }
+
+ public void setPkuname(String pkuname) {
+ this.pkuname = pkuname;
+ }
+
+ public String getPkuimg() {
+ return pkuimg;
+ }
+
+ public void setPkuimg(String pkuimg) {
+ this.pkuimg = pkuimg;
+ }
+}
diff --git a/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java b/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java
index 8260ee377..638334d48 100644
--- a/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java
+++ b/common/src/main/java/com/yunbao/common/bean/OpenAdModel.java
@@ -2,7 +2,6 @@ package com.yunbao.common.bean;
import com.google.gson.annotations.SerializedName;
import com.yunbao.common.CommonAppConfig;
-import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.StringUtil;
import java.text.ParseException;
@@ -22,6 +21,8 @@ public class OpenAdModel extends BaseModel {
public static final int SHOW_ONE = 3;//3. 仅弹出一次;
@SerializedName("id")
private int id;
+ @SerializedName("popup_name")
+ private String name;
@SerializedName("popup_location")
private int type = TYPE_HOME;
@SerializedName("activity_url")
@@ -35,24 +36,27 @@ public class OpenAdModel extends BaseModel {
@SerializedName("popup_model")
private int model = MODEL_SQUARE;
@SerializedName("start_show_time")
- private String startTime;//活动开始时间
+ private String startTime;//活动开始时间 1
@SerializedName("end_show_time")
- private String endTime;//活动结束时间
+ private String endTime;//活动结束时间 5
@SerializedName("popup_permission")
private int permission;
@SerializedName("popup_frequency")
private int showModel = SHOW_DEF;//显示模式,1:杀死程序后弹出 2:指定时间内(本机时间) 3:1. 仅弹出一次
@SerializedName("popup_frequency_time")
- private String section = "0";// SHOW_DEF = 2
-
+ private String section = "0";// SHOW_DEF = 2 1
+ @SerializedName("popup_sort")
+ private int popupSort = 1;//弹框类型 1.图片 2.H5
+ @SerializedName("sort")
+ private int sort = 0;
public OpenAdModel() {
}
public static OpenAdModel createTestData() {
OpenAdModel model = new OpenAdModel();
- model.id=3;
- model.type=1;
+ model.id = 3;
+ model.type = 1;
model.url = "/h5/GuildTournament/20230821/rank.html";
model.imageUrl = "https://ceshi.yaoulive.com/data/upload/20230913/1694589490.png";
model.showTime = 10;
@@ -66,6 +70,30 @@ public class OpenAdModel extends BaseModel {
return model;
}
+ public int getPopupSort() {
+ return popupSort;
+ }
+
+ public int getSort() {
+ return sort;
+ }
+
+ public void setSort(int sort) {
+ this.sort = sort;
+ }
+
+ public void setPopupSort(int popupSort) {
+ this.popupSort = popupSort;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
public int getShowModel() {
return showModel;
}
@@ -91,12 +119,13 @@ public class OpenAdModel extends BaseModel {
}
public String getUrl() {
- if (!url.startsWith("http://") || !url.startsWith("https://")) {
- url = CommonAppConfig.HOST + url;
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
+ url = CommonAppConfig.HOST + (url.startsWith("/") ? url : "/" + url);
}
- return url + "?t=" + System.currentTimeMillis() / 1000;
+ return url;
}
- public String getOriginalUrl(){
+
+ public String getOriginalUrl() {
return url;
}
@@ -198,6 +227,7 @@ public class OpenAdModel extends BaseModel {
public String toString() {
return "OpenAdModel{" +
"id=" + id +
+ ", name='" + name + '\'' +
", type=" + type +
", url='" + url + '\'' +
", imageUrl='" + imageUrl + '\'' +
@@ -206,7 +236,10 @@ public class OpenAdModel extends BaseModel {
", model=" + model +
", startTime='" + startTime + '\'' +
", endTime='" + endTime + '\'' +
- ", permission='" + permission + '\'' +
+ ", permission=" + permission +
+ ", showModel=" + showModel +
+ ", section='" + section + '\'' +
+ ", sort=" + popupSort +
'}';
}
}
diff --git a/common/src/main/java/com/yunbao/common/bean/SwTokenModel.java b/common/src/main/java/com/yunbao/common/bean/SwTokenModel.java
new file mode 100644
index 000000000..2f50ed67c
--- /dev/null
+++ b/common/src/main/java/com/yunbao/common/bean/SwTokenModel.java
@@ -0,0 +1,23 @@
+package com.yunbao.common.bean;
+
+/**
+ * 声网token
+ */
+public class SwTokenModel extends BaseModel {
+ private String token;
+
+ public SwTokenModel() {
+ }
+
+ public SwTokenModel(String token) {
+ this.token = token;
+ }
+
+ public String getToken() {
+ return token;
+ }
+
+ public void setToken(String token) {
+ this.token = token;
+ }
+}
diff --git a/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java b/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java
index d8759af91..d4abdd05e 100644
--- a/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java
+++ b/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java
@@ -20,6 +20,7 @@ import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BottomPopupView;
import com.lxj.xpopup.enums.PopupPosition;
+import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.R;
import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.CustomSidebarChildModel;
@@ -153,8 +154,6 @@ public class CreateSudGamePopup extends BottomPopupView {
.asCustom(new SudGameListSelectPopup(getContext(), 4, customSidebarChildModels, interactionID))
.show();
}
-
-
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.room_back),
@@ -282,7 +281,11 @@ public class CreateSudGamePopup extends BottomPopupView {
public void onSuccess(CreateSudRoomModel data) {
if (isHome) {
dialog.dismiss();
- RouteUtil.forwardSudGameActivity(new Gson().toJson(data));
+ if(CommonAppConfig.getInstance().getConfig().isSw()){
+ RouteUtil.forwardSwSudGameActivity(new Gson().toJson(data),true,isHome);
+ }else{
+ RouteUtil.forwardRySudGameActivity(new Gson().toJson(data),true,isHome);
+ }
} else {
Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(0).setCreateSudRoomModel(data));
diff --git a/common/src/main/java/com/yunbao/common/dialog/DebugDialog.java b/common/src/main/java/com/yunbao/common/dialog/DebugDialog.java
index c65520ff4..4764a38e5 100644
--- a/common/src/main/java/com/yunbao/common/dialog/DebugDialog.java
+++ b/common/src/main/java/com/yunbao/common/dialog/DebugDialog.java
@@ -21,13 +21,14 @@ import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.ToastUtil;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Timer;
import java.util.TimerTask;
public class DebugDialog {
RecyclerView recyclerView;
- HashMap params;
+ LinkedHashMap params;
DebugDialogAdapter adapter;
private static DebugDialog debugDialog;
Context mContext;
@@ -70,7 +71,7 @@ public class DebugDialog {
this.runnable = runnable;
if (params == null) {
Log.i("debug弹窗", "DebugDialog: 初始化参数");
- params = new HashMap<>();
+ params = new LinkedHashMap<>();
}
init();
}
@@ -103,6 +104,7 @@ public class DebugDialog {
}
public void show() {
+ if (recyclerView != null) return;
if (showPattern == ShowPattern.CURRENT_ACTIVITY) {
createView();
return;
@@ -138,7 +140,7 @@ public class DebugDialog {
EasyFloat.updateFloat("debug");
}
});
- params.put("debug弹窗", textView);
+ params.put("发包时间:" + CommonAppConfig.BUILD_TIME, textView);
params.put("发包时间:" + CommonAppConfig.BUILD_TIME, buildTime);
adapter.setParamMap(params);
diff --git a/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java
index 072ab97a8..e878da2d2 100644
--- a/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java
+++ b/common/src/main/java/com/yunbao/common/dialog/OpenAdBottomDialogPopup.java
@@ -1,7 +1,11 @@
package com.yunbao.common.dialog;
+import android.app.Activity;
import android.content.Context;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import androidx.annotation.NonNull;
@@ -9,12 +13,21 @@ import com.lxj.xpopup.XPopup;
import com.yunbao.common.R;
import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.bean.OpenAdModel;
+import com.yunbao.common.event.JavascriptInterfaceEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.interfaces.OnItemClickListener;
+import com.yunbao.common.manager.IMLoginManager;
+import com.yunbao.common.utils.DpUtil;
+import com.yunbao.common.utils.JavascriptInterfaceUtils;
+import com.yunbao.common.utils.L;
+import com.yunbao.common.utils.ScreenDimenUtil;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
- private ImageView mImageView;
private ImageView mClose;
+ private LinearLayout contentLayout;
private OpenAdModel model;
private OnItemClickListener mListener;
@@ -27,6 +40,11 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
@Override
public void buildDialog(XPopup.Builder builder) {
builder.animationDuration(0);
+ builder.hasShadowBg(true);
+ if(model.getPopupSort()==2){
+ builder.dismissOnTouchOutside(false);
+ builder.dismissOnBackPressed(false);
+ }
}
@Override
@@ -51,8 +69,63 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
@Override
protected void onCreate() {
super.onCreate();
- mImageView = findViewById(R.id.img);
+ contentLayout = findViewById(R.id.content_layout);
mClose = findViewById(R.id.close);
+ if (model.getPopupSort() == 1) {
+ setImage();
+ } else {
+ setWeb();
+ }
+
+ mClose.setOnClickListener(v -> dismiss());
+ if (model.getShowTime() > 0) {
+ mClose.postDelayed(this::dismiss, model.getShowTime());
+ }
+ }
+
+ private void setWeb() {
+ WebView mWebView = new WebView(mContext);
+ mWebView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
+ mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext((Activity) mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject");
+ mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
+ mWebView.getSettings().setJavaScriptEnabled(true);
+ mWebView.getSettings().setDomStorageEnabled(true);
+ String appCachePath = mContext.getCacheDir().getAbsolutePath();
+// mWebView.getSettings().setAppCachePath(appCachePath);
+ mWebView.getSettings().setAllowFileAccess(true);
+ mWebView.getSettings().setUseWideViewPort(true); // 关键点
+ mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件
+ mWebView.setHorizontalScrollBarEnabled(false);
+ mWebView.setVerticalScrollBarEnabled(false);
+ mWebView.setWebViewClient(new WebViewClient() {
+ @Override
+ public boolean shouldOverrideUrlLoading(WebView view, String url) {
+ L.e("H5-------->" + url);
+ view.loadUrl(url);
+
+ return true;
+ }
+
+ @Override
+ public void onPageFinished(WebView view, String url) {
+ }
+ });
+ String url=model.getUrl();
+ if(url.contains("?")){
+ url+="&uid="+ IMLoginManager.get(mContext).getUserInfo().getId()+"&token="+IMLoginManager.get(mContext).getUserInfo().getToken();
+ }else{
+ url+="?uid="+ IMLoginManager.get(mContext).getUserInfo().getId()+"&token="+IMLoginManager.get(mContext).getUserInfo().getToken();
+ }
+ mWebView.loadUrl(url);
+ contentLayout.addView(mWebView);
+ }
+
+ private void setImage() {
+ int width = ScreenDimenUtil.getInstance().getScreenWdith();
+ int height = (int) (width * 1.4);
+
+ ImageView mImageView = new ImageView(mContext);
+ mImageView.setLayoutParams(new LinearLayout.LayoutParams(width, height));
mImageView.setOnClickListener(v -> {
WebViewActivity.forward(mContext, model.getUrl(), model.getType() != OpenAdModel.TYPE_HOME);
if (mListener != null) {
@@ -61,10 +134,12 @@ public class OpenAdBottomDialogPopup extends AbsDialogPopupWindow {
}
dismiss();
});
- mClose.setOnClickListener(v -> dismiss());
ImgLoader.display(mContext, model.getImageUrl(), mImageView);
- if (model.getShowTime() > 0) {
- mClose.postDelayed(this::dismiss, model.getShowTime());
- }
+ contentLayout.addView(mImageView);
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
+
}
}
diff --git a/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java
index d5a0de407..046494ea8 100644
--- a/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java
+++ b/common/src/main/java/com/yunbao/common/dialog/OpenAdCenterDialogPopup.java
@@ -1,24 +1,44 @@
package com.yunbao.common.dialog;
+import android.app.Activity;
import android.content.Context;
+import android.graphics.Color;
import android.util.Log;
+import android.view.Gravity;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.view.WindowInsets;
+import android.webkit.WebResourceRequest;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import androidx.annotation.NonNull;
-import androidx.constraintlayout.widget.ConstraintLayout;
import com.lxj.xpopup.XPopup;
+import com.lzf.easyfloat.enums.ShowPattern;
import com.yunbao.common.R;
import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.bean.OpenAdModel;
+import com.yunbao.common.event.JavascriptInterfaceEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.interfaces.OnItemClickListener;
+import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DpUtil;
+import com.yunbao.common.utils.JavascriptInterfaceUtils;
+import com.yunbao.common.utils.L;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ScreenDimenUtil;
+import com.yunbao.common.utils.ToastUtil;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
private ImageView mImageView;
+ private LinearLayout contentLayout;
private ImageView mClose;
private OpenAdModel model;
private OnItemClickListener mListener;
@@ -39,7 +59,8 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
@Override
public void buildDialog(XPopup.Builder builder) {
- builder.hasShadowBg(false);
+ builder.hasShadowBg(true);
+ builder.shadowBgColor(Color.parseColor("#80000000"));
builder.animationDuration(0);
}
@@ -61,12 +82,103 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
@Override
protected void onCreate() {
super.onCreate();
- Log.e("-----弹窗-----", "onCreate: 创建弹窗" );
- mImageView = findViewById(R.id.img);
+ Log.e("-----弹窗-----", "onCreate: 创建弹窗");
+ contentLayout = findViewById(R.id.content_layout);
mClose = findViewById(R.id.close);
- findViewById(R.id.layout).setOnClickListener(v -> dismiss());
+
+
+ contentLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
+ boolean isShow = false;
+
+ @Override
+ public void onGlobalLayout() {
+ if (isShow)
+ return;
+ isShow = true;
+ int width = contentLayout.getWidth() - DpUtil.dp2px(20);
+ int height = (int) (width * 1.5);
+ if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
+ height = (int) (width * 1.2);
+ }
+ Log.i("-----弹窗-----", "高度:" + height + " 宽度:" + width + " 屏幕宽度: " + ScreenDimenUtil.getInstance().getScreenWdith());
+ /*DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
+ @Override
+ public void run(DebugDialog dialog) {
+ dialog.setShowPattern(ShowPattern.ALL_TIME);
+ dialog.show();
+ int width = contentLayout.getWidth() - DpUtil.dp2px(10);
+ int height = (int) (width * 1.5);
+ if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
+ height = (int) (width * 1.2);
+ }
+ Log.i("-----弹窗-----", "弹框debug高宽 高度:" + height + " 宽度:" + width);
+ dialog.setParams(model.getName() + "弹框高宽", "高度:" + height + " 宽度:" + width);
+ }
+ });*/
+ if (model.getPopupSort() == 1) {
+ setImage(model, width, height);
+ findViewById(R.id.layout).setOnClickListener(v -> dismiss());
+ } else {
+ setWeb(model, width, height);
+ }
+ mClose.setOnClickListener(v -> dismiss());
+ if (model.getShowTime() > 0) {
+ mClose.postDelayed(OpenAdCenterDialogPopup.this::dismiss, model.getShowTime());
+ }
+ }
+ });
+
+ }
+
+ private void setWeb(OpenAdModel model, int width, int height) {
+ WebView mWebView = new WebView(mContext);
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height);
+ params.gravity = Gravity.CENTER;
+ mWebView.setLayoutParams(params);
+ mWebView.addJavascriptInterface(JavascriptInterfaceUtils.getInstance().setmContext((Activity) mContext, mWebView).setPageClose(true).setLiveZhuangBana(false), "androidObject");
+ mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
+ mWebView.getSettings().setJavaScriptEnabled(true);
+ mWebView.getSettings().setDomStorageEnabled(true);
+ String appCachePath = mContext.getCacheDir().getAbsolutePath();
+// mWebView.getSettings().setAppCachePath(appCachePath);
+ mWebView.getSettings().setAllowFileAccess(true);
+ mWebView.getSettings().setUseWideViewPort(true); // 关键点
+ mWebView.getSettings().setAllowFileAccess(true); // 允许访问文件
+ mWebView.setHorizontalScrollBarEnabled(false);
+ mWebView.setVerticalScrollBarEnabled(false);
+ mWebView.setWebViewClient(new WebViewClient() {
+ @Override
+ public boolean shouldOverrideUrlLoading(WebView view, String url) {
+ L.e("H5-------->" + url);
+ view.loadUrl(url);
+
+ return true;
+ }
+
+ @Override
+ public void onPageFinished(WebView view, String url) {
+ }
+ });
+ String url = model.getUrl();
+ if (url.contains("?")) {
+ url += "&uid=" + IMLoginManager.get(mContext).getUserInfo().getId() + "&token=" + IMLoginManager.get(mContext).getUserInfo().getToken();
+ } else {
+ url += "?uid=" + IMLoginManager.get(mContext).getUserInfo().getId() + "&token=" + IMLoginManager.get(mContext).getUserInfo().getToken();
+ }
+ Log.i("-----弹窗-----", "setWeb: " + url);
+ mWebView.loadUrl(url);
+ contentLayout.addView(mWebView);
+ }
+
+ private void setImage(OpenAdModel model, int width, int height) {
+ mImageView = new ImageView(mContext);
+ mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height);
+ params.gravity = Gravity.CENTER;
+ mImageView.setLayoutParams(params);
+
mImageView.setOnClickListener(v -> {
- if("home_page_banner_battle".equals(model.getOriginalUrl())){
+ if ("home_page_banner_battle".equals(model.getOriginalUrl())) {
RouteUtil.forwardBattlePass();
dismiss();
return;
@@ -78,19 +190,12 @@ public class OpenAdCenterDialogPopup extends AbsDialogFullScreenPopupWindow {
}
dismiss();
});
- mClose.setOnClickListener(v -> dismiss());
ImgLoader.display(mContext, model.getImageUrl(), mImageView);
- int width = ScreenDimenUtil.getInstance().getScreenWdith() - DpUtil.dp2px(40);
- int height = (int) (width * 1.4);
- if (model.getModel() == OpenAdModel.MODEL_SQUARE) {
- height = width;
- }
- ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) mImageView.getLayoutParams();
- params.width = width;
- params.height = height;
- mImageView.setLayoutParams(params);
- if (model.getShowTime() > 0) {
- mClose.postDelayed(this::dismiss, model.getShowTime());
- }
+ contentLayout.addView(mImageView);
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
+
}
}
diff --git a/common/src/main/java/com/yunbao/common/event/SudGameSocketImEvent.java b/common/src/main/java/com/yunbao/common/event/SudGameSocketImEvent.java
index 31d9ec28e..6956f7d18 100644
--- a/common/src/main/java/com/yunbao/common/event/SudGameSocketImEvent.java
+++ b/common/src/main/java/com/yunbao/common/event/SudGameSocketImEvent.java
@@ -53,6 +53,15 @@ public class SudGameSocketImEvent extends BaseModel {
private String method;
@SerializedName("equipment")
private String equipment;
+ private String time;
+
+ public String getTime() {
+ return time;
+ }
+
+ public void setTime(String time) {
+ this.time = time;
+ }
public String getAction() {
return action;
diff --git a/common/src/main/java/com/yunbao/common/http/LiveHttpUtil.java b/common/src/main/java/com/yunbao/common/http/LiveHttpUtil.java
index 2ff045248..b52d81384 100644
--- a/common/src/main/java/com/yunbao/common/http/LiveHttpUtil.java
+++ b/common/src/main/java/com/yunbao/common/http/LiveHttpUtil.java
@@ -768,7 +768,7 @@ public class LiveHttpUtil {
* @param file 封面图片文件
* @param callback
*/
- public static void newcreateRoom(String title, int liveClassId, int type, int typeVal, File file, int clarityType, HttpCallback callback) {
+ public static void newcreateRoom(String title, int liveClassId, int type, int typeVal, File file, int clarityType,boolean isSw, HttpCallback callback) {
PostRequest request = HttpClient.getInstance().post("Live.createRoom2", LiveHttpConsts.CREATE_ROOM)
.params("title", title)
@@ -777,6 +777,7 @@ public class LiveHttpUtil {
.params("landscape", "2")
.params("class_type", "0")
.params("type_val", typeVal)
+ .params("is_shengwang",isSw?1:0)
.params("clarityType", clarityType);
if (file != null) {
request.params("file", file);
@@ -821,6 +822,15 @@ public class LiveHttpUtil {
.execute(callback);
}
+ /**
+ * 获取是否是声网开播
+ * @param callback
+ */
+ public static void getIsSw(HttpCallback callback) {
+ HttpClient.getInstance().get("Tx.setRtcFirm", "Tx.setRtcFirm")
+ .execute(callback);
+ }
+
/**
* 腾讯sdk 跟主播连麦时,获取主播的低延时流
*/
diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java
index f4b7acbaa..b4f549816 100644
--- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java
+++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java
@@ -84,6 +84,7 @@ import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.SudGameUserModel;
import com.yunbao.common.bean.SudRoomListModel;
import com.yunbao.common.bean.SudgameCodeModel;
+import com.yunbao.common.bean.SwTokenModel;
import com.yunbao.common.bean.UserAreaBean;
import com.yunbao.common.bean.UserAvatarSelectBean;
import com.yunbao.common.bean.UserBean;
@@ -230,7 +231,7 @@ public interface PDLiveApi {
);
/**
- * 关注主播
+ * 关注主播···································································
*
* @param liveuid
* @return
@@ -1376,5 +1377,6 @@ public interface PDLiveApi {
@Query("to_uid")String toUid,
@Query("payload")String payload
);
-
+ @GET("/api/public/?service=Tx.getShengwangToken")
+ Observable> getSwToken();
}
diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java
index b57535246..babc2e545 100644
--- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java
+++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java
@@ -84,6 +84,7 @@ import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.SudGameUserModel;
import com.yunbao.common.bean.SudRoomListModel;
import com.yunbao.common.bean.SudgameCodeModel;
+import com.yunbao.common.bean.SwTokenModel;
import com.yunbao.common.bean.UserAreaBean;
import com.yunbao.common.bean.UserAvatarSelectBean;
import com.yunbao.common.bean.UserBean;
@@ -3949,6 +3950,30 @@ public class LiveNetManager {
}
+ public void getSwToken( HttpCallback callback) {
+ API.get().pdLiveApi(mContext)
+ .getSwToken()
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Consumer>() {
+ @Override
+ public void accept(ResponseModel listResponseModel) throws Exception {
+ if (callback != null) {
+ callback.onSuccess(listResponseModel.getData().getInfo());
+ }
+ }
+ }, new Consumer() {
+ @Override
+ public void accept(Throwable throwable) throws Exception {
+ throwable.printStackTrace();
+ if (callback != null) {
+ callback.onError(mContext.getString(R.string.net_error));
+ }
+ }
+ }).isDisposed();
+
+ }
+
/**
* 直播间取消网络请求
*/
diff --git a/common/src/main/java/com/yunbao/common/http/main/MainNetManager.java b/common/src/main/java/com/yunbao/common/http/main/MainNetManager.java
index 38731b326..00dd5a6bc 100644
--- a/common/src/main/java/com/yunbao/common/http/main/MainNetManager.java
+++ b/common/src/main/java/com/yunbao/common/http/main/MainNetManager.java
@@ -96,27 +96,27 @@ public class MainNetManager {
}).isDisposed();
}
- /**
- * 猜你喜欢
- *
- * @param num 请求数量
- * @return
- */
- public void anchorRecommend(String num, HttpCallback httpCallback) {
- API.get().pdLiveApi(mContext).anchorRecommend(num)
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(anchorRecommendModelResponseModel -> {
- if (httpCallback != null) {
- AnchorRecommendModel model = anchorRecommendModelResponseModel.getData().getInfo();
- httpCallback.onSuccess(model);
- }
- }, throwable -> {
- if (httpCallback != null) {
- httpCallback.onError(throwable.getMessage());
- }
- }).isDisposed();
- }
+// /**
+// * 猜你喜欢
+// *
+// * @param num 请求数量
+// * @return
+// */
+// public void anchorRecommend(String num, String is_shengwang,HttpCallback httpCallback) {
+// API.get().pdLiveApi(mContext).anchorRecommend(num,is_shengwang)
+// .subscribeOn(Schedulers.io())
+// .observeOn(AndroidSchedulers.mainThread())
+// .subscribe(anchorRecommendModelResponseModel -> {
+// if (httpCallback != null) {
+// AnchorRecommendModel model = anchorRecommendModelResponseModel.getData().getInfo();
+// httpCallback.onSuccess(model);
+// }
+// }, throwable -> {
+// if (httpCallback != null) {
+// httpCallback.onError(throwable.getMessage());
+// }
+// }).isDisposed();
+// }
public void anchorRecommend(Map map, HttpCallback httpCallback) {
API.get().pdLiveApi(mContext).anchorRecommend(map)
@@ -140,11 +140,12 @@ public class MainNetManager {
* @param num 请求数量
* @return
*/
- public void anchorRecommendType(String num, HttpCallback httpCallback) {
+ public void anchorRecommendType(String num, String is_shengwang,HttpCallback httpCallback) {
Map map = new HashMap<>();
map.put("num", num);
map.put("live_recommend", "slide");
map.put("type", "1");
+ map.put(" is_shengwang", is_shengwang);
API.get().pdLiveApi(mContext).anchorRecommend(map)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
diff --git a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java
index b63c096ef..08e1c154b 100644
--- a/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java
+++ b/common/src/main/java/com/yunbao/common/manager/OpenAdManager.java
@@ -1,25 +1,34 @@
package com.yunbao.common.manager;
+import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
+import com.lzf.easyfloat.enums.ShowPattern;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.bean.OpenAdModel;
+import com.yunbao.common.dialog.DebugDialog;
import com.yunbao.common.dialog.OpenAdBottomDialogPopup;
import com.yunbao.common.dialog.OpenAdCenterDialogPopup;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
+import com.yunbao.common.interfaces.OnItemClickListener;
+import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.SpUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
+import java.lang.ref.WeakReference;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Objects;
public class OpenAdManager {
public static final int TYPE_HOME = 1;
@@ -28,19 +37,34 @@ public class OpenAdManager {
private Map showMap;
private List list = null;
private Handler handler = new Handler(Looper.getMainLooper());
- private Map runnableMap = new HashMap<>();
+ private Map runnableMap = new LinkedHashMap<>();
+ private Map waitRunnableMap = new LinkedHashMap<>();//等待运行的弹窗
private int showType;
+ private WeakReference runNowRunnable;
+ private static final boolean IS_QUEUE_SHOW = true;//是否按队列显示弹窗,true就会等待上一个弹窗关闭后弹出,false就按原逻辑顺序直接弹出
private OpenAdManager() {
showMap = new HashMap<>();
init(false);
}
- public void reset() {
+ public void close() {
dismiss();
+ clear();
+ }
+
+ public void clear() {
runnableMap.clear();
showMap.clear();
list.clear();
+ waitRunnableMap.clear();
+ list = null;
+ runNowRunnable = null;
+ }
+
+ public void reset() {
+ Log.i(TAG, "reset: ");
+ next();
}
private static final class MInstanceHolder {
@@ -55,13 +79,14 @@ public class OpenAdManager {
if (list != null && list.isEmpty()) {
return;
}
- Context context = CommonAppContext.getTopActivity();
+ Context context = AppManager.getInstance().getMainActivity();
if (context == null) {
context = CommonAppContext.sInstance;
}
if (context == null) {
return;
}
+
LiveNetManager.get(context).activityPopup(new HttpCallback>() {
@Override
public void onSuccess(List data) {
@@ -70,21 +95,34 @@ public class OpenAdManager {
list = new ArrayList<>();
return;
}
+ Collections.sort(data, new AdListComparator());
list = data;
if (isShow) {
- show(TYPE_HOME, false);
+ if (showType == 0) {
+ show(TYPE_HOME, false);
+ } else {
+ show(showType, false);
+ }
}
}
@Override
public void onError(String error) {
- System.err.println("弹框列表:" + error);
+ Log.e(TAG, "弹框列表:" + error);
}
});
}
- private static long showTime=0;
+ private static long showTime = 0;
+ private OnItemClickListener onItemClickListener=new OnItemClickListener() {
+ @Override
+ public void onItemClick(String bean, int position) {
+
+ }
+ };
+
public synchronized void show(int type, boolean isGuard) {
+ showType = type;
if(true){
//潘多拉不需要彈窗
return;
@@ -93,16 +131,32 @@ public class OpenAdManager {
init(true);
return;
}
- if(System.currentTimeMillis()-showTime<100){
+ Log.i(TAG, "show: 调用显示 " + type + " " + isGuard);
+ if (System.currentTimeMillis() - showTime < 100) {
return;
}
- showTime=System.currentTimeMillis();
- showType = type;
+ /*DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
+ @Override
+ public void run(DebugDialog dialog) {
+ dialog.setShowPattern(ShowPattern.ALL_TIME);
+ dialog.show();
+ onItemClickListener = new OnItemClickListener() {
+ @Override
+ public void onItemClick(String bean, int position) {
+ dialog.setParams(bean, "剩余:" + position);
+ }
+ };
+ }
+ });*/
+ showTime = System.currentTimeMillis();
+ waitRunnableMap.clear();
+ runnableMap.clear();
+ runNowRunnable = null;
for (OpenAdModel model : list) {
if (model.getType() == type) {
- if (type == OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)) {
+ /* if (type == OpenAdModel.TYPE_LIVE && !model.userIsPermission(isGuard)) {
continue;
- }
+ }*/
if (model.getShowModel() == OpenAdModel.SHOW_ONE) {
if (SpUtil.getInstance().getBooleanValue("open_ad_popup_" + model.getId())) {
continue;
@@ -126,13 +180,22 @@ public class OpenAdManager {
if (!isShow(model)) {
Log.i(TAG, "show: " + model);
- handler.postDelayed(new AdRunnable(model), model.getDelayShowTime());
+ if (IS_QUEUE_SHOW) {
+ waitRunnableMap.put(new AdRunnable(model), model.getDelayShowTime());
+ } else {
+ handler.postDelayed(new AdRunnable(model), model.getDelayShowTime());
+ }
} else {
Log.i(TAG, "notshow: " + model);
}
}
}
+ Log.i(TAG, "show: 循环完毕,调用next");
+ if (IS_QUEUE_SHOW) {
+ onItemClickListener.onItemClick("接口返回需要展示的弹窗数:", waitRunnableMap.size());
+ next();
+ }
Log.i(TAG, "------------------------------");
}
@@ -148,6 +211,9 @@ public class OpenAdManager {
}
}
runnableMap.clear();
+ if (runNowRunnable != null && runNowRunnable.get() != null) {
+ handler.removeCallbacks(runNowRunnable.get());
+ }
}
private synchronized boolean isShow(OpenAdModel type) {
@@ -157,11 +223,45 @@ public class OpenAdManager {
return false;
}
+ int getNowType() {
+ Activity lastActivity = AppManager.getInstance().getLastActivity();
+ if (lastActivity == null) {
+ return -1;
+ }
+ if (AppManager.getInstance().isLiveActivity()) {
+ return TYPE_LIVE;
+ } else if (AppManager.getInstance().isMainActivity()) {
+ return TYPE_HOME;
+ }
+ return -2;
+ }
+
+ void next() {
+ Log.i(TAG, "next: 剩余数" + waitRunnableMap.size());
+ if (waitRunnableMap.isEmpty()) return;
+ for (AdRunnable next : waitRunnableMap.keySet()) {
+ Log.i(TAG, "next: " + next.model);
+ if (next.model.getType() == getNowType()) {
+ Integer i = waitRunnableMap.get(next);
+ if (i == null) {
+ i = 0;
+ }
+ onItemClickListener.onItemClick("当前加载id:" + next.model.getId() + " " + next.model.getName() + " 延迟展示时间:" + i, (waitRunnableMap.size() - 1));
+ handler.postDelayed(next, i);
+ return;
+ }
+ }
+
+ }
+
private class AdRunnable implements Runnable {
OpenAdModel model;
+ AdRunnable runnable;
public AdRunnable(OpenAdModel model) {
this.model = model;
+ this.runnable = this;
+ runNowRunnable = new WeakReference<>(this);
runnableMap.put(model.getId(), this);
}
@@ -174,37 +274,101 @@ public class OpenAdManager {
Log.i(TAG, "run: " + model);
if (model == null) {
ToastUtil.showDebug("model为空");
+ if (onItemClickListener != null) {
+ onItemClickListener.onItemClick("", -2);
+ }
return;
}
if (!model.isInTime()) {
ToastUtil.showDebug("不在展示时间内:" + model.getStartTime() + "|" + model.getEndTime());
+ if (onItemClickListener != null) {
+ onItemClickListener.onItemClick("", -2);
+ }
return;
}
if (isShow(model)) {
ToastUtil.showDebug(model.getId() + "|model展示过了");
+ if (onItemClickListener != null) {
+ onItemClickListener.onItemClick("", -2);
+ }
return;
}
if (model.getType() != showType) {
+ if (onItemClickListener != null) {
+ onItemClickListener.onItemClick("", -2);
+ }
return;
}
- if(isShow(model)){
- Log.i(TAG,"展示过:"+model);
+ if (isShow(model)) {
+ Log.i(TAG, "展示过:" + model);
+ if (onItemClickListener != null) {
+ onItemClickListener.onItemClick("", -2);
+ }
return;
}
+ if (model.getType() == OpenAdModel.TYPE_HOME && !AppManager.getInstance().isMainActivity()) {
+ Log.i(TAG, "首页类型弹窗,但当前不是首页");
+ if (onItemClickListener != null) {
+ onItemClickListener.onItemClick("", -2);
+ }
+ dismiss();
+ return;
+ }
+ if (model.getType() == TYPE_LIVE && !AppManager.getInstance().isLiveActivity()) {
+ Log.i(TAG, "直播类型弹窗,但当前不是直播");
+ if (onItemClickListener != null) {
+ onItemClickListener.onItemClick("", -2);
+ }
+ dismiss();
+ return;
+ }
+
showMap.put(model.getId(), true);
if (model.getShowModel() == OpenAdModel.SHOW_DIY) {
- String nextTime= String.valueOf(System.currentTimeMillis() + (Long.parseLong(model.getSection()) * 60 * 1000));
+ String nextTime = String.valueOf(System.currentTimeMillis() + (Long.parseLong(model.getSection()) * 60 * 1000));
SpUtil.setStringValue("open_ad_popup_time_" + model.getId(), nextTime);
Log.i(TAG, "run: 下一次展示时间:"+nextTime+" | "+model.getSection());
showMap.remove(model.getId());
}
if (model.getModel() == OpenAdModel.MODEL_BOTTOM) {
- new OpenAdBottomDialogPopup(CommonAppContext.getTopActivity(), model).setListener((bean, position) -> {
+ new OpenAdBottomDialogPopup(AppManager.getInstance().getLastActivity(), model).setListener((bean, position) -> {
+ Log.i(TAG, "run: 弹框回调:" + position + " id = " + model.getId());
+ if (IS_QUEUE_SHOW) {
+ removeList(bean);
+ if (position == 0) {
+ next();
+ }
+ }
}).showDialog();
} else {
- new OpenAdCenterDialogPopup(CommonAppContext.getTopActivity(), model).setListener((bean, position) -> {
+ new OpenAdCenterDialogPopup(AppManager.getInstance().getLastActivity(), model).setListener((bean, position) -> {
+ Log.i(TAG, "run: 弹框回调:" + position + " id = " + model.getId());
+ if (IS_QUEUE_SHOW) {
+ removeList(bean);
+ if (position == 0) {
+ next();
+ }
+ }
}).showDialog();
}
}
+
+ void removeList(OpenAdModel model) {
+ Log.i(TAG, "removeList: " + model);
+ for (AdRunnable next : waitRunnableMap.keySet()) {
+ if (next.model.getId() == model.getId()) {
+ waitRunnableMap.remove(next);
+ return;
+ }
+ }
+ }
+ }
+
+ private class AdListComparator implements Comparator {
+
+ @Override
+ public int compare(OpenAdModel openAdModel, OpenAdModel t1) {
+ return openAdModel.getSort() - t1.getSort();
+ }
}
}
diff --git a/common/src/main/java/com/yunbao/common/manager/RandomPkManager.java b/common/src/main/java/com/yunbao/common/manager/RandomPkManager.java
index ebb586b0a..e0bd21378 100644
--- a/common/src/main/java/com/yunbao/common/manager/RandomPkManager.java
+++ b/common/src/main/java/com/yunbao/common/manager/RandomPkManager.java
@@ -343,7 +343,7 @@ public class RandomPkManager {
@Override
public void onError(String error) {
- ToastUtil.show(WordUtil.isNewZh()?"抱歉!出錯了!":"i \\'m sorry! An error occurred");
+ //ToastUtil.show(WordUtil.isNewZh()?"抱歉!出錯了!":"i \\'m sorry! An error occurred");
}
});
}
diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameMicManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameRyMicManager.java
similarity index 99%
rename from common/src/main/java/com/yunbao/common/manager/imrongcloud/GameMicManager.java
rename to common/src/main/java/com/yunbao/common/manager/imrongcloud/GameRyMicManager.java
index 83d0bccb2..d696513dd 100644
--- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameMicManager.java
+++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameRyMicManager.java
@@ -38,7 +38,7 @@ import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.Message;
import io.rong.message.TextMessage;
-public class GameMicManager {
+public class GameRyMicManager {
MeetingCallback mMeetingCallback = null;
private RCRTCRoom mRtcRoom = null;
private String mRoomID = "";
@@ -367,7 +367,7 @@ public class GameMicManager {
RCRTCEngine.getInstance().joinRoom("v" + roomId, roomConfig, new IRCRTCResultDataCallback() {
@Override
public void onSuccess(final RCRTCRoom rcrtcRoom) {
- GameMicManager.this.mRtcRoom = rcrtcRoom;
+ GameRyMicManager.this.mRtcRoom = rcrtcRoom;
// 注册房间回调
rcrtcRoom.registerRoomListener(roomEventsListener);
try {
diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameSwMicManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameSwMicManager.java
new file mode 100644
index 000000000..bd3cece8c
--- /dev/null
+++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameSwMicManager.java
@@ -0,0 +1,569 @@
+package com.yunbao.common.manager.imrongcloud;
+
+import android.content.Context;
+import android.text.TextUtils;
+import android.util.Log;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
+import com.yunbao.common.CommonAppContext;
+import com.yunbao.common.bean.IMLoginModel;
+import com.yunbao.common.bean.SudGameChatImModel;
+import com.yunbao.common.bean.SudGameUserModel;
+import com.yunbao.common.event.SudGameSocketImEvent;
+import com.yunbao.common.manager.IMLoginManager;
+import com.yunbao.common.utils.ToastUtil;
+import com.yunbao.common.utils.WordUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import cn.rongcloud.rtc.api.RCRTCEngine;
+import cn.rongcloud.rtc.api.RCRTCRemoteUser;
+import cn.rongcloud.rtc.api.RCRTCRoom;
+import cn.rongcloud.rtc.api.RCRTCRoomConfig;
+import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
+import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
+import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener;
+import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
+import cn.rongcloud.rtc.base.RCRTCParamsType;
+import cn.rongcloud.rtc.base.RCRTCRoomType;
+import cn.rongcloud.rtc.base.RTCErrorCode;
+import io.rong.imlib.IRongCallback;
+import io.rong.imlib.IRongCoreCallback;
+import io.rong.imlib.IRongCoreEnum;
+import io.rong.imlib.RongIMClient;
+import io.rong.imlib.chatroom.base.RongChatRoomClient;
+import io.rong.imlib.model.Conversation;
+import io.rong.imlib.model.Message;
+import io.rong.message.TextMessage;
+
+public class GameSwMicManager {
+ MeetingCallback mMeetingCallback = null;
+ private RCRTCRoom mRtcRoom = null;
+ private String mRoomID = "";
+
+ public void setmRoomID(String mRoomID) {
+ this.mRoomID = mRoomID;
+ }
+
+ private final IRCRTCRoomEventsListener roomEventsListener = new IRCRTCRoomEventsListener() {
+ /**
+ * 房间内用户发布资源
+ *
+ * @param rcrtcRemoteUser 远端用户
+ * @param list 发布的资源
+ */
+ @Override
+ public void onRemoteUserPublishResource(RCRTCRemoteUser rcrtcRemoteUser, final List list) {
+// subscribeAVStream();
+ }
+
+ @Override
+ public void onRemoteUserMuteAudio(RCRTCRemoteUser rcrtcRemoteUser, RCRTCInputStream rcrtcInputStream, boolean b) {
+
+ }
+
+ @Override
+ public void onRemoteUserMuteVideo(RCRTCRemoteUser rcrtcRemoteUser, RCRTCInputStream rcrtcInputStream, boolean b) {
+ }
+
+
+ @Override
+ public void onRemoteUserUnpublishResource(RCRTCRemoteUser rcrtcRemoteUser, List list) {
+ }
+
+ /**
+ * 用户加入房间
+ *
+ * @param rcrtcRemoteUser 远端用户
+ */
+ @Override
+ public void onUserJoined(final RCRTCRemoteUser rcrtcRemoteUser) {
+ try {
+ getView().onUserJoined(rcrtcRemoteUser);
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * 用户离开房间
+ *
+ * @param rcrtcRemoteUser 远端用户
+ */
+ @Override
+ public void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser) {
+ try {
+ getView().onUserLeft(rcrtcRemoteUser);
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onUserOffline(RCRTCRemoteUser rcrtcRemoteUser) {
+ }
+
+ @Override
+ public void onPublishLiveStreams(List list) {
+ }
+
+ @Override
+ public void onUnpublishLiveStreams(List list) {
+ }
+
+ /**
+ * 自己退出房间。 例如断网退出等
+ * @param i 状态码
+ */
+ @Override
+ public void onLeaveRoom(int i) {
+ }
+ };
+
+ protected MeetingCallback getView() {
+ if (mMeetingCallback == null) {
+ throw new IllegalStateException("view is not attached");
+ } else {
+ return mMeetingCallback;
+ }
+ }
+
+ public void attachView(MeetingCallback callback) {
+ mMeetingCallback = callback;
+ }
+
+ public void detachView() {
+ mMeetingCallback = null;
+ }
+
+ /**
+ * 主动订阅远端用户发布的流
+ * 视频流需要用户设置用于显示载体的videoview
+ */
+ public void subscribeAVStream() {
+ if (mRtcRoom == null || mRtcRoom.getRemoteUsers() == null) {
+ return;
+ }
+ final List inputStreams = new ArrayList<>();
+ for (final RCRTCRemoteUser remoteUser : mRtcRoom.getRemoteUsers()) {
+ if (remoteUser.getStreams().size() == 0) {
+ continue;
+ }
+
+ inputStreams.addAll(remoteUser.getStreams());
+
+ }
+
+ if (inputStreams.size() == 0) {
+ return;
+ }
+ mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
+ @Override
+ public void onSuccess() {
+
+
+ try {
+ getView().onSubscribeSuccess(inputStreams);
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode errorCode) {
+ try {
+ getView().onSubscribeFailed();
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+
+ public void refreshStreams(List personList) {
+
+ final List inputStreams = new ArrayList<>();
+ if(mRtcRoom!=null){
+ for (SudGameUserModel sudGameUserModel : personList) {
+ List rcrtcRemoteUsers = mRtcRoom.getRemoteUsers();
+
+ for (RCRTCRemoteUser rcrtcRemoteUser : rcrtcRemoteUsers) {
+ if (TextUtils.equals(rcrtcRemoteUser.getUserId(), String.valueOf(sudGameUserModel.getId()))) {
+ for (RCRTCInputStream rcrtcInputStream : rcrtcRemoteUser.getStreams()) {
+ rcrtcInputStream.mute(sudGameUserModel.getMicStatus() == 3);
+ }
+ inputStreams.addAll(rcrtcRemoteUser.getStreams());
+ }
+ }
+ }
+ if (inputStreams.size() == 0) {
+ return;
+ }
+ mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
+ @Override
+ public void onSuccess() {
+
+
+ try {
+ getView().onSubscribeSuccess(inputStreams);
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode errorCode) {
+ try {
+ getView().onSubscribeFailed();
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+ }
+
+ public void refreshStreams(String userID, boolean mute, int position) {
+
+ final List inputStreams = new ArrayList<>();
+
+ List rcrtcRemoteUsers = mRtcRoom.getRemoteUsers();
+
+ for (RCRTCRemoteUser rcrtcRemoteUser : rcrtcRemoteUsers) {
+ if (TextUtils.equals(rcrtcRemoteUser.getUserId(), String.valueOf(userID))) {
+ for (RCRTCInputStream rcrtcInputStream : rcrtcRemoteUser.getStreams()) {
+ rcrtcInputStream.mute(mute);
+ }
+ inputStreams.addAll(rcrtcRemoteUser.getStreams());
+ }
+ }
+ if (inputStreams.size() == 0) {
+ return;
+ }
+ mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() {
+ @Override
+ public void onSuccess() {
+ try {
+ getView().onSubscribeSuccess(userID, mute, position);
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode errorCode) {
+ try {
+ getView().onSubscribeFailed(userID);
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ public void unPublishStreams() {
+ if (mRtcRoom == null) {
+ return;
+ }
+ mRtcRoom.getLocalUser().unpublishStream(RCRTCEngine.getInstance().getDefaultAudioStream(), new IRCRTCResultCallback() {
+ @Override
+ public void onSuccess() {
+ try {
+ getView().onUnPublishStreamsSuccess();
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode errorCode) {
+ try {
+ getView().onUnPublishStreamsFailed();
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ /**
+ * 发布默认流
+ */
+ public void publishDefaultAVStream() {
+ if (mRtcRoom == null) {
+ return;
+ }
+ mRtcRoom.getLocalUser().publishStream(RCRTCEngine.getInstance().getDefaultAudioStream(), new IRCRTCResultCallback() {
+ @Override
+ public void onSuccess() {
+ try {
+ getView().onPublishSuccess();
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode rtcErrorCode) {
+ try {
+ getView().onPublishFailed();
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+
+ /**
+ * 配置rtc sdk
+ */
+ public void config(Context context) {
+
+// RCRTCConfig.Builder configBuilder = RCRTCConfig.Builder.create();
+// // 是否硬解码
+// configBuilder.enableHardwareDecoder(true);
+// // 是否硬编码
+// configBuilder.enableHardwareEncoder(true);
+//
+// // init 需结合 uninit 使用,否则有些配置无法重新初始化
+// RCRTCEngine.getInstance().unInit();
+// RCRTCEngine.getInstance().init(context, configBuilder.build());
+
+// RCRTCVideoStreamConfig.Builder videoConfigBuilder = RCRTCVideoStreamConfig.Builder.create();
+// // 设置分辨率
+// videoConfigBuilder.setVideoResolution(RCRTCParamsType.RCRTCVideoResolution.RESOLUTION_720_1280);
+// // 设置帧率
+// videoConfigBuilder.setVideoFps(RCRTCParamsType.RCRTCVideoFps.Fps_30);
+// /**
+// * 设置最小码率,可根据分辨率RCRTCVideoResolution设置
+// * {@link RCRTCParamsType.RCRTCVideoResolution)}
+// */
+// videoConfigBuilder.setMinRate(250);
+// /**
+// * 设置最大码率,可根据分辨率RCRTCVideoResolution设置
+// * {@link RCRTCParamsType.RCRTCVideoResolution)}
+// */
+// videoConfigBuilder.setMaxRate(2200);
+// RCRTCEngine.getInstance().getDefaultVideoStream().setVideoConfig(videoConfigBuilder.build());
+ //打开扬声器。
+ RCRTCEngine.getInstance().enableSpeaker(true);
+ // 启用耳返功能
+ RCRTCEngine.getInstance().getDefaultAudioStream().enableEarMonitoring(true);
+ RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(false);
+ RCRTCEngine.getInstance().getDefaultAudioStream().setAudioQuality(RCRTCParamsType.AudioQuality.MUSIC_HIGH, RCRTCParamsType.AudioScenario.MUSIC_CHATROOM);
+ }
+
+ public void joinRoom(String roomId, boolean imOff) {
+ mRoomID = roomId;
+ if (imOff) {
+
+ RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create()
+ // 根据实际场景,选择音视频直播:LIVE_AUDIO_VIDEO 或音频直播:LIVE_AUDIO
+ .setRoomType(RCRTCRoomType.MEETING)
+
+ .build();
+ RCRTCEngine.getInstance().joinRoom("v" + roomId, roomConfig, new IRCRTCResultDataCallback() {
+ @Override
+ public void onSuccess(final RCRTCRoom rcrtcRoom) {
+ GameSwMicManager.this.mRtcRoom = rcrtcRoom;
+ // 注册房间回调
+ rcrtcRoom.registerRoomListener(roomEventsListener);
+ try {
+ getView().onJoinRoomSuccess(rcrtcRoom);
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode rtcErrorCode) {
+ try {
+ getView().onJoinRoomFailed(rtcErrorCode);
+ } catch (IllegalStateException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ }
+
+ RongChatRoomClient.getInstance().joinChatRoom("v" + roomId, -1, new IRongCoreCallback.OperationCallback() {
+ @Override
+ public void onSuccess() {
+ Log.i("tx", "加入成功");
+ enterRoom();
+
+ }
+
+ @Override
+ public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
+ Log.i("tx", "加入" + "失败" + coreErrorCode);
+ if (WordUtil.isNewZh()) {
+ ToastUtil.show("網絡不佳無法連接,請重新進入");
+ } else {
+ ToastUtil.show("The network is not connected, please re-enter");
+ }
+ }
+ });
+ }
+
+ public void leaveRoom() {
+ RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
+ @Override
+ public void onFailed(RTCErrorCode rtcErrorCode) {
+ }
+
+ @Override
+ public void onSuccess() {
+ }
+ });
+ RongChatRoomClient.getInstance().quitChatRoom("v" + mRoomID, new IRongCoreCallback.OperationCallback() {
+ @Override
+ public void onSuccess() {
+ Log.i("tx", "退出成功");
+ }
+
+ @Override
+ public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
+ Log.i("tx", "退出" + "" + coreErrorCode);
+ }
+ });
+ }
+
+ String lastTime = "";
+
+ /**
+ * 处理游戏房Im消息
+ */
+ public void processingMessage(SudGameSocketImEvent socketImModel) {
+
+ List msgDTOS = socketImModel.getMsg();
+ if (msgDTOS.isEmpty()) return;
+ SudGameSocketImEvent.MsgDTO msgDTO = msgDTOS.get(0);
+
+ if(lastTime.equals(msgDTO.getTime())){
+ return;
+ }
+ lastTime = msgDTO.getTime();
+ //正常文字消息
+ if (TextUtils.equals(msgDTO.getMethod(), "SendMsg")) {
+ getView().insertItem(new SudGameChatImModel().setWelcomMessage(false).setNickname(msgDTO.getUname()).setTextMessage(msgDTO.getCt()));
+ } else if (TextUtils.equals(msgDTO.getMethod(), "welcomMessage")) {
+ // 欢迎(用户名)进入房间 Welcome (username) to the room
+
+ StringBuffer stringBuffer = new StringBuffer();
+ if (WordUtil.isNewZh()) {
+ stringBuffer.append("歡迎 ").append(msgDTO.getCt()).append(" 進入房間");
+ } else {
+ stringBuffer.append("Welcome ").append(msgDTO.getCt()).append(" to enter the room");
+ }
+
+ getView().insertItem(new SudGameChatImModel().setWelcomMessage(true).setNickname(msgDTO.getCt()).setTextMessage(stringBuffer.toString()));
+ } else if (TextUtils.equals(msgDTO.getMethod(), "sudGameRoomVoiceList")) {
+ List personList = new Gson().fromJson(msgDTO.getCt(), new TypeToken>() {
+ }.getType());
+ getView().refreshSudGameUserList(personList);
+
+ refreshStreams(personList);
+
+ }
+ }
+
+ private void sendChatMessage(String textMessage, String method) {
+ IMLoginModel loginModel = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo();
+ SudGameSocketImEvent sudGameSocketImEvent = new SudGameSocketImEvent();
+ sudGameSocketImEvent.setRetcode("000000");
+ sudGameSocketImEvent.setRetmsg("ok");
+
+ SudGameSocketImEvent.MsgDTO msgDTO = new SudGameSocketImEvent.MsgDTO();
+ msgDTO.setAction("0")
+ .setCt(textMessage)
+ .setEquipment("app")
+ .setUid(String.valueOf(loginModel.getId()))
+ .setMethod(method)
+ .setUname(loginModel.getUserNicename())
+ .setRoomnum(mRoomID);
+
+ List msgDTOS = new ArrayList<>();
+ msgDTOS.add(msgDTO);
+ sudGameSocketImEvent.setMsg(msgDTOS);
+ Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
+ TextMessage messageContent = TextMessage.obtain(new Gson().toJson(sudGameSocketImEvent));
+ Message message = Message.obtain("v" + mRoomID, conversationType, messageContent);
+ RongcloudIMManager.sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
+ @Override
+ public void onAttached(Message message) {
+
+ }
+
+ @Override
+ public void onSuccess(Message message) {
+ Log.i("tx", "发送成功");
+ String contentJson = ((TextMessage) message.getContent()).getContent();
+ Log.e("wewe", contentJson);
+ SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class);
+ sudGameSocketImEvent.getMsg().get(0).setTime("11");
+ processingMessage(sudGameSocketImEvent);
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+ Log.i("tx", "发送成功" + errorCode.toString());
+ }
+ });
+ }
+
+ /**
+ * 发送聊天信息
+ *
+ * @param textMessage
+ */
+ public void sendMessage(String textMessage) {
+ sendChatMessage(textMessage, "SendMsg");
+ }
+
+ /**
+ * 进房间
+ */
+ public void enterRoom() {
+ IMLoginModel loginModel = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo();
+ sendChatMessage(loginModel.getUserNicename(), "welcomMessage");
+ }
+
+ /**
+ * activity相关回调
+ */
+ public interface MeetingCallback {
+ void onJoinRoomSuccess(RCRTCRoom rcrtcRoom);
+
+ void onJoinRoomFailed(RTCErrorCode rtcErrorCode);
+
+ void onPublishSuccess();
+
+
+ void onPublishFailed();
+
+ void onUnPublishStreamsSuccess();
+
+ void onUnPublishStreamsFailed();
+
+ void onSubscribeSuccess(List inputStreamList);
+
+ void onSubscribeFailed();
+
+ void onSubscribeSuccess(String userID, boolean mute, int position);
+
+ void onSubscribeFailed(String userID);
+
+ void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser);
+
+ void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser);
+
+ void insertItem(SudGameChatImModel sudGameChatImModel);
+
+ void refreshSudGameUserList(List personList);
+ }
+}
diff --git a/common/src/main/java/com/yunbao/common/provider/MessageChatCardItemProvider.java b/common/src/main/java/com/yunbao/common/provider/MessageChatCardItemProvider.java
index 390a78c95..6c8962139 100644
--- a/common/src/main/java/com/yunbao/common/provider/MessageChatCardItemProvider.java
+++ b/common/src/main/java/com/yunbao/common/provider/MessageChatCardItemProvider.java
@@ -101,7 +101,7 @@ public class MessageChatCardItemProvider extends BaseMessageItemProvider-1;
+ }
+
public void removeFromParent() {
ViewParent parent = mContentView.getParent();
if (parent != null) {
diff --git a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java
index 9ad0e8686..94c0bbb84 100644
--- a/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java
+++ b/common/src/main/java/com/yunbao/common/views/CustomDrawerPopupView.java
@@ -29,6 +29,7 @@ import java.util.List;
public class CustomDrawerPopupView extends DrawerPopupView {
private Context mContext;
+ private boolean mIs_shengwang;
private RecyclerView drawerList;
private CustomDrawerPopupAdapter adapter;
@@ -45,9 +46,10 @@ public class CustomDrawerPopupView extends DrawerPopupView {
return this;
}
- public CustomDrawerPopupView(@NonNull Context context) {
+ public CustomDrawerPopupView(@NonNull Context context, boolean is_shengwang) {
super(context);
mContext = context;
+ mIs_shengwang = is_shengwang;
}
@Override
@@ -72,7 +74,7 @@ public class CustomDrawerPopupView extends DrawerPopupView {
private void initView() {
drawerList = findViewById(R.id.drawerList);
- adapter = new CustomDrawerPopupAdapter(mContext);
+ adapter = new CustomDrawerPopupAdapter(mContext,mIs_shengwang);
adapter.setList(list).setLiveId(liveId);
drawerList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
drawerList.setAdapter(adapter);
diff --git a/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java b/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java
index c87f93e08..b2c36f106 100644
--- a/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java
+++ b/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java
@@ -14,6 +14,7 @@ import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.makeramen.roundedimageview.RoundedImageView;
+import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.R;
import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.LiveBean;
@@ -106,8 +107,11 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder {
createSudRoomModel.setSudGameName(model.getSudGameName());
if (isHome) {
if (TextUtils.equals(model.getLiveUid(), "0")) {
- RouteUtil.forwardSudGameActivity(new Gson().toJson(createSudRoomModel));
-
+ if(CommonAppConfig.getInstance().getConfig().isSw()){
+ RouteUtil.forwardSwSudGameActivity(new Gson().toJson(createSudRoomModel),true,isHome);
+ }else{
+ RouteUtil.forwardRySudGameActivity(new Gson().toJson(createSudRoomModel),true,isHome);
+ }
} else {
String yes = "是";
if (IMLoginManager.get(itemView.getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
@@ -131,8 +135,8 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(itemView.getContext(), liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
@@ -155,8 +159,11 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder {
@Override
public void onCancel() {
-
- RouteUtil.forwardSudGameActivity(new Gson().toJson(createSudRoomModel));
+ if(CommonAppConfig.getInstance().getConfig().isSw()){
+ RouteUtil.forwardSwSudGameActivity(new Gson().toJson(createSudRoomModel),true,isHome);
+ }else{
+ RouteUtil.forwardRySudGameActivity(new Gson().toJson(createSudRoomModel),true,isHome);
+ }
}
})).show();
diff --git a/main/src/main/res/drawable/border_f1f1f1.xml b/common/src/main/res/drawable/border_f1f1f1.xml
similarity index 100%
rename from main/src/main/res/drawable/border_f1f1f1.xml
rename to common/src/main/res/drawable/border_f1f1f1.xml
diff --git a/common/src/main/res/layout/dialog_open_bottom_ad.xml b/common/src/main/res/layout/dialog_open_bottom_ad.xml
index 192f2d295..07cbd6f4f 100644
--- a/common/src/main/res/layout/dialog_open_bottom_ad.xml
+++ b/common/src/main/res/layout/dialog_open_bottom_ad.xml
@@ -5,16 +5,19 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
-
+ app:srcCompat="@mipmap/background_gift_wall">
+
+
+
+
diff --git a/common/src/main/res/layout/dialog_open_center_ad.xml b/common/src/main/res/layout/dialog_open_center_ad.xml
index dd60e83a6..8e078bb5d 100644
--- a/common/src/main/res/layout/dialog_open_center_ad.xml
+++ b/common/src/main/res/layout/dialog_open_center_ad.xml
@@ -6,26 +6,28 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+
+
+
\ No newline at end of file
diff --git a/common/src/main/res/layout/view_flaot_live.xml b/common/src/main/res/layout/view_flaot_live.xml
index 5b1d2d4db..715547e35 100644
--- a/common/src/main/res/layout/view_flaot_live.xml
+++ b/common/src/main/res/layout/view_flaot_live.xml
@@ -25,6 +25,12 @@
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
+
+
+
diff --git a/live/src/main/res/mipmap-xxxhdpi/bg_kirin.png b/common/src/main/res/mipmap-xxxhdpi/bg_kirin.png
similarity index 100%
rename from live/src/main/res/mipmap-xxxhdpi/bg_kirin.png
rename to common/src/main/res/mipmap-xxxhdpi/bg_kirin.png
diff --git a/live/src/main/res/mipmap-xxxhdpi/icon_more_live_menu.png b/common/src/main/res/mipmap-xxxhdpi/icon_more_live_menu.png
similarity index 100%
rename from live/src/main/res/mipmap-xxxhdpi/icon_more_live_menu.png
rename to common/src/main/res/mipmap-xxxhdpi/icon_more_live_menu.png
diff --git a/common/src/main/res/values-zh-rHK/strings.xml b/common/src/main/res/values-zh-rHK/strings.xml
index 7e5719bef..01320d02b 100644
--- a/common/src/main/res/values-zh-rHK/strings.xml
+++ b/common/src/main/res/values-zh-rHK/strings.xml
@@ -1547,5 +1547,6 @@
2.用戶關注主播並參與活動,將在倒計時五分鐘結束後瓜分活動金豆;
3.此活動的最終解釋權歸PDLIVE所有。
短劇
+ 主播正在PK,稍後再試
您將花費%s鑽石,為主播開通
diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml
index 2b88b006d..cc243dfa7 100644
--- a/common/src/main/res/values-zh-rTW/strings.xml
+++ b/common/src/main/res/values-zh-rTW/strings.xml
@@ -1547,5 +1547,6 @@
2.用戶關注主播並參與活動,將在倒計時五分鐘結束後瓜分活動金豆;
3.此活動的最終解釋權歸PDLIVE所有。
短劇
+ 主播正在PK,稍後再試
您將花費%s鑽石,為主播開通
diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml
index 66abfaf6d..c1043b2fa 100644
--- a/common/src/main/res/values-zh/strings.xml
+++ b/common/src/main/res/values-zh/strings.xml
@@ -1545,5 +1545,6 @@
2.用戶關注主播並參與活動,將在倒計時五分鐘結束後瓜分活動金豆;
3.此活動的最終解釋權歸PDLIVE所有。
短劇
+ 主播正在PK,稍後再試
您將花費%s鑽石,為主播開通
diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml
index 1f0e04f1c..fe08a0498 100644
--- a/common/src/main/res/values/strings.xml
+++ b/common/src/main/res/values/strings.xml
@@ -1570,4 +1570,5 @@ Limited ride And limited avatar frame
2.Users who follow the anchor and participate in the activity will divide the gold beans of the activity after the countdown of five minutes ends;
3.The final interpretation of this activity belongs to PDLIVE.
Theater
+ The anchor is in PK, please try again later
diff --git a/config.gradle b/config.gradle
index 00d103a4d..7a5b821e4 100644
--- a/config.gradle
+++ b/config.gradle
@@ -4,25 +4,28 @@ ext {
buildToolsVersion: "29.0.2",
minSdkVersion : 23,
targetSdkVersion : 33,
- versionCode : 526,
+ versionCode : 676,
versionName : "6.6.9",
namespace : "com.pandoralive.shayu"
]
manifestPlaceholders = [
//正式、
- serverHost : "https://napi.yaoulive.com",
+// serverHost : "https://napi.yaoulive.com",
// 测试
-// serverHost : " https://ceshi.yaoulive.com",
+ serverHost : " https://ceshi.yaoulive.com",
buildTime : new Date().format("MM-dd HH:mm", TimeZone.getTimeZone("GMT+8")),
//百度语音识别
+
+ swReleaseModel : false, //true声网正式服 false测试服
+
baiduAppId : "23774720",
baiduAppKey : "zgCgFhUKEOV7I3ZXDFpTfnRB",
baiduAppSecretKey: "nEVSgmuGpU0pjPr6VleEGGAl0hzGW52S",
// true表示谷歌支付 false
// isGooglePlay : false,
-// true表示谷歌支付 false 0 链接包 1 谷歌包 2华为包
+// true表示谷歌支付 false 0 链接包(isPluginModel-> true) 1 谷歌包 2华为包 3 samsung包
isGooglePlay : 0,
//是否上报异常日志
diff --git a/gradle.properties b/gradle.properties
index 5547a2720..c41a7a913 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -24,6 +24,6 @@ android.nonTransitiveRClass=false
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
-systemProp.https.proxyPort=10809
-systemProp.http.proxyPort=10809
+systemProp.https.proxyPort=7890
+systemProp.http.proxyPort=7890
#android.enableR8.fullMode=true
\ No newline at end of file
diff --git a/lib_faceunity/.gitignore b/lib_faceunity/.gitignore
new file mode 100644
index 000000000..bcc2eb0f5
--- /dev/null
+++ b/lib_faceunity/.gitignore
@@ -0,0 +1,4 @@
+/build
+/src/main/assets/makeup
+/src/main/assets/sticker
+authpack.java
\ No newline at end of file
diff --git a/lib_faceunity/build.gradle b/lib_faceunity/build.gradle
new file mode 100644
index 000000000..e35bb80a7
--- /dev/null
+++ b/lib_faceunity/build.gradle
@@ -0,0 +1,80 @@
+apply plugin: 'com.android.library'
+apply plugin: 'maven-publish'
+apply plugin: 'kotlin-android'
+
+android {
+ namespace "com.yunbao.swfaceunity"
+ compileSdkVersion 31
+ buildToolsVersion "30.0.3"
+
+ defaultConfig {
+ minSdkVersion 21
+ targetSdkVersion 31
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+ kotlinOptions {
+ jvmTarget = '1.8'
+ }
+}
+
+dependencies {
+
+ testImplementation 'junit:junit:4.13.2'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+ if (new File("$AGORA_RTC_SDK").exists()) {
+ api fileTree(dir: "${AGORA_RTC_SDK}", include: ['*.jar', '*.aar'])
+ } else {
+ api "$AGORA_RTC_SDK"
+ }
+ api project(path: ':FaceUnity')
+}
+
+// Because the components are created only during the afterEvaluate phase, you must
+// configure your publications using the afterEvaluate() lifecycle method.
+afterEvaluate {
+ publishing {
+ publications {
+ // Creates a Maven publication called "release".
+ release(MavenPublication) {
+ // Applies the component for the release build variant.
+ from components.release
+
+ // You can then customize attributes of the publication as shown below.
+ groupId = 'com.github.AgoraIO-Community.BeautyAPI'
+ artifactId = 'FaceUnity'
+ version = "$LIB_VERSION"
+ }
+ // Creates a Maven publication called “debug”.
+ debug(MavenPublication) {
+ // Applies the component for the debug build variant.
+ from components.debug
+
+ groupId = 'com.github.AgoraIO-Community.BeautyAPI'
+ artifactId = 'FaceUnity'
+ version = "$LIB_VERSION"
+ }
+ }
+ if(IS_PUBLISH_LOCAL){
+ repositories {
+ maven {
+ url = "file://${rootProject.projectDir.path}/maven"
+ println("maven publish to ${url}")
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/lib_faceunity/consumer-rules.pro b/lib_faceunity/consumer-rules.pro
new file mode 100644
index 000000000..e69de29bb
diff --git a/lib_faceunity/proguard-rules.pro b/lib_faceunity/proguard-rules.pro
new file mode 100644
index 000000000..481bb4348
--- /dev/null
+++ b/lib_faceunity/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/lib_faceunity/src/main/AndroidManifest.xml b/lib_faceunity/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..7b0c8da7c
--- /dev/null
+++ b/lib_faceunity/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/FaceUnityBeautyAPI.kt b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/FaceUnityBeautyAPI.kt
new file mode 100644
index 000000000..1058ea229
--- /dev/null
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/FaceUnityBeautyAPI.kt
@@ -0,0 +1,179 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2023 Agora Community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package io.agora.beautyapi.faceunity
+
+import android.content.Context
+import android.view.View
+import com.faceunity.core.faceunity.FURenderKit
+import io.agora.base.VideoFrame
+import io.agora.rtc2.Constants
+import io.agora.rtc2.RtcEngine
+
+const val VERSION = "1.0.6"
+
+enum class CaptureMode{
+ Agora, // 使用声网内部的祼数据接口进行处理
+ Custom // 自定义模式,需要自己调用onFrame接口将原始视频帧传给BeautyAPI做处理
+}
+
+interface IEventCallback{
+
+ /**
+ * 统计数据回调,每处理完一帧后会回调一次
+ *
+ * @param stats 美颜统计数据
+ */
+ fun onBeautyStats(stats: BeautyStats)
+}
+
+data class BeautyStats(
+ val minCostMs:Long, // 统计区间内的最小值
+ val maxCostMs: Long, // 统计区间内的最大值
+ val averageCostMs: Long // 统计区间内的平均值
+)
+
+enum class MirrorMode {
+
+ // 没有镜像正常画面的定义:前置拍到画面和手机看到画面是左右不一致的,后置拍到画面和手机看到画面是左右一致的
+
+ MIRROR_LOCAL_REMOTE, //本地远端都镜像,前置默认,本地和远端贴纸都正常
+ MIRROR_LOCAL_ONLY, // 仅本地镜像,远端不镜像,,远端贴纸正常,本地贴纸镜像。用于打电话场景,电商直播场景(保证电商直播后面的告示牌文字是正的);这种模式因为本地远端是反的,所以肯定有一边的文字贴纸方向会是反的
+ MIRROR_REMOTE_ONLY, // 仅远端镜像,本地不镜像,远端贴纸正常,本地贴纸镜像
+ MIRROR_NONE // 本地远端都不镜像,后置默认,本地和远端贴纸都正常
+}
+
+data class CameraConfig(
+ val frontMirror: MirrorMode = MirrorMode.MIRROR_LOCAL_REMOTE, // 前置默认镜像:本地远端都镜像
+ val backMirror: MirrorMode = MirrorMode.MIRROR_NONE // 后置默认镜像:本地远端都不镜像
+)
+
+data class Config(
+ val context: Context, // Android Context 上下文
+ val rtcEngine: RtcEngine, // 声网Rtc引擎
+ val fuRenderKit: FURenderKit, // 美颜SDK处理句柄
+ val eventCallback: IEventCallback? = null, // 事件回调
+ val captureMode: CaptureMode = CaptureMode.Agora, // 处理模式
+ val statsDuration: Long = 1000, // 统计区间
+ val statsEnable: Boolean = false, // 是否开启统计
+ val cameraConfig: CameraConfig = CameraConfig() // 摄像头镜像配置
+)
+
+enum class ErrorCode(val value: Int) {
+ ERROR_OK(0), // 一切正常
+ ERROR_HAS_NOT_INITIALIZED(101), // 没有调用Initialize或调用失败情况下调用了其他API
+ ERROR_HAS_INITIALIZED(102), // 已经Initialize成功后再次调用报错
+ ERROR_HAS_RELEASED(103), // 已经调用release销毁后还调用其他API
+ ERROR_PROCESS_NOT_CUSTOM(104), // 非Custom处理模式下调用onFrame接口从外部传入视频帧
+ ERROR_VIEW_TYPE_ERROR(105), // 当调用setupLocalVideo时view类型错误时返回
+ ERROR_FRAME_SKIPPED(106), // 当处理帧忽略时在onFrame返回
+}
+
+enum class BeautyPreset {
+ CUSTOM, // 不使用推荐的美颜参数
+ DEFAULT // 默认的
+}
+
+fun createFaceUnityBeautyAPI(): FaceUnityBeautyAPI = FaceUnityBeautyAPIImpl()
+
+interface FaceUnityBeautyAPI {
+
+ /**
+ * 初始化API
+ *
+ * @param config 配置参数
+ * @return 见ErrorCode
+ */
+ fun initialize(config: Config): Int
+
+ /**
+ * 开启/关闭美颜
+ *
+ * @param enable true:开启; false: 关闭
+ * @return 见ErrorCode
+ */
+ fun enable(enable: Boolean): Int
+
+ /**
+ * 本地视图渲染,由内部来处理镜像问题
+ *
+ * @param view SurfaceView或TextureView
+ * @param renderMode 渲染缩放模式
+ * @return 见ErrorCode
+ */
+ fun setupLocalVideo(view: View, renderMode: Int = Constants.RENDER_MODE_HIDDEN): Int
+
+ /**
+ * 当ProcessMode==Custom时由外部传入原始视频帧
+ *
+ * @param videoFrame 原始视频帧
+ * @return 见ErrorCode
+ */
+ fun onFrame(videoFrame: VideoFrame): Int
+
+ /**
+ * 声网提供的美颜最佳默认参数
+ *
+ * @return 见ErrorCode
+ */
+ fun setBeautyPreset(preset: BeautyPreset = BeautyPreset.DEFAULT): Int
+
+ /**
+ * 更新摄像头配置
+ */
+ fun updateCameraConfig(config: CameraConfig): Int
+
+ /**
+ * 是否是前置摄像头
+ * PS:只在美颜处理中才能知道准确的值,否则会一直是true
+ */
+ fun isFrontCamera(): Boolean
+
+ /**
+ * 获取镜像状态
+ *
+ * @return 镜像状态,true: 镜像,false:非镜像
+ */
+ fun getMirrorApplied(): Boolean
+
+ /**
+ * 在处理线程里执行操作
+ *
+ * @param run 操作run
+ */
+ fun runOnProcessThread(run: ()->Unit)
+
+ /**
+ * 私参配置,用于不对外api的调用,多用于测试
+ */
+ fun setParameters(key: String, value: String)
+
+ /**
+ * 释放资源,一旦释放后这个实例将无法使用
+ *
+ * @return 见ErrorCode
+ */
+ fun release(): Int
+
+}
\ No newline at end of file
diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/FaceUnityBeautyAPIImpl.kt b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/FaceUnityBeautyAPIImpl.kt
new file mode 100644
index 000000000..5c17a503d
--- /dev/null
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/FaceUnityBeautyAPIImpl.kt
@@ -0,0 +1,818 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2023 Agora Community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package io.agora.beautyapi.faceunity
+
+import android.graphics.Matrix
+import android.opengl.GLES11Ext
+import android.opengl.GLES20
+import android.view.SurfaceView
+import android.view.TextureView
+import android.view.View
+import com.faceunity.core.entity.FUBundleData
+import com.faceunity.core.entity.FURenderInputData
+import com.faceunity.core.enumeration.CameraFacingEnum
+import com.faceunity.core.enumeration.FUInputBufferEnum
+import com.faceunity.core.enumeration.FUInputTextureEnum
+import com.faceunity.core.enumeration.FUTransformMatrixEnum
+import com.faceunity.core.faceunity.FUAIKit
+import com.faceunity.core.faceunity.FURenderKit
+import com.faceunity.core.model.facebeauty.FaceBeauty
+import com.faceunity.core.model.facebeauty.FaceBeautyFilterEnum
+import io.agora.base.TextureBufferHelper
+import io.agora.base.VideoFrame
+import io.agora.base.VideoFrame.I420Buffer
+import io.agora.base.VideoFrame.SourceType
+import io.agora.base.VideoFrame.TextureBuffer
+import io.agora.base.internal.video.EglBase
+import io.agora.base.internal.video.YuvHelper
+import io.agora.beautyapi.faceunity.utils.FuDeviceUtils
+import io.agora.beautyapi.faceunity.utils.LogUtils
+import io.agora.beautyapi.faceunity.utils.StatsHelper
+import io.agora.beautyapi.faceunity.utils.egl.GLFrameBuffer
+import io.agora.beautyapi.faceunity.utils.egl.TextureProcessHelper
+import io.agora.rtc2.Constants
+import io.agora.rtc2.gl.EglBaseProvider
+import io.agora.rtc2.video.IVideoFrameObserver
+import io.agora.rtc2.video.VideoCanvas
+import java.io.File
+import java.nio.ByteBuffer
+import java.util.Collections
+import java.util.concurrent.Callable
+
+class FaceUnityBeautyAPIImpl : FaceUnityBeautyAPI, IVideoFrameObserver {
+ private val TAG = "FaceUnityBeautyAPIImpl"
+ private val reportId = "scenarioAPI"
+ private val reportCategory = "beauty_android_$VERSION"
+ private var beautyMode = 0 // 0: 自动根据buffer类型切换,1:固定使用OES纹理,2:固定使用i420,3: 单纹理模式
+ private var enableTextureAsync = true // 是否开启纹理+异步缓存处理,不支持在预览中实时切换。对于GPU性能好的手机可以减小美颜处理耗时,对于中端机开启后效果也不明显。
+
+ private var textureBufferHelper: TextureBufferHelper? = null
+ private var wrapTextureBufferHelper: TextureBufferHelper? = null
+ private var byteBuffer: ByteBuffer? = null
+ private var byteArray: ByteArray? = null
+ private var config: Config? = null
+ private var enable: Boolean = false
+ private var enableChange: Boolean = false
+ private var isReleased: Boolean = false
+ private var captureMirror = false
+ private var renderMirror = false
+ private val identityMatrix = Matrix()
+ private var mTextureProcessHelper: TextureProcessHelper? = null
+ private var statsHelper: StatsHelper? = null
+ private var skipFrame = 0
+ private enum class ProcessSourceType{
+ UNKNOWN,
+ TEXTURE_OES_ASYNC,
+ TEXTURE_2D_ASYNC,
+ TEXTURE_OES,
+ TEXTURE_2D,
+ I420
+ }
+ private var currProcessSourceType = ProcessSourceType.UNKNOWN
+ private var deviceLevel = FuDeviceUtils.DEVICEINFO_UNKNOWN
+ private var isFrontCamera = true
+ private var cameraConfig = CameraConfig()
+ private var localVideoRenderMode = Constants.RENDER_MODE_HIDDEN
+ private val pendingProcessRunList = Collections.synchronizedList(mutableListOf<()->Unit>())
+ private val transformGLFrameBuffer = GLFrameBuffer()
+
+ override fun initialize(config: Config): Int {
+ if (this.config != null) {
+ LogUtils.e(TAG, "initialize >> The beauty api has been initialized!")
+ return ErrorCode.ERROR_HAS_INITIALIZED.value
+ }
+ this.config = config
+ this.cameraConfig = config.cameraConfig
+ if (config.captureMode == CaptureMode.Agora) {
+ config.rtcEngine.registerVideoFrameObserver(this)
+ }
+ statsHelper = StatsHelper(config.statsDuration){
+ this.config?.eventCallback?.onBeautyStats(it)
+ }
+ LogUtils.i(TAG, "initialize >> config = $config")
+ LogUtils.i(TAG, "initialize >> beauty api version=$VERSION, beauty sdk version=${FURenderKit.getInstance().getVersion()}")
+
+ // config face beauty
+ if (deviceLevel == FuDeviceUtils.DEVICEINFO_UNKNOWN) {
+ deviceLevel = FuDeviceUtils.judgeDeviceLevel(config.context)
+ FUAIKit.getInstance().faceProcessorSetFaceLandmarkQuality(deviceLevel)
+ if (deviceLevel > FuDeviceUtils.DEVICE_LEVEL_MID) {
+ FUAIKit.getInstance().fuFaceProcessorSetDetectSmallFace(true)
+ }
+ }
+ LogUtils.i(TAG, "initialize >> FuDeviceUtils deviceLevel=$deviceLevel")
+ config.rtcEngine.sendCustomReportMessage(reportId, reportCategory, "initialize", "config=$config, deviceLevel=$deviceLevel", 0)
+ return ErrorCode.ERROR_OK.value
+ }
+
+ override fun enable(enable: Boolean): Int {
+ LogUtils.i(TAG, "enable >> enable = $enable")
+ if (config == null) {
+ LogUtils.e(TAG, "enable >> The beauty api has not been initialized!")
+ return ErrorCode.ERROR_HAS_NOT_INITIALIZED.value
+ }
+ if (isReleased) {
+ LogUtils.e(TAG, "enable >> The beauty api has been released!")
+ return ErrorCode.ERROR_HAS_RELEASED.value
+ }
+ if(config?.captureMode == CaptureMode.Custom){
+ skipFrame = 2
+ LogUtils.i(TAG, "enable >> skipFrame = $skipFrame")
+ }
+ config?.rtcEngine?.sendCustomReportMessage(reportId, reportCategory, "enable", "enable=$enable", 0)
+
+ if(this.enable != enable){
+ this.enable = enable
+ enableChange = true
+ LogUtils.i(TAG, "enable >> enableChange")
+ }
+ return ErrorCode.ERROR_OK.value
+ }
+
+ override fun setupLocalVideo(view: View, renderMode: Int): Int {
+ val rtcEngine = config?.rtcEngine
+ if(rtcEngine == null){
+ LogUtils.e(TAG, "setupLocalVideo >> The beauty api has not been initialized!")
+ return ErrorCode.ERROR_HAS_NOT_INITIALIZED.value
+ }
+ LogUtils.i(TAG, "setupLocalVideo >> view=$view, renderMode=$renderMode")
+ localVideoRenderMode = renderMode
+ rtcEngine.sendCustomReportMessage(reportId, reportCategory, "enable", "view=$view, renderMode=$renderMode", 0)
+ if (view is TextureView || view is SurfaceView) {
+ val canvas = VideoCanvas(view, renderMode, 0)
+ canvas.mirrorMode = Constants.VIDEO_MIRROR_MODE_DISABLED
+ rtcEngine.setupLocalVideo(canvas)
+ return ErrorCode.ERROR_OK.value
+ }
+ return ErrorCode.ERROR_VIEW_TYPE_ERROR.value
+ }
+
+ override fun onFrame(videoFrame: VideoFrame): Int {
+ val conf = config
+ if(conf == null){
+ LogUtils.e(TAG, "onFrame >> The beauty api has not been initialized!")
+ return ErrorCode.ERROR_HAS_NOT_INITIALIZED.value
+ }
+ if (isReleased) {
+ LogUtils.e(TAG, "onFrame >> The beauty api has been released!")
+ return ErrorCode.ERROR_HAS_RELEASED.value
+ }
+ if (conf.captureMode != CaptureMode.Custom) {
+ LogUtils.e(TAG, "onFrame >> The capture mode is not Custom!")
+ return ErrorCode.ERROR_PROCESS_NOT_CUSTOM.value
+ }
+ if (processBeauty(videoFrame)) {
+ return ErrorCode.ERROR_OK.value
+ }
+ LogUtils.i(TAG, "onFrame >> Skip Frame.")
+ return ErrorCode.ERROR_FRAME_SKIPPED.value
+ }
+
+ override fun updateCameraConfig(config: CameraConfig): Int {
+ LogUtils.i(TAG, "updateCameraConfig >> oldCameraConfig=$cameraConfig, newCameraConfig=$config")
+ cameraConfig = CameraConfig(config.frontMirror, config.backMirror)
+ this.config?.rtcEngine?.sendCustomReportMessage(reportId, reportCategory, "updateCameraConfig", "config=$config", 0)
+
+ return ErrorCode.ERROR_OK.value
+ }
+
+ override fun runOnProcessThread(run: () -> Unit) {
+ if (config == null) {
+ LogUtils.e(TAG, "runOnProcessThread >> The beauty api has not been initialized!")
+ return
+ }
+ if (isReleased) {
+ LogUtils.e(TAG, "runOnProcessThread >> The beauty api has been released!")
+ return
+ }
+ if (textureBufferHelper?.handler?.looper?.thread == Thread.currentThread()) {
+ run.invoke()
+ } else if (textureBufferHelper != null) {
+ textureBufferHelper?.handler?.post(run)
+ } else {
+ pendingProcessRunList.add(run)
+ }
+ }
+
+ override fun isFrontCamera() = isFrontCamera
+
+ override fun setParameters(key: String, value: String) {
+ when(key){
+ "beauty_mode" -> beautyMode = value.toInt()
+ "enableTextureAsync" -> enableTextureAsync = value.toBoolean()
+ }
+ }
+
+ override fun setBeautyPreset(preset: BeautyPreset): Int {
+ val conf = config
+ if(conf == null){
+ LogUtils.e(TAG, "setBeautyPreset >> The beauty api has not been initialized!")
+ return ErrorCode.ERROR_HAS_NOT_INITIALIZED.value
+ }
+ if (isReleased) {
+ LogUtils.e(TAG, "setBeautyPreset >> The beauty api has been released!")
+ return ErrorCode.ERROR_HAS_RELEASED.value
+ }
+
+ LogUtils.i(TAG, "setBeautyPreset >> preset = $preset")
+ config?.rtcEngine?.sendCustomReportMessage(reportId, reportCategory, "enable", "preset=$preset", 0)
+
+ val recommendFaceBeauty = FaceBeauty(FUBundleData("graphics" + File.separator + "face_beautification.bundle"))
+ if (preset == BeautyPreset.DEFAULT) {
+ recommendFaceBeauty.filterName = FaceBeautyFilterEnum.FENNEN_1
+ recommendFaceBeauty.filterIntensity = 0.7
+ // 美牙
+ recommendFaceBeauty.toothIntensity = 0.3
+ // 亮眼
+ recommendFaceBeauty.eyeBrightIntensity = 0.3
+ // 大眼
+ recommendFaceBeauty.eyeEnlargingIntensity = 0.5
+ // 红润
+ recommendFaceBeauty.redIntensity = 0.5 * 2
+ // 美白
+ recommendFaceBeauty.colorIntensity = 0.75 * 2
+ // 磨皮
+ recommendFaceBeauty.blurIntensity = 0.75 * 6
+ if (deviceLevel > FuDeviceUtils.DEVICE_LEVEL_MID) {
+ val score = FUAIKit.getInstance().getFaceProcessorGetConfidenceScore(0)
+ if (score > 0.95) {
+ recommendFaceBeauty.blurType = 3
+ recommendFaceBeauty.enableBlurUseMask = true
+ } else {
+ recommendFaceBeauty.blurType = 2
+ recommendFaceBeauty.enableBlurUseMask = false
+ }
+ } else {
+ recommendFaceBeauty.blurType = 2
+ recommendFaceBeauty.enableBlurUseMask = false
+ }
+ // 嘴型
+ recommendFaceBeauty.mouthIntensity = 0.3
+ // 瘦鼻
+ recommendFaceBeauty.noseIntensity = 0.1
+ // 额头
+ recommendFaceBeauty.forHeadIntensity = 0.3
+ // 下巴
+ recommendFaceBeauty.chinIntensity = 0.0
+ // 瘦脸
+ recommendFaceBeauty.cheekThinningIntensity = 0.3
+ // 窄脸
+ recommendFaceBeauty.cheekNarrowIntensity = 0.0
+ // 小脸
+ recommendFaceBeauty.cheekSmallIntensity = 0.0
+ // v脸
+ recommendFaceBeauty.cheekVIntensity = 0.0
+ }
+ conf.fuRenderKit.faceBeauty = recommendFaceBeauty
+ return ErrorCode.ERROR_OK.value
+ }
+
+ override fun release(): Int {
+ val conf = config
+ val fuRenderer = conf?.fuRenderKit
+ if(fuRenderer == null){
+ LogUtils.e(TAG, "release >> The beauty api has not been initialized!")
+ return ErrorCode.ERROR_HAS_NOT_INITIALIZED.value
+ }
+ if (isReleased) {
+ LogUtils.e(TAG, "setBeautyPreset >> The beauty api has been released!")
+ return ErrorCode.ERROR_HAS_RELEASED.value
+ }
+ LogUtils.i(TAG, "release")
+ if (conf.captureMode == CaptureMode.Agora) {
+ conf.rtcEngine.registerVideoFrameObserver(null)
+ }
+ conf.rtcEngine.sendCustomReportMessage(reportId, reportCategory, "release", "", 0)
+
+ isReleased = true
+ textureBufferHelper?.let {
+ textureBufferHelper = null
+ it.handler.removeCallbacksAndMessages(null)
+ it.invoke {
+ fuRenderer.release()
+ mTextureProcessHelper?.release()
+ mTextureProcessHelper = null
+ transformGLFrameBuffer.release()
+ null
+ }
+ // it.handler.looper.quit()
+ it.dispose()
+ }
+ wrapTextureBufferHelper?.let {
+ wrapTextureBufferHelper = null
+ it.dispose()
+ }
+ statsHelper?.reset()
+ statsHelper = null
+ pendingProcessRunList.clear()
+ return ErrorCode.ERROR_OK.value
+ }
+
+ private fun processBeauty(videoFrame: VideoFrame): Boolean {
+ if (isReleased) {
+ LogUtils.e(TAG, "processBeauty >> The beauty api has been released!")
+ return false
+ }
+
+ val cMirror =
+ if (isFrontCamera) {
+ when (cameraConfig.frontMirror) {
+ MirrorMode.MIRROR_LOCAL_REMOTE -> true
+ MirrorMode.MIRROR_LOCAL_ONLY -> false
+ MirrorMode.MIRROR_REMOTE_ONLY -> true
+ MirrorMode.MIRROR_NONE -> false
+ }
+ } else {
+ when (cameraConfig.backMirror) {
+ MirrorMode.MIRROR_LOCAL_REMOTE -> true
+ MirrorMode.MIRROR_LOCAL_ONLY -> false
+ MirrorMode.MIRROR_REMOTE_ONLY -> true
+ MirrorMode.MIRROR_NONE -> false
+ }
+ }
+ val rMirror =
+ if (isFrontCamera) {
+ when (cameraConfig.frontMirror) {
+ MirrorMode.MIRROR_LOCAL_REMOTE -> false
+ MirrorMode.MIRROR_LOCAL_ONLY -> true
+ MirrorMode.MIRROR_REMOTE_ONLY -> true
+ MirrorMode.MIRROR_NONE -> false
+ }
+ } else {
+ when (cameraConfig.backMirror) {
+ MirrorMode.MIRROR_LOCAL_REMOTE -> false
+ MirrorMode.MIRROR_LOCAL_ONLY -> true
+ MirrorMode.MIRROR_REMOTE_ONLY -> true
+ MirrorMode.MIRROR_NONE -> false
+ }
+ }
+ if (captureMirror != cMirror || renderMirror != rMirror) {
+ LogUtils.w(TAG, "processBeauty >> enable=$enable, captureMirror=$captureMirror->$cMirror, renderMirror=$renderMirror->$rMirror")
+ captureMirror = cMirror
+ if(renderMirror != rMirror){
+ renderMirror = rMirror
+ config?.rtcEngine?.setLocalRenderMode(
+ localVideoRenderMode,
+ if(renderMirror) Constants.VIDEO_MIRROR_MODE_ENABLED else Constants.VIDEO_MIRROR_MODE_DISABLED
+ )
+ }
+ textureBufferHelper?.invoke {
+ mTextureProcessHelper?.reset()
+ }
+ skipFrame = 2
+ return false
+ }
+
+ val oldIsFrontCamera = isFrontCamera
+ isFrontCamera = videoFrame.sourceType == SourceType.kFrontCamera
+ if(oldIsFrontCamera != isFrontCamera){
+ LogUtils.w(TAG, "processBeauty >> oldIsFrontCamera=$oldIsFrontCamera, isFrontCamera=$isFrontCamera")
+ return false
+ }
+
+ if(enableChange){
+ enableChange = false
+ textureBufferHelper?.invoke {
+ mTextureProcessHelper?.reset()
+ }
+ return false
+ }
+
+ if(!enable){
+ return true
+ }
+
+ if (textureBufferHelper == null) {
+ textureBufferHelper = TextureBufferHelper.create(
+ "FURender",
+ EglBaseProvider.instance().rootEglBase.eglBaseContext
+ )
+ textureBufferHelper?.invoke {
+ synchronized(pendingProcessRunList){
+ val iterator = pendingProcessRunList.iterator()
+ while (iterator.hasNext()){
+ iterator.next().invoke()
+ iterator.remove()
+ }
+ }
+ }
+ LogUtils.i(TAG, "processBeauty >> create texture buffer, beautyMode=$beautyMode")
+ }
+ if (wrapTextureBufferHelper == null) {
+ wrapTextureBufferHelper = TextureBufferHelper.create(
+ "FURenderWrap",
+ EglBaseProvider.instance().rootEglBase.eglBaseContext
+ )
+ LogUtils.i(TAG, "processBeauty >> create texture buffer wrap, beautyMode=$beautyMode")
+ }
+ val startTime = System.currentTimeMillis()
+ val processTexId = when (beautyMode) {
+ 2 -> processBeautySingleBuffer(videoFrame)
+ 3 -> {
+ if (enableTextureAsync) {
+ processBeautySingleTextureAsync(videoFrame)
+ } else {
+ processBeautySingleTexture(videoFrame)
+ }
+ }
+ else -> processBeautyAuto(videoFrame)
+ }
+
+ if(config?.statsEnable == true){
+ val costTime = System.currentTimeMillis() - startTime
+ statsHelper?.once(costTime)
+ }
+
+ if (processTexId <= 0) {
+ LogUtils.w(TAG, "processBeauty >> processTexId <= 0")
+ return false
+ }
+
+ if(skipFrame > 0){
+ skipFrame --
+ LogUtils.w(TAG, "processBeauty >> skipFrame=$skipFrame")
+ return false
+ }
+
+ val processBuffer: TextureBuffer = wrapTextureBufferHelper?.wrapTextureBuffer(
+ videoFrame.rotatedWidth,
+ videoFrame.rotatedHeight,
+ TextureBuffer.Type.RGB,
+ processTexId,
+ identityMatrix
+ ) ?: return false
+ videoFrame.replaceBuffer(processBuffer, 0, videoFrame.timestampNs)
+ return true
+ }
+
+ private fun processBeautyAuto(videoFrame: VideoFrame): Int {
+ val buffer = videoFrame.buffer
+ return if (buffer is TextureBuffer) {
+ if (enableTextureAsync) {
+ processBeautySingleTextureAsync(videoFrame)
+ } else {
+ processBeautySingleTexture(videoFrame)
+ }
+ } else {
+ processBeautySingleBuffer(videoFrame)
+ }
+ }
+
+ private fun processBeautySingleTextureAsync(videoFrame: VideoFrame): Int {
+ val texBufferHelper = wrapTextureBufferHelper ?: return -1
+ val textureBuffer = videoFrame.buffer as? TextureBuffer ?: return -1
+
+ when(textureBuffer.type){
+ TextureBuffer.Type.OES -> {
+ if(currProcessSourceType != ProcessSourceType.TEXTURE_OES_ASYNC){
+ LogUtils.i(TAG, "processBeauty >> process source type change old=$currProcessSourceType, new=${ProcessSourceType.TEXTURE_OES_ASYNC}")
+ if (currProcessSourceType != ProcessSourceType.UNKNOWN) {
+ skipFrame = 3
+ }
+ currProcessSourceType = ProcessSourceType.TEXTURE_OES_ASYNC
+ return -1
+ }
+ }
+ else -> {
+ if(currProcessSourceType != ProcessSourceType.TEXTURE_2D_ASYNC){
+ LogUtils.i(TAG, "processBeauty >> process source type change old=$currProcessSourceType, new=${ProcessSourceType.TEXTURE_2D_ASYNC}")
+ if (currProcessSourceType != ProcessSourceType.UNKNOWN) {
+ skipFrame = 3
+ }
+ currProcessSourceType = ProcessSourceType.TEXTURE_2D_ASYNC
+ skipFrame = 6
+ return -1
+ }
+ }
+ }
+
+ if(mTextureProcessHelper == null) {
+ mTextureProcessHelper = TextureProcessHelper()
+ mTextureProcessHelper?.setFilter { frame ->
+ val fuRenderKit = config?.fuRenderKit ?: return@setFilter -1
+
+ val input = FURenderInputData(frame.width, frame.height)
+ input.texture = FURenderInputData.FUTexture(
+ FUInputTextureEnum.FU_ADM_FLAG_COMMON_TEXTURE,
+ frame.textureId
+ )
+ val isFront = frame.isFrontCamera
+ input.renderConfig.let {
+ if (isFront) {
+ it.cameraFacing = CameraFacingEnum.CAMERA_FRONT
+ it.inputBufferMatrix = FUTransformMatrixEnum.CCROT0
+ it.inputTextureMatrix = FUTransformMatrixEnum.CCROT0
+ it.outputMatrix = FUTransformMatrixEnum.CCROT0_FLIPVERTICAL
+ it.deviceOrientation = 270
+ } else {
+ it.cameraFacing = CameraFacingEnum.CAMERA_BACK
+ it.inputBufferMatrix = FUTransformMatrixEnum.CCROT0
+ it.inputTextureMatrix = FUTransformMatrixEnum.CCROT0
+ it.outputMatrix = FUTransformMatrixEnum.CCROT0_FLIPVERTICAL
+ it.deviceOrientation = 270
+ }
+ }
+ if (isReleased) {
+ return@setFilter -1
+ }
+ val ret = textureBufferHelper?.invoke {
+ synchronized(EglBase.lock){
+ return@invoke fuRenderKit.renderWithInput(input).texture?.texId ?: -1
+ }
+ }
+ return@setFilter ret ?: -1
+ }
+ }
+
+ return texBufferHelper.invoke {
+ if(isReleased){
+ return@invoke -1
+ }
+
+ return@invoke mTextureProcessHelper?.process(
+ textureBuffer.textureId,
+ when (textureBuffer.type) {
+ TextureBuffer.Type.OES -> GLES11Ext.GL_TEXTURE_EXTERNAL_OES
+ else -> GLES20.GL_TEXTURE_2D
+ },
+ textureBuffer.width,
+ textureBuffer.height,
+ videoFrame.rotation,
+ textureBuffer.transformMatrixArray,
+ isFrontCamera,
+ (isFrontCamera && !captureMirror) || (!isFrontCamera && captureMirror)
+ )?: -1
+ }
+ }
+
+ private fun processBeautySingleTexture(videoFrame: VideoFrame): Int {
+ val texBufferHelper = wrapTextureBufferHelper ?: return -1
+ val textureBuffer = videoFrame.buffer as? TextureBuffer ?: return -1
+
+ when(textureBuffer.type){
+ TextureBuffer.Type.OES -> {
+ if(currProcessSourceType != ProcessSourceType.TEXTURE_OES){
+ LogUtils.i(TAG, "processBeauty >> process source type change old=$currProcessSourceType, new=${ProcessSourceType.TEXTURE_OES}")
+ if (currProcessSourceType != ProcessSourceType.UNKNOWN) {
+ skipFrame = 3
+ }
+ currProcessSourceType = ProcessSourceType.TEXTURE_OES
+ return -1
+ }
+ }
+ else -> {
+ if(currProcessSourceType != ProcessSourceType.TEXTURE_2D){
+ LogUtils.i(TAG, "processBeauty >> process source type change old=$currProcessSourceType, new=${ProcessSourceType.TEXTURE_2D}")
+ if (currProcessSourceType != ProcessSourceType.UNKNOWN) {
+ skipFrame = 3
+ }
+ currProcessSourceType = ProcessSourceType.TEXTURE_2D
+ skipFrame = 6
+ return -1
+ }
+ }
+ }
+
+ val width = videoFrame.rotatedWidth
+ val height = videoFrame.rotatedHeight
+ val isFront = videoFrame.sourceType == SourceType.kFrontCamera
+ val rotation = videoFrame.rotation
+
+ return texBufferHelper.invoke {
+ val fuRenderKit = config?.fuRenderKit ?: return@invoke -1
+
+ transformGLFrameBuffer.setSize(width, height)
+ transformGLFrameBuffer.resetTransform()
+ transformGLFrameBuffer.setTexMatrix(textureBuffer.transformMatrixArray)
+ transformGLFrameBuffer.setRotation(rotation)
+ var flipH = isFront
+ if((isFrontCamera && !captureMirror) || (!isFrontCamera && captureMirror)){
+ flipH = !flipH
+ }
+ transformGLFrameBuffer.setFlipH(flipH)
+ val transformTexId = transformGLFrameBuffer.process(
+ textureBuffer.textureId, when (textureBuffer.type) {
+ TextureBuffer.Type.OES -> GLES11Ext.GL_TEXTURE_EXTERNAL_OES
+ else -> GLES20.GL_TEXTURE_2D
+ }
+ )
+
+ val input = FURenderInputData(width, height)
+ input.texture = FURenderInputData.FUTexture(
+ FUInputTextureEnum.FU_ADM_FLAG_COMMON_TEXTURE,
+ transformTexId
+ )
+ input.renderConfig.let {
+ if (isFront) {
+ it.cameraFacing = CameraFacingEnum.CAMERA_FRONT
+ it.inputBufferMatrix = FUTransformMatrixEnum.CCROT0
+ it.inputTextureMatrix = FUTransformMatrixEnum.CCROT0
+ it.outputMatrix = FUTransformMatrixEnum.CCROT0_FLIPVERTICAL
+ it.deviceOrientation = 270
+ } else {
+ it.cameraFacing = CameraFacingEnum.CAMERA_BACK
+ it.inputBufferMatrix = FUTransformMatrixEnum.CCROT0
+ it.inputTextureMatrix = FUTransformMatrixEnum.CCROT0
+ it.outputMatrix = FUTransformMatrixEnum.CCROT0_FLIPVERTICAL
+ it.deviceOrientation = 270
+ }
+ }
+ if (isReleased) {
+ return@invoke -1
+ }
+ synchronized(EglBase.lock){
+ return@invoke fuRenderKit.renderWithInput(input).texture?.texId ?: -1
+ }
+ }
+ }
+
+ private fun processBeautySingleBuffer(videoFrame: VideoFrame): Int {
+ val texBufferHelper = textureBufferHelper ?: return -1
+ if(currProcessSourceType != ProcessSourceType.I420){
+ LogUtils.i(TAG, "processBeauty >> process source type change old=$currProcessSourceType, new=${ProcessSourceType.I420}")
+ if (currProcessSourceType != ProcessSourceType.UNKNOWN) {
+ skipFrame = 3
+ }
+ currProcessSourceType = ProcessSourceType.I420
+ return -1
+ }
+ val bufferArray = getNV21Buffer(videoFrame) ?: return -1
+ val buffer = videoFrame.buffer
+ val width = buffer.width
+ val height = buffer.height
+ val isFront = videoFrame.sourceType == SourceType.kFrontCamera
+ val mirror = (isFrontCamera && !captureMirror) || (!isFrontCamera && captureMirror)
+ val rotation = videoFrame.rotation
+
+ return texBufferHelper.invoke(Callable {
+ if(isReleased){
+ return@Callable -1
+ }
+ val fuRenderKit = config?.fuRenderKit ?: return@Callable -1
+ val input = FURenderInputData(width, height)
+ input.imageBuffer = FURenderInputData.FUImageBuffer(
+ FUInputBufferEnum.FU_FORMAT_NV21_BUFFER,
+ bufferArray
+ )
+ input.renderConfig.let {
+ if (isFront) {
+ it.cameraFacing = CameraFacingEnum.CAMERA_FRONT
+ it.inputBufferMatrix = if(mirror) {
+ when (rotation) {
+ 0 -> FUTransformMatrixEnum.CCROT0
+ 180 -> FUTransformMatrixEnum.CCROT180
+ else -> FUTransformMatrixEnum.CCROT90
+ }
+ } else {
+ when (rotation) {
+ 0 -> FUTransformMatrixEnum.CCROT0_FLIPHORIZONTAL
+ 180 -> FUTransformMatrixEnum.CCROT0_FLIPVERTICAL
+ else -> FUTransformMatrixEnum.CCROT90_FLIPHORIZONTAL
+ }
+ }
+ it.inputTextureMatrix = if(mirror) {
+ when (rotation) {
+ 0 -> FUTransformMatrixEnum.CCROT0
+ 180 -> FUTransformMatrixEnum.CCROT180
+ else -> FUTransformMatrixEnum.CCROT90
+ }
+ } else {
+ when (rotation) {
+ 0 -> FUTransformMatrixEnum.CCROT0_FLIPHORIZONTAL
+ 180 -> FUTransformMatrixEnum.CCROT0_FLIPVERTICAL
+ else -> FUTransformMatrixEnum.CCROT90_FLIPHORIZONTAL
+ }
+ }
+ it.deviceOrientation = when(rotation){
+ 0 -> 270
+ 180 -> 90
+ else -> 0
+ }
+ it.outputMatrix = FUTransformMatrixEnum.CCROT0
+ } else {
+ it.cameraFacing = CameraFacingEnum.CAMERA_BACK
+ it.inputBufferMatrix = if(mirror) {
+ when (rotation) {
+ 0 -> FUTransformMatrixEnum.CCROT0_FLIPHORIZONTAL
+ 180 -> FUTransformMatrixEnum.CCROT0_FLIPVERTICAL
+ else -> FUTransformMatrixEnum.CCROT90_FLIPVERTICAL
+ }
+ } else {
+ when (rotation) {
+ 0 -> FUTransformMatrixEnum.CCROT0
+ 180 -> FUTransformMatrixEnum.CCROT180
+ else -> FUTransformMatrixEnum.CCROT270
+ }
+ }
+ it.inputTextureMatrix = if(mirror) {
+ when (rotation) {
+ 0 -> FUTransformMatrixEnum.CCROT0_FLIPHORIZONTAL
+ 180 -> FUTransformMatrixEnum.CCROT0_FLIPVERTICAL
+ else -> FUTransformMatrixEnum.CCROT90_FLIPVERTICAL
+ }
+ } else {
+ when (rotation) {
+ 0 -> FUTransformMatrixEnum.CCROT0
+ 180 -> FUTransformMatrixEnum.CCROT180
+ else -> FUTransformMatrixEnum.CCROT270
+ }
+ }
+ it.deviceOrientation = when(rotation){
+ 0 -> 270
+ 180 -> 90
+ else -> 0
+ }
+ it.outputMatrix = FUTransformMatrixEnum.CCROT0
+ }
+ }
+
+ mTextureProcessHelper?.let {
+ if(it.size() > 0){
+ it.reset()
+ return@Callable -1
+ }
+ }
+ synchronized(EglBase.lock){
+ return@Callable fuRenderKit.renderWithInput(input).texture?.texId ?: -1
+ }
+ })
+ }
+
+ private fun getNV21Buffer(videoFrame: VideoFrame): ByteArray? {
+ val buffer = videoFrame.buffer
+ val width = buffer.width
+ val height = buffer.height
+ val size = (width * height * 3.0f / 2.0f + 0.5f).toInt()
+ if (byteBuffer == null || byteBuffer?.capacity() != size || byteArray == null || byteArray?.size != size) {
+ byteBuffer?.clear()
+ byteBuffer = ByteBuffer.allocateDirect(size)
+ byteArray = ByteArray(size)
+ return null
+ }
+ val outArray = byteArray ?: return null
+ val outBuffer = byteBuffer ?: return null
+ val i420Buffer = buffer as? I420Buffer ?: buffer.toI420()
+ YuvHelper.I420ToNV12(
+ i420Buffer.dataY, i420Buffer.strideY,
+ i420Buffer.dataV, i420Buffer.strideV,
+ i420Buffer.dataU, i420Buffer.strideU,
+ outBuffer, width, height
+ )
+ outBuffer.position(0)
+ outBuffer.get(outArray)
+ if(buffer !is I420Buffer){
+ i420Buffer.release()
+ }
+ return outArray
+ }
+
+ // IVideoFrameObserver implements
+
+ override fun onCaptureVideoFrame(sourceType: Int, videoFrame: VideoFrame?): Boolean {
+ videoFrame ?: return false
+ return processBeauty(videoFrame)
+ }
+
+ override fun onPreEncodeVideoFrame(sourceType: Int, videoFrame: VideoFrame?) = false
+
+ override fun onMediaPlayerVideoFrame(videoFrame: VideoFrame?, mediaPlayerId: Int) = false
+
+ override fun onRenderVideoFrame(
+ channelId: String?,
+ uid: Int,
+ videoFrame: VideoFrame?
+ ) = false
+
+ override fun getVideoFrameProcessMode() = IVideoFrameObserver.PROCESS_MODE_READ_WRITE
+
+ override fun getVideoFormatPreference() = IVideoFrameObserver.VIDEO_PIXEL_DEFAULT
+
+ override fun getRotationApplied() = false
+
+ override fun getMirrorApplied() = captureMirror && !enable
+
+ override fun getObservedFramePosition() = IVideoFrameObserver.POSITION_POST_CAPTURER
+
+}
\ No newline at end of file
diff --git a/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/LiveFloatView.java
similarity index 58%
rename from common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java
rename to lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/LiveFloatView.java
index 0f9efc7de..0b43f7d0a 100644
--- a/common/src/main/java/com/yunbao/common/views/weight/LiveFloatView.java
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/LiveFloatView.java
@@ -1,4 +1,4 @@
-package com.yunbao.common.views.weight;
+package io.agora.beautyapi.faceunity.agora;
import android.app.Activity;
import android.os.Bundle;
@@ -7,6 +7,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
+import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import androidx.cardview.widget.CardView;
@@ -19,6 +20,8 @@ import com.lzf.easyfloat.interfaces.OnInvokeView;
import com.tencent.rtmp.ITXLivePlayListener;
import com.tencent.rtmp.TXLivePlayer;
import com.tencent.rtmp.ui.TXCloudVideoView;
+import com.yunbao.common.CommonAppConfig;
+import com.yunbao.common.Constants;
import com.yunbao.common.R;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.dialog.HintDialog;
@@ -26,10 +29,12 @@ import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DpUtil;
+import com.yunbao.common.utils.L;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.views.floatingview.APPEasyFloat;
import com.yunbao.common.views.floatingview.FloatingMagnetView;
import com.yunbao.common.views.floatingview.MagnetViewListener;
+import com.yunbao.common.views.weight.ViewClicksAntiShake;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
@@ -45,17 +50,19 @@ public class LiveFloatView implements Function1 {
private String url;
private LiveBean mLiveBean;
private int mLiveType;
- private int mLiveSDK;
+ private boolean mLiveSDK;
private int mLiveTypeVal;
private FloatCallbacks.Builder builder;
private String TAG = "LiveFloatView";
private TXLivePlayer mPlayer;
+ private FrameLayout videoFrameLayout;
+ private TXCloudVideoView videoView;
+ private SWAuManager swAuManager;
public static LiveFloatView getInstance() {
if (instance == null) {
instance = new LiveFloatView();
}
-
return instance;
}
@@ -79,39 +86,53 @@ public class LiveFloatView implements Function1 {
cardParams.height = DpUtil.dp2px(224);
cardParams.width = DpUtil.dp2px(126);
}
- TXCloudVideoView videoView = magnetView.findViewById(R.id.video_view);
- mPlayer = new TXLivePlayer(mContext);
- mPlayer.setPlayerView(videoView);
- mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV);
- mPlayer.setPlayListener(new ITXLivePlayListener() {
- @Override
- public void onPlayEvent(int event, Bundle param) {
- float videoWidth = param.getInt("EVT_PARAM1", 0);
- float videoHeight = param.getInt("EVT_PARAM2", 0);
- Log.e("视频流有", "videoWidth:" + videoWidth + " videoHeight:" + videoHeight);
- if (mLiveBean.getLandscape() != 1){
- if (videoWidth > 720) {
- cardParams.height = DpUtil.dp2px(190);
- cardParams.width = DpUtil.dp2px(255);
- } else {
- cardParams.height = DpUtil.dp2px(224);
- cardParams.width = DpUtil.dp2px(126);
+ if(mLiveSDK){
+ L.eSw("mLiveSDK == Constants.LIVE_S2222222222222222");
+ videoFrameLayout = magnetView.findViewById(R.id.videoFrameLayout);
+ swAuManager = SWAuManager.get();
+ swAuManager.setAudienceContainer(videoFrameLayout);
+ swAuManager.initRtcEngine( mContext);
+ swAuManager.setupRemoteVideo(Integer.parseInt(mLiveBean.getUid()));
+ //进入主播房间
+ swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken,mLiveBean.getUid(), SWAuManager.getChannelName(mLiveBean.getUid()));
+ }else{
+ videoView = magnetView.findViewById(R.id.video_view);
+ mPlayer = new TXLivePlayer(mContext);
+ mPlayer.setPlayerView(videoView);
+ mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV);
+ mPlayer.setPlayListener(new ITXLivePlayListener() {
+ @Override
+ public void onPlayEvent(int event, Bundle param) {
+ float videoWidth = param.getInt("EVT_PARAM1", 0);
+ float videoHeight = param.getInt("EVT_PARAM2", 0);
+ Log.e("视频流有", "videoWidth:" + videoWidth + " videoHeight:" + videoHeight);
+ if (mLiveBean.getLandscape() != 1){
+ if (videoWidth > 720) {
+ cardParams.height = DpUtil.dp2px(190);
+ cardParams.width = DpUtil.dp2px(255);
+ } else {
+ cardParams.height = DpUtil.dp2px(224);
+ cardParams.width = DpUtil.dp2px(126);
+ }
+ layout.setLayoutParams(cardParams);
}
- layout.setLayoutParams(cardParams);
}
- }
+ @Override
+ public void onNetStatus(Bundle bundle) {
- @Override
- public void onNetStatus(Bundle bundle) {
+ }
+ });
+ }
-
- }
- });
ViewClicksAntiShake.clicksAntiShake(magnetView.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
- mPlayer.stopPlay(true);
+ if(mLiveSDK){
+ SWAuManager.get().exitChannelAll();
+ }else{
+ mPlayer.stopPlay(true);
+ }
APPEasyFloat.getInstance().dismiss(mContext);
if (IMLoginManager.get(mContext).isHint2() && !((FragmentActivity) mContext).getSupportFragmentManager().isDestroyed()) {
HintDialog fragment = new HintDialog();
@@ -122,13 +143,20 @@ public class LiveFloatView implements Function1 {
}
}
});
- ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
- mPlayer.stopPlay(true);
- APPEasyFloat.getInstance().dismiss(mContext);
- new Handler().post(liveCheck);
+ if(mLiveSDK){
+ ViewClicksAntiShake.clicksAntiShake(videoFrameLayout, () -> {
+ SWAuManager.get().exitChannelAll();
+ APPEasyFloat.getInstance().dismiss(mContext);
+ new Handler().post(liveCheck);
+ });
+ }else{
+ ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
+ mPlayer.stopPlay(true);
+ APPEasyFloat.getInstance().dismiss(mContext);
+ new Handler().post(liveCheck);
+ });
+ }
-
- });
}
@Override
@@ -138,8 +166,13 @@ public class LiveFloatView implements Function1 {
@Override
public void dismiss() {
- if (mPlayer != null)
- mPlayer.stopPlay(true);
+ if(mLiveSDK){
+ SWAuManager.get().exitChannelAll();
+ }else{
+ if (mPlayer != null)
+ mPlayer.stopPlay(true);
+ }
+
}
})
.show(mContext);
@@ -161,7 +194,7 @@ public class LiveFloatView implements Function1 {
.show();
}
- public LiveFloatView cacheLiveData(LiveBean mLiveBean, int mLiveType, int mLiveSDK, int mLiveTypeVal) {
+ public LiveFloatView cacheLiveData(LiveBean mLiveBean, int mLiveType, boolean mLiveSDK, int mLiveTypeVal) {
this.mLiveBean = mLiveBean;
this.mLiveType = mLiveType;
this.mLiveSDK = mLiveSDK;
@@ -202,7 +235,8 @@ public class LiveFloatView implements Function1 {
@Override
public void invoke(View view) {
- TXCloudVideoView videoView = view.findViewById(R.id.video_view);
+ videoFrameLayout = view.findViewById(R.id.videoFrameLayout);
+ L.eSw("invoke(View view) invoke(View view) invoke(View view) invoke(View view) ");
CardView layout = view.findViewById(R.id.layout);
RelativeLayout.LayoutParams cardParams = (RelativeLayout.LayoutParams) layout.getLayoutParams();
if (mLiveBean.getLandscape() == 1) {
@@ -213,39 +247,54 @@ public class LiveFloatView implements Function1 {
cardParams.width = DpUtil.dp2px(126);
}
layout.setLayoutParams(cardParams);
- mPlayer = new TXLivePlayer(mContext);
- mPlayer.setPlayerView(videoView);
- mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV);
- mPlayer.setPlayListener(new ITXLivePlayListener() {
- @Override
- public void onPlayEvent(int event, Bundle param) {
- float videoWidth = param.getInt("EVT_PARAM1", 0);
- float videoHeight = param.getInt("EVT_PARAM2", 0);
- Log.e("视频流有", "videoWidth:" + videoWidth + " videoHeight:" + videoHeight);
- if (mLiveBean.getLandscape() != 1){
- if (videoWidth > 720) {
- cardParams.height = DpUtil.dp2px(190);
- cardParams.width = DpUtil.dp2px(255);
- } else {
- cardParams.height = DpUtil.dp2px(224);
- cardParams.width = DpUtil.dp2px(126);
+ if(mLiveSDK){
+ L.eSw("mLiveSDK == Constants.LIVE_SDK_SW mLive1111111");
+ swAuManager = SWAuManager.get();
+ swAuManager.setAudienceContainer(videoFrameLayout);
+ swAuManager.initRtcEngine( mContext);
+ swAuManager.setupRemoteVideo(Integer.parseInt(mLiveBean.getUid()));
+ //进入主播房间
+ swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, mLiveBean.getUid(),SWAuManager.getChannelName(mLiveBean.getUid()));
+ }else{
+ TXCloudVideoView videoView = view.findViewById(R.id.video_view);
+ mPlayer = new TXLivePlayer(mContext);
+ mPlayer.setPlayerView(videoView);
+ mPlayer.startPlay(url, TXLivePlayer.PLAY_TYPE_LIVE_FLV);
+ mPlayer.setPlayListener(new ITXLivePlayListener() {
+ @Override
+ public void onPlayEvent(int event, Bundle param) {
+ float videoWidth = param.getInt("EVT_PARAM1", 0);
+ float videoHeight = param.getInt("EVT_PARAM2", 0);
+ Log.e("视频流有", "videoWidth:" + videoWidth + " videoHeight:" + videoHeight);
+ if (mLiveBean.getLandscape() != 1){
+ if (videoWidth > 720) {
+ cardParams.height = DpUtil.dp2px(190);
+ cardParams.width = DpUtil.dp2px(255);
+ } else {
+ cardParams.height = DpUtil.dp2px(224);
+ cardParams.width = DpUtil.dp2px(126);
+ }
+ layout.setLayoutParams(cardParams);
}
- layout.setLayoutParams(cardParams);
+
}
- }
-
- @Override
- public void onNetStatus(Bundle bundle) {
-
- }
- });
+ @Override
+ public void onNetStatus(Bundle bundle) {
+ }
+ });
+ }
ViewClicksAntiShake.clicksAntiShake(view.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
- mPlayer.stopPlay(true);
+ if(mLiveSDK){
+ SWAuManager.get().exitChannelAll();
+ }else{
+ mPlayer.stopPlay(true);
+ }
+
EasyFloat.dismiss("LiveFloatView", true);
if (IMLoginManager.get(mContext).isHint2() && !((FragmentActivity) mContext).getSupportFragmentManager().isDestroyed()) {
HintDialog fragment = new HintDialog();
@@ -257,8 +306,11 @@ public class LiveFloatView implements Function1 {
}
});
ViewClicksAntiShake.clicksAntiShake(view, () -> {
-
- mPlayer.stopPlay(true);
+ if(mLiveSDK){
+ SWAuManager.get().exitChannelAll();
+ }else{
+ mPlayer.stopPlay(true);
+ }
new Handler().post(liveCheck);
@@ -289,7 +341,7 @@ public class LiveFloatView implements Function1 {
public void onSuccess(int code, String msg, String[] info) {
if (code == 0) {
- RouteUtil.forwardLiveAudienceActivity(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal);
+ RouteUtil.forwardLiveAudienceActivity(mLiveBean, mLiveType, mLiveSDK ? Constants.LIVE_SDK_SW:Constants.LIVE_SDK_TX, mLiveTypeVal,mLiveSDK);
} else {
//判断是否有直播悬浮窗,有直接关闭
diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java
new file mode 100644
index 000000000..f64ea9637
--- /dev/null
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/agora/SWAuManager.java
@@ -0,0 +1,429 @@
+package io.agora.beautyapi.faceunity.agora;
+
+import android.app.Activity;
+import android.content.Context;
+import android.util.Log;
+import android.view.SurfaceView;
+import android.widget.FrameLayout;
+
+
+import com.yunbao.common.CommonAppConfig;
+import com.yunbao.common.CommonAppContext;
+import com.yunbao.common.bean.BaseModel;
+import com.yunbao.common.bean.LiveBean;
+import com.yunbao.common.bean.UserBean;
+import com.yunbao.common.http.API;
+import com.yunbao.common.http.ResponseModel;
+import com.yunbao.common.manager.MicUserManager;
+import com.yunbao.common.manager.MicedUserManager;
+import com.yunbao.common.manager.base.BaseCacheManager;
+import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
+import com.yunbao.common.utils.L;
+import com.yunbao.common.utils.StringUtil;
+import com.yunbao.common.utils.ToastUtil;
+
+import java.util.List;
+
+import io.agora.rtc2.ChannelMediaOptions;
+import io.agora.rtc2.Constants;
+import io.agora.rtc2.IRtcEngineEventHandler;
+import io.agora.rtc2.RtcConnection;
+import io.agora.rtc2.RtcEngineConfig;
+import io.agora.rtc2.RtcEngineEx;
+import io.agora.rtc2.video.VideoCanvas;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.functions.Consumer;
+import io.reactivex.schedulers.Schedulers;
+import io.rong.imkit.IMCenter;
+import io.rong.imlib.IRongCallback;
+import io.rong.imlib.RongIMClient;
+import io.rong.imlib.model.Conversation;
+import io.rong.imlib.model.Message;
+import io.rong.message.TextMessage;
+
+/**
+ * 声网主播管理类
+ */
+public class SWAuManager extends BaseCacheManager {
+
+ private Activity mContext;
+ public static SWAuManager manager;
+ private RtcEngineEx mRtcEngine;
+ private FrameLayout audienceContainer; //主播视图
+ private FrameLayout pkContainer1; //pk主播视图1
+ private FrameLayout pkContainer2; //pk主播视图2
+ private FrameLayout pkContainer3; //pk主播视图3
+ private FrameLayout linkUserContainer;//连麦用户视图
+
+ private int liveMicUid;
+
+ private SwListener swListener;
+
+ public void setSwListener(SwListener swListener) {
+ this.swListener = swListener;
+ }
+
+ public SWAuManager(Context context) {
+ super(context);
+ }
+
+ /**
+ * 获取单列
+ *
+ * @return
+ */
+ public static SWAuManager get() {
+ if (null == manager) {
+ manager = new SWAuManager(CommonAppContext.sInstance.getBaseContext());
+ }
+ return manager;
+ }
+
+ IRtcEngineEventHandler mEventHandler = new IRtcEngineEventHandler() {
+ @Override
+ public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
+ super.onJoinChannelSuccess(channel, uid, elapsed);
+ L.eSw("加入房间成功 channel" + channel + " uid" + uid);
+ }
+
+ @Override
+ public void onUserJoined(int uid, int elapsed) {
+ super.onUserJoined(uid, elapsed);
+ L.eSw("用户加入房间成功" + uid);
+ }
+ };
+
+ /**
+ * 初始化声网SDK
+ */
+ public void initRtcEngine(Activity mContext) {
+ this.mContext = mContext;
+ if(mRtcEngine==null){
+ try {
+ // 创建 RtcEngineConfig 对象,并进行配置
+ RtcEngineConfig config = new RtcEngineConfig();
+ config.mContext = mContext;
+ config.mAppId = CommonAppConfig.getSwAppId();
+ config.mEventHandler = mRtcEventHandler;
+ // 创建并初始化 RtcEngine
+ mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
+ } catch (Exception e) {
+ throw new RuntimeException("Check the error.");
+ }
+ }
+ mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING); // 直播模式,引擎級別
+ // 开启本地预览
+ //mRtcEngine.startPreview();
+ }
+
+ /**
+ * 初始化声网SDK-语音房
+ */
+ public void initRtcEngineAudio(Activity mContext) {
+ this.mContext = mContext;
+ try {
+ if(mRtcEngine==null){
+ RtcEngineConfig config = new RtcEngineConfig();
+ config.mContext = mContext;
+ config.mAppId = CommonAppConfig.getSwAppId();
+ config.mEventHandler = mEventHandler;
+ // 创建并初始化 RtcEngine
+ mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
+ }
+ // 创建 RtcEngineConfig 对象,并进行配置
+ mRtcEngine.enableAudio();
+ mRtcEngine.enableLocalAudio(true);
+ } catch (Exception e) {
+ throw new RuntimeException("Check the error.");
+ }
+ }
+
+ /**
+ * 创建语音房
+ *
+ * @param token
+ * @param channelName
+ * @param uid
+ */
+ public void joinAudioRoom(String channelName, String token, int uid) {
+ L.eSw("加入房间" + channelName + " uid" + uid);
+ // 直播场景下,设置频道场景为 BROADCASTING (直播场景)
+ mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING);
+ // 创建 ChannelMediaOptions 对象,并进行配置
+ ChannelMediaOptions options = new ChannelMediaOptions();
+ // 根据场景将用户角色设置为 AUDIENCE (观众)
+ options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE;
+ mRtcEngine.disableVideo();
+ options.autoSubscribeAudio = true;
+ mRtcEngine.joinChannel(token, channelName, uid, options);
+ }
+
+
+ /**
+ * 更新主播视图
+ *
+ * @param frameLayout
+ */
+ public void updateMyChannelView(FrameLayout frameLayout, int uid) {
+ mRtcEngine.setupLocalVideo(null);
+ SurfaceView surfaceView = new SurfaceView(mContext);
+ surfaceView.setZOrderMediaOverlay(true);
+ frameLayout.addView(surfaceView);
+
+ VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid);
+ mRtcEngine.setupRemoteVideo(videoCanvas);
+ }
+
+ /**
+ * 加入房间
+ */
+ public void joinRoom(String strUid, String token, String liveUid, String channelName) {
+ liveMicUid = Integer.parseInt(liveUid);
+ int uid;
+ if (StringUtil.isEmpty(strUid)) {
+ uid = 0;
+ } else {
+ uid = Integer.parseInt(strUid);
+ }
+ // 创建一个 SurfaceView 对象,并将其作为 FrameLayout 的子对象
+ SurfaceView surfaceView = new SurfaceView(mContext);
+ audienceContainer.addView(surfaceView);
+
+ // 启用视频模块
+ mRtcEngine.enableVideo();
+
+ //走媒体音量,和音质有关
+ mRtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY);
+ mRtcEngine.setAudioScenario(Constants.AUDIO_SCENARIO_GAME_STREAMING);
+
+ // 创建 ChannelMediaOptions 对象,并进行配置
+ ChannelMediaOptions options = new ChannelMediaOptions();
+ // 根据场景将用户角色设置为 AUDIENCE (观众)
+ options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE;
+ // 直播场景下,设置频道场景为 BROADCASTING (直播场景)
+ options.audienceLatencyLevel = Constants.AUDIENCE_LATENCY_LEVEL_LOW_LATENCY; // 觀眾走極速直播
+ // 使用临时 Token 加入频道,自行指定用户 ID 并确保其在频道内的唯一性
+ mRtcEngine.joinChannel(token, channelName, uid, options);
+ }
+
+ public void joinExRoomEx(int strUid, String token, String channelName) {
+ // 创建 ChannelMediaOptions 对象,并进行配置
+ ChannelMediaOptions options = new ChannelMediaOptions();
+ // 根据场景将用户角色设置为 AUDIENCE (观众)
+ options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE;
+ // 直播场景下,设置频道场景为 BROADCASTING (直播场景)
+ options.audienceLatencyLevel = Constants.AUDIENCE_LATENCY_LEVEL_LOW_LATENCY; // 觀眾走極速直播
+ options.autoSubscribeVideo = true;
+ options.autoSubscribeAudio = true;
+
+ RtcConnection rtcConnection = new RtcConnection();
+ rtcConnection.channelId = channelName; //對方主播的頻道
+ rtcConnection.localUid = Integer.parseInt(CommonAppConfig.getInstance().getUid());//自己的ID
+
+ mRtcEngine.joinChannelEx(token, rtcConnection, options, new IRtcEngineEventHandler() {
+ @Override
+ public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
+ super.onJoinChannelSuccess(channel, uid, elapsed);
+ mContext.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ L.eSw("onJoinChannelSuccess:" + channel + " uid " + uid + " elapsed: " + elapsed);
+ SurfaceView surfaceView = new SurfaceView(mContext);
+ surfaceView.setZOrderMediaOverlay(true);
+ pkContainer1.addView(surfaceView);
+ VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, strUid);
+ mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection);
+ }
+ });
+ }
+
+ @Override
+ public void onError(int err) {
+ super.onError(err);
+ L.eSw("onError:" + err);
+ }
+ });
+ }
+
+ /**
+ * 与主播连麦
+ *
+ * @param isUp true 上麦 false 下麦
+ */
+ public void setMicAn(boolean isUp) {
+ L.eSw("setMicAn-isUp:" + isUp);
+ ChannelMediaOptions options = new ChannelMediaOptions();
+ if (isUp) {
+ options.publishCameraTrack = false; //控制是否发视频
+ options.publishMicrophoneTrack = true; //控制是否发音频
+ options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER; //设置身份为主播
+ } else {
+ options.publishCameraTrack = false; //控制是否发视频
+ options.publishMicrophoneTrack = false; //控制是否发音频
+ options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE; //设置身份为观众
+ options.audienceLatencyLevel = Constants.AUDIENCE_LATENCY_LEVEL_LOW_LATENCY;//设置为极速直播观众
+ }
+ mRtcEngine.updateChannelMediaOptions(options);
+ }
+
+ public void setMicAudio(int toUid, boolean isEn) {
+ L.eSw("setMicAudio:toUid" + toUid + "isEn " + isEn);
+ mRtcEngine.muteRemoteAudioStream(toUid, isEn);
+ }
+
+ /**
+ * PK-加入对方主播直播间
+ *
+ * @param strUid
+ * @param token
+ * @param toUid
+ * @param channelName
+ */
+ public void joinChannelDrEx(FrameLayout frameLayout, String strUid, String token, String toUid, String channelName) {
+ int tempUid;
+ if (StringUtil.isEmpty(strUid)) {
+ tempUid = 0;
+ } else {
+ tempUid = Integer.parseInt(strUid);
+ }
+
+ // 创建 ChannelMediaOptions 对象,并进行配置
+ ChannelMediaOptions options = new ChannelMediaOptions();
+ // 根据场景将用户角色设置为 AUDIENCE (观众)
+ options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE;
+ options.autoSubscribeVideo = true;
+ options.autoSubscribeAudio = true;
+ options.publishMicrophoneTrack = false;
+ options.publishCameraTrack = false;
+
+ RtcConnection rtcConnection = new RtcConnection();
+ rtcConnection.channelId = channelName; //對方主播的頻道
+ rtcConnection.localUid = tempUid;//自己的ID
+ L.eSw("strUid:" + tempUid + "_token:" + token + "_channelName:" + channelName);
+ mRtcEngine.joinChannelEx(token, rtcConnection, options, new IRtcEngineEventHandler() {
+ @Override
+ public void onJoinChannelSuccess(String channel, int scUid, int elapsed) {
+ super.onJoinChannelSuccess(channel, scUid, elapsed);
+ L.eSw("onJoinChannelSuccess:" + channel + " uid " + scUid + " elapsed: " + elapsed);
+ mContext.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ SurfaceView surfaceView = new SurfaceView(mContext);
+ surfaceView.setZOrderMediaOverlay(true);
+ frameLayout.addView(surfaceView);
+ VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, Integer.parseInt(toUid));
+ mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection);
+ }
+ });
+ }
+
+ @Override
+ public void onLeaveChannel(RtcStats stats) {
+ super.onLeaveChannel(stats);
+ }
+
+ @Override
+ public void onError(int err) {
+ super.onError(err);
+ L.eSw("onError:" + err);
+ }
+ });
+ }
+
+ /**
+ * 退出对方直播间
+ *
+ * @param uid 自己的ID
+ * @param liveUid 对方直播间号
+ */
+ public void exitChannelToUid(int uid, String liveUid) {
+ RtcConnection rtcConnection = new RtcConnection();
+ rtcConnection.channelId = getChannelName(liveUid); //對方主播的頻道
+ rtcConnection.localUid = uid;//自己的ID
+ mRtcEngine.leaveChannelEx(rtcConnection);
+ }
+
+ /**
+ * 退出所有的直播间
+ */
+ public void exitChannelAll() {
+ L.eSw("exitChannelAll exitChannelAll exitChannelAll");
+ if (mRtcEngine != null) {
+ mRtcEngine.leaveChannel();
+ }
+ }
+
+ public static String getChannelName(String liveUid) {
+ if ( liveUid != null &&liveUid.contains("g")) {
+ return liveUid;
+ } else {
+ return CommonAppConfig.SWChannelPrefix + liveUid;
+ }
+ }
+
+ //远程监听
+ private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() {
+ @Override
+ // 监听频道内的远端用户,获取用户的 uid 信息
+ public void onUserJoined(int uid, int elapsed) {
+ mContext.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ // 获取 uid 后,设置远端视频视图
+ //setupRemoteVideo(uid);
+ }
+ });
+ }
+
+ @Override
+ public void onUserOffline(int uid, int reason) {
+ super.onUserOffline(uid, reason);
+ L.eSw("onUserOffline: uid " + uid + " reason" + reason);
+ if (liveMicUid == uid) {
+ if (swListener != null) {
+ swListener.onUserOffline(liveMicUid);
+ }
+ }
+ }
+ };
+
+ //设置对方主播视图
+ public void setupRemoteVideo(int uid) {
+ SurfaceView surfaceView = new SurfaceView(mContext);
+ surfaceView.setZOrderMediaOverlay(true);
+ audienceContainer.addView(surfaceView);
+ // 将 SurfaceView 对象传入声网实时互动 SDK,设置远端视图
+ mRtcEngine.setupRemoteVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid));
+ }
+
+ public void setAudienceContainer(FrameLayout audienceContainer) {
+ this.audienceContainer = audienceContainer;
+ }
+
+ public void setPkContainer1(FrameLayout pkContainer1) {
+ this.pkContainer1 = pkContainer1;
+ }
+
+ public void setPkContainer2(FrameLayout pkContainer2) {
+ this.pkContainer2 = pkContainer2;
+ }
+
+ public void setPkContainer3(FrameLayout pkContainer3) {
+ this.pkContainer3 = pkContainer3;
+ }
+
+ public void setLinkUserContainer(FrameLayout linkUserContainer) {
+ this.linkUserContainer = linkUserContainer;
+ }
+
+ public interface SwListener {
+ void onUserOffline(int liveUid);
+ }
+
+ public void preloadChannel(List uids){
+ for (int i = 0; i drPkUserInfo = new ArrayList<>();
+
+ private onDrPkJoinSuccessListener onDrPkJoinSuccessListener;
+
+ public void setOnDrPkJoinSuccessListener(SWManager.onDrPkJoinSuccessListener onDrPkJoinSuccessListener) {
+ this.onDrPkJoinSuccessListener = onDrPkJoinSuccessListener;
+ }
+
+ public void setOnRtcEngineListener(SWManager.onRtcEngineListener onRtcEngineListener) {
+ this.onRtcEngineListener = onRtcEngineListener;
+ }
+
+ public SWManager(Context context) {
+ super(context);
+ }
+
+ /**
+ * 获取单列
+ *
+ * @return
+ */
+ public static SWManager get() {
+ if (null == manager) {
+ manager = new SWManager(CommonAppContext.sInstance.getBaseContext());
+ }
+ return manager;
+ }
+
+ /**
+ * 初始化声网SDK
+ */
+ public void initRtcEngine(Activity mContext, String strUid) {
+ this.mContext = mContext;
+ if (StringUtil.isEmpty(strUid)) {
+ uid = 0;
+ } else {
+ uid = Integer.parseInt(strUid);
+ }
+ try {
+ if (mRtcEngine == null) {
+ // 创建 RtcEngineConfig 对象,并进行配置
+ RtcEngineConfig config = new RtcEngineConfig();
+ config.mContext = mContext;
+ config.mAppId = CommonAppConfig.getSwAppId();
+ config.mEventHandler = mRtcEventHandler;
+ // 创建并初始化 RtcEngine
+ mRtcEngine = (RtcEngineEx) RtcEngineEx.create(config);
+ }
+
+ } catch (Exception e) {
+ throw new RuntimeException("Check the error.");
+ }
+ mRtcEngine.setChannelProfile(Constants.CHANNEL_PROFILE_LIVE_BROADCASTING);
+ // 启用视频模块
+ mRtcEngine.enableVideo();
+ // 开启本地预览
+ mRtcEngine.startPreview();
+
+ cfg = new VideoEncoderConfiguration();
+
+ //设置默认分辨率
+ VideoEncoderConfiguration.VideoDimensions videoDimensions = new VideoEncoderConfiguration.VideoDimensions();
+ videoDimensions.width = 720;
+ videoDimensions.height = 1280;
+ cfg.dimensions = videoDimensions;
+
+ cfg.frameRate = 20;
+ cfg.bitrate = 0;
+ //镜像
+ cfg.mirrorMode = VideoEncoderConfiguration.MIRROR_MODE_TYPE.MIRROR_MODE_ENABLED;
+ //设置竖屏
+ cfg.orientationMode = VideoEncoderConfiguration.ORIENTATION_MODE.ORIENTATION_MODE_FIXED_PORTRAIT;
+
+
+
+ mRtcEngine.setVideoEncoderConfiguration(cfg);
+
+ // 创建一个 SurfaceView 对象,并将其作为 FrameLayout 的子对象
+ SurfaceView surfaceView = new SurfaceView(mContext);
+ anchorContainer.addView(surfaceView);
+ Config config = new Config(mContext, mRtcEngine, FURenderer.INSTANCE.mFURenderKit, null, CaptureMode.Agora, 0, false, new CameraConfig(MirrorMode.MIRROR_NONE, MirrorMode.MIRROR_NONE));
+ faceUnityBeautyAPI.initialize(config);
+
+ faceUnityBeautyAPI.setBeautyPreset(BeautyPreset.CUSTOM);
+ //FaceUnityBeautyManage.getInstance().mFURenderKit.setFaceBeauty();
+
+ // 设置视图
+ faceUnityBeautyAPI.setupLocalVideo(surfaceView, Constants.RENDER_MODE_HIDDEN);
+ //faceUnityBeautyAPI.updateCameraConfig(new CameraConfig(MirrorMode.MIRROR_NONE,MirrorMode.MIRROR_NONE));
+ //mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid));
+ setEnableBeauty(true); //默认开启美颜
+ setContentInspect(); //开启视频截图上传
+ }
+
+
+ public void setEnableBeauty(boolean flag) {
+ if (faceUnityBeautyAPI != null) {
+ faceUnityBeautyAPI.enable(flag);
+ }
+ }
+
+ /**
+ * 设置清晰度
+ * 单人直播:720x1280
+ * 2人连麦PK:360x640
+ * 3人连麦PK:左侧主播 360x640,右侧两个主播 360x320
+ * 4人连麦PK:360X320
+ *
+ * @param selectClarity
+ */
+ public void setDrPkNumClarity(int selectClarity) {
+ if (cfg != null && mRtcEngine != null) {
+ VideoEncoderConfiguration.VideoDimensions videoDimensions = new VideoEncoderConfiguration.VideoDimensions();
+ switch (selectClarity) {
+ case 1:
+ videoDimensions.width = 720;
+ videoDimensions.height = 1280;
+ cfg.dimensions = videoDimensions;
+ break;
+ case 2:
+ case 3:
+ videoDimensions.width = 360;
+ videoDimensions.height = 640;
+ cfg.dimensions = videoDimensions;
+ break;
+ case 4:
+ videoDimensions.width = 360;
+ videoDimensions.height = 320;
+ cfg.dimensions = videoDimensions;
+ break;
+ }
+ mRtcEngine.setVideoEncoderConfiguration(cfg);
+ }
+ }
+
+
+ /**
+ * 设置镜像模式
+ */
+ public void setMirrorMode() {
+ if (cfg != null && mRtcEngine != null) {
+ L.eSw("setMirrorMode设置镜像" + cfg.mirrorMode);
+ if (cfg.mirrorMode == VideoEncoderConfiguration.MIRROR_MODE_TYPE.MIRROR_MODE_ENABLED) {
+ cfg.mirrorMode = VideoEncoderConfiguration.MIRROR_MODE_TYPE.MIRROR_MODE_DISABLED; //取消镜像
+ } else {
+ cfg.mirrorMode = VideoEncoderConfiguration.MIRROR_MODE_TYPE.MIRROR_MODE_ENABLED; //设置镜像
+ }
+ mRtcEngine.setVideoEncoderConfiguration(cfg);
+ SurfaceView surfaceView = new SurfaceView(mContext);
+ anchorContainer.addView(surfaceView);
+ mRtcEngine.setupLocalVideo(new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid));
+ }
+ }
+
+ public void setContentInspect() {
+ ContentInspectConfig config = new ContentInspectConfig();
+ config.extraInfo = "YourExtraInfo";
+ config.moduleCount = 1;
+ // 功能模块的类型为视频截图上传
+ config.modules[0].type = ContentInspectConfig.CONTENT_INSPECT_TYPE_SUPERVISE;
+ // 视频截图上传的频率为 2 秒一次
+ config.modules[0].interval = 2;
+ mRtcEngine.enableContentInspect(true, config);
+ }
+
+
+ /**
+ * 设置前後攝像頭
+ */
+ public void switchCamera() {
+ if (mRtcEngine != null) {
+ mRtcEngine.switchCamera();
+ }
+ }
+
+ /**
+ * 创建直播间
+ */
+ public void createChannel(String token, String channelName) {
+ ChannelMediaOptions options = new ChannelMediaOptions();
+ // 设置角色 BROADCASTER (主播) 或 AUDIENCE (观众)
+ options.clientRoleType = Constants.CLIENT_ROLE_BROADCASTER;
+ options.publishCameraTrack = true;
+ options.publishMicrophoneTrack = true;
+ mRtcEngine.setAudioProfile(Constants.AUDIO_PROFILE_MUSIC_HIGH_QUALITY);
+ mRtcEngine.setAudioScenario(Constants.AUDIO_SCENARIO_GAME_STREAMING);
+
+ // 加入频道
+ mRtcEngine.joinChannel(token, channelName, uid, options);
+ }
+
+ /**
+ * 更新主播视图
+ *
+ * @param frameLayout
+ */
+ public void updateMyChannelView(FrameLayout frameLayout) {
+ mRtcEngine.setupLocalVideo(null);
+ SurfaceView surfaceView = new SurfaceView(mContext);
+ surfaceView.setZOrderMediaOverlay(true);
+ frameLayout.addView(surfaceView);
+
+ VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, uid);
+ mRtcEngine.setupLocalVideo(videoCanvas);
+ }
+
+
+ /**
+ * PK-加入对方主播直播间
+ *
+ * @param strUid
+ * @param token
+ * @param toUid
+ * @param channelName
+ */
+ public void joinChannelEx(String strUid, String token, String toUid, String channelName) {
+ int tempUid;
+ if (StringUtil.isEmpty(strUid)) {
+ tempUid = 0;
+ } else {
+ tempUid = Integer.parseInt(strUid);
+ }
+
+ // 创建 ChannelMediaOptions 对象,并进行配置
+ ChannelMediaOptions options = new ChannelMediaOptions();
+ // 根据场景将用户角色设置为 AUDIENCE (观众)
+ options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE;
+ options.autoSubscribeVideo = true;
+ options.autoSubscribeAudio = true;
+ options.publishMicrophoneTrack = false;
+ options.publishCameraTrack = false;
+
+ RtcConnection rtcConnection = new RtcConnection();
+ rtcConnection.channelId = channelName; //對方主播的頻道
+ rtcConnection.localUid = tempUid;//自己的ID
+ L.eSw("strUid:" + tempUid + "_token:" + token + "_channelName:" + channelName);
+ mRtcEngine.joinChannelEx(token, rtcConnection, options, new IRtcEngineEventHandler() {
+ @Override
+ public void onJoinChannelSuccess(String channel, int scUid, int elapsed) {
+ super.onJoinChannelSuccess(channel, scUid, elapsed);
+ L.eSw("onJoinChannelSuccess:" + channel + " uid " + scUid + " elapsed: " + elapsed);
+ mContext.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ SurfaceView surfaceView = new SurfaceView(mContext);
+ surfaceView.setZOrderMediaOverlay(true);
+ pkContainer.addView(surfaceView);
+ VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, Integer.parseInt(toUid));
+ mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection);
+ }
+ });
+ }
+
+ @Override
+ public void onLeaveChannel(RtcStats stats) {
+ super.onLeaveChannel(stats);
+ }
+
+ @Override
+ public void onError(int err) {
+ super.onError(err);
+ L.eSw("onError:" + err);
+ }
+
+ @Override
+ public void onVideoSizeChanged(Constants.VideoSourceType source, int uid, int width, int height, int rotation) {
+ super.onVideoSizeChanged(source, uid, width, height, rotation);
+ L.eSw("uid:" + uid + "\nwidth:" + width + "\nheight:" + height);
+ }
+ });
+ }
+
+
+ /**
+ * PK-加入对方主播直播间
+ *
+ * @param strUid
+ * @param token
+ * @param toUid
+ * @param channelName
+ */
+ public void joinChannelDrEx(FrameLayout frameLayout, String strUid, String token, String toUid, String channelName, int position) {
+ int tempUid;
+ if (StringUtil.isEmpty(strUid)) {
+ tempUid = 0;
+ } else {
+ tempUid = Integer.parseInt(strUid);
+ }
+
+ // 创建 ChannelMediaOptions 对象,并进行配置
+ ChannelMediaOptions options = new ChannelMediaOptions();
+ // 根据场景将用户角色设置为 AUDIENCE (观众)
+ options.clientRoleType = Constants.CLIENT_ROLE_AUDIENCE;
+ options.autoSubscribeVideo = true;
+ options.autoSubscribeAudio = true;
+ options.publishMicrophoneTrack = false;
+ options.publishCameraTrack = false;
+
+ RtcConnection rtcConnection = new RtcConnection();
+ rtcConnection.channelId = channelName; //對方主播的頻道
+ rtcConnection.localUid = tempUid;//自己的ID
+
+ SurfaceView surfaceView = new SurfaceView(mContext);
+ surfaceView.setZOrderMediaOverlay(true);
+ frameLayout.addView(surfaceView);
+ VideoCanvas videoCanvas = new VideoCanvas(surfaceView, VideoCanvas.RENDER_MODE_HIDDEN, Integer.parseInt(toUid));
+
+ L.eSw("strUid:" + tempUid + "_token:" + token + "_channelName:" + channelName);
+ // 用内部通知,刷新多人PK的用户信息
+ mRtcEngine.joinChannelEx(token, rtcConnection, options, new IRtcEngineEventHandler() {
+ @Override
+ public void onJoinChannelSuccess(String channel, int scUid, int elapsed) {
+ super.onJoinChannelSuccess(channel, scUid, elapsed);
+ L.eSw("onJoinChannelSuccess:" + channel + " uid " + scUid + " elapsed: " + elapsed);
+ mContext.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mRtcEngine.setupRemoteVideoEx(videoCanvas, rtcConnection);
+ }
+ });
+ }
+
+ @Override
+ public void onLeaveChannel(RtcStats stats) {
+ super.onLeaveChannel(stats);
+ }
+
+ @Override
+ public void onError(int err) {
+ super.onError(err);
+ L.eSw("onError:" + err);
+ }
+ });
+ }
+
+ /**
+ * 退出对方直播间
+ *
+ * @param uid 自己的ID
+ * @param liveUid 对方直播间号
+ */
+ public void exitChannelToUid(int uid, String liveUid) {
+ RtcConnection rtcConnection = new RtcConnection();
+ rtcConnection.channelId = getChannelName(liveUid); //對方主播的頻道
+ rtcConnection.localUid = uid;//自己的ID
+ mRtcEngine.leaveChannelEx(rtcConnection);
+ }
+
+ /**
+ * 退出所有频道
+ */
+ public void exitChannelAll() {
+ if (mRtcEngine != null) {
+ mRtcEngine.leaveChannel();
+ }
+ }
+
+ public void setAnchorContainer(FrameLayout anchorContainer) {
+ this.anchorContainer = anchorContainer;
+ }
+
+ //远程监听
+ private final IRtcEngineEventHandler mRtcEventHandler = new IRtcEngineEventHandler() {
+ @Override
+ // 监听频道内的远端用户,获取用户的 uid 信息
+ public void onUserJoined(int uid, int elapsed) {
+ mContext.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ // 获取 uid 后,设置远端视频视图
+ //setupRemoteVideo(uid);
+ }
+ });
+ }
+
+ @Override
+ public void onJoinChannelSuccess(String channel, int uid, int elapsed) {
+ super.onJoinChannelSuccess(channel, uid, elapsed);
+ L.eSw("onJoinChannelSuccess 加入频道:channel" + channel + " uid:" + uid + " elapsed:" + elapsed);
+ if (onRtcEngineListener != null) {
+ onRtcEngineListener.onOpenSuccess(channel, uid);
+ }
+ }
+
+ @Override
+ public void onUserOffline(int uid, int reason) {
+ super.onUserOffline(uid, reason);
+ if (onRtcEngineListener != null) {
+ //onRtcEngineListener.onOpenSuccess(channel, uid);
+ }
+ }
+
+ @Override
+ public void onError(int err) {
+ super.onError(err);
+ L.eSw("onError 错误码:" + err);
+ ToastUtil.show("onError:" + err);
+ }
+
+ @Override
+ public void onTokenPrivilegeWillExpire(String token) {
+ super.onTokenPrivilegeWillExpire(token);
+ L.eSw("onTokenPrivilegeWillExpire_Token 即将失效");
+ refreshToken();
+ }
+
+ @Override
+ public void onRequestToken() {
+ super.onRequestToken();
+ L.eSw("onRequestToken_Token失效");
+ refreshToken();
+ }
+
+ @Override
+ public void onLeaveChannel(RtcStats stats) {
+ super.onLeaveChannel(stats);
+ L.eSw("onLeaveChannel退出頻道");
+ }
+
+ @Override
+ public void onLocalVideoStateChanged(Constants.VideoSourceType source, int state, int error) {
+ super.onLocalVideoStateChanged(source, state, error);
+ L.eSw("onLocalVideoStateChanged_source" + source + " state_" + state + " error_" + error);
+ }
+ };
+
+ private void refreshToken() {
+ LiveNetManager.get(mContext).getSwToken(new HttpCallback() {
+ @Override
+ public void onSuccess(SwTokenModel data) {
+ if (mRtcEngine != null) {
+ mRtcEngine.renewToken(data.getToken());
+ }
+ L.eSw("refreshToken_重新获取Token成功");
+ }
+
+ @Override
+ public void onError(String error) {
+
+ }
+ });
+ }
+
+ public interface onRtcEngineListener {
+ void onOpenSuccess(String channel, int uid);
+ void onUserOffline(int uid);
+ }
+
+ public void setPkContainer(FrameLayout pkContainer) {
+ this.pkContainer = pkContainer;
+ }
+
+ public void setLinkUserContainer(FrameLayout linkUserContainer) {
+ this.linkUserContainer = linkUserContainer;
+ }
+
+ public static String getChannelName(String liveUid) {
+ if (liveUid.contains("g")) {
+ return liveUid;
+ } else {
+ return CommonAppConfig.SWChannelPrefix + liveUid;
+ }
+ }
+
+ public interface onDrPkJoinSuccessListener {
+ void joinSuccess1();
+
+ void joinSuccess2();
+
+ void joinSuccess3();
+
+ void joinSuccess4();
+
+ }
+}
diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/FuDeviceUtils.java b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/FuDeviceUtils.java
new file mode 100644
index 000000000..60de92611
--- /dev/null
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/FuDeviceUtils.java
@@ -0,0 +1,607 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2023 Agora Community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ *
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package io.agora.beautyapi.faceunity.utils;
+
+import android.annotation.TargetApi;
+import android.app.ActivityManager;
+import android.content.Context;
+import android.os.Build;
+import android.text.TextUtils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+public class FuDeviceUtils {
+
+ public static final String TAG = "FuDeviceUtils";
+
+ public static final int DEVICE_LEVEL_HIGH = 2;
+ public static final int DEVICE_LEVEL_MID = 1;
+ public static final int DEVICE_LEVEL_LOW = 0;
+
+ /**
+ * The default return value of any method in this class when an
+ * error occurs or when processing fails (Currently set to -1). Use this to check if
+ * the information about the device in question was successfully obtained.
+ */
+ public static final int DEVICEINFO_UNKNOWN = -1;
+
+ private static final FileFilter CPU_FILTER = new FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ String path = pathname.getName();
+ //regex is slow, so checking char by char.
+ if (path.startsWith("cpu")) {
+ for (int i = 3; i < path.length(); i++) {
+ if (!Character.isDigit(path.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+ };
+
+
+ /**
+ * Calculates the total RAM of the device through Android API or /proc/meminfo.
+ *
+ * @param c - Context object for current running activity.
+ * @return Total RAM that the device has, or DEVICEINFO_UNKNOWN = -1 in the event of an error.
+ */
+ @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
+ public static long getTotalMemory(Context c) {
+ // memInfo.totalMem not supported in pre-Jelly Bean APIs.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
+ ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
+ ActivityManager am = (ActivityManager) c.getSystemService(Context.ACTIVITY_SERVICE);
+ am.getMemoryInfo(memInfo);
+ if (memInfo != null) {
+ return memInfo.totalMem;
+ } else {
+ return DEVICEINFO_UNKNOWN;
+ }
+ } else {
+ long totalMem = DEVICEINFO_UNKNOWN;
+ try {
+ FileInputStream stream = new FileInputStream("/proc/meminfo");
+ try {
+ totalMem = parseFileForValue("MemTotal", stream);
+ totalMem *= 1024;
+ } finally {
+ stream.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return totalMem;
+ }
+ }
+
+ /**
+ * Method for reading the clock speed of a CPU core on the device. Will read from either
+ * {@code /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq} or {@code /proc/cpuinfo}.
+ *
+ * @return Clock speed of a core on the device, or -1 in the event of an error.
+ */
+ public static int getCPUMaxFreqKHz() {
+ int maxFreq = DEVICEINFO_UNKNOWN;
+ try {
+ for (int i = 0; i < getNumberOfCPUCores(); i++) {
+ String filename =
+ "/sys/devices/system/cpu/cpu" + i + "/cpufreq/cpuinfo_max_freq";
+ File cpuInfoMaxFreqFile = new File(filename);
+ if (cpuInfoMaxFreqFile.exists() && cpuInfoMaxFreqFile.canRead()) {
+ byte[] buffer = new byte[128];
+ FileInputStream stream = new FileInputStream(cpuInfoMaxFreqFile);
+ try {
+ stream.read(buffer);
+ int endIndex = 0;
+ //Trim the first number out of the byte buffer.
+ while (Character.isDigit(buffer[endIndex]) && endIndex < buffer.length) {
+ endIndex++;
+ }
+ String str = new String(buffer, 0, endIndex);
+ Integer freqBound = Integer.parseInt(str);
+ if (freqBound > maxFreq) {
+ maxFreq = freqBound;
+ }
+ } catch (NumberFormatException e) {
+ //Fall through and use /proc/cpuinfo.
+ } finally {
+ stream.close();
+ }
+ }
+ }
+ if (maxFreq == DEVICEINFO_UNKNOWN) {
+ FileInputStream stream = new FileInputStream("/proc/cpuinfo");
+ try {
+ int freqBound = parseFileForValue("cpu MHz", stream);
+ freqBound *= 1024; //MHz -> kHz
+ if (freqBound > maxFreq) maxFreq = freqBound;
+ } finally {
+ stream.close();
+ }
+ }
+ } catch (IOException e) {
+ maxFreq = DEVICEINFO_UNKNOWN; //Fall through and return unknown.
+ }
+ return maxFreq;
+ }
+
+ /**
+ * Reads the number of CPU cores from the first available information from
+ * {@code /sys/devices/system/cpu/possible}, {@code /sys/devices/system/cpu/present},
+ * then {@code /sys/devices/system/cpu/}.
+ *
+ * @return Number of CPU cores in the phone, or DEVICEINFO_UKNOWN = -1 in the event of an error.
+ */
+ public static int getNumberOfCPUCores() {
+ if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
+ // Gingerbread doesn't support giving a single application access to both cores, but a
+ // handful of devices (Atrix 4G and Droid X2 for example) were released with a dual-core
+ // chipset and Gingerbread; that can let an app in the background run without impacting
+ // the foreground application. But for our purposes, it makes them single core.
+ return 1;
+ }
+ int cores;
+ try {
+ cores = getCoresFromFileInfo("/sys/devices/system/cpu/possible");
+ if (cores == DEVICEINFO_UNKNOWN) {
+ cores = getCoresFromFileInfo("/sys/devices/system/cpu/present");
+ }
+ if (cores == DEVICEINFO_UNKNOWN) {
+ cores = new File("/sys/devices/system/cpu/").listFiles(CPU_FILTER).length;
+ }
+ } catch (SecurityException e) {
+ cores = DEVICEINFO_UNKNOWN;
+ } catch (NullPointerException e) {
+ cores = DEVICEINFO_UNKNOWN;
+ }
+ return cores;
+ }
+
+ /**
+ * Tries to read file contents from the file location to determine the number of cores on device.
+ *
+ * @param fileLocation The location of the file with CPU information
+ * @return Number of CPU cores in the phone, or DEVICEINFO_UKNOWN = -1 in the event of an error.
+ */
+ private static int getCoresFromFileInfo(String fileLocation) {
+ InputStream is = null;
+ try {
+ is = new FileInputStream(fileLocation);
+ BufferedReader buf = new BufferedReader(new InputStreamReader(is));
+ String fileContents = buf.readLine();
+ buf.close();
+ return getCoresFromFileString(fileContents);
+ } catch (IOException e) {
+ return DEVICEINFO_UNKNOWN;
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // Do nothing.
+ }
+ }
+ }
+ }
+
+ /**
+ * Converts from a CPU core information format to number of cores.
+ *
+ * @param str The CPU core information string, in the format of "0-N"
+ * @return The number of cores represented by this string
+ */
+ private static int getCoresFromFileString(String str) {
+ if (str == null || !str.matches("0-[\\d]+$")) {
+ return DEVICEINFO_UNKNOWN;
+ }
+ return Integer.valueOf(str.substring(2)) + 1;
+ }
+
+ /**
+ * Helper method for reading values from system files, using a minimised buffer.
+ *
+ * @param textToMatch - Text in the system files to read for.
+ * @param stream - FileInputStream of the system file being read from.
+ * @return A numerical value following textToMatch in specified the system file.
+ * -1 in the event of a failure.
+ */
+ private static int parseFileForValue(String textToMatch, FileInputStream stream) {
+ byte[] buffer = new byte[1024];
+ try {
+ int length = stream.read(buffer);
+ for (int i = 0; i < length; i++) {
+ if (buffer[i] == '\n' || i == 0) {
+ if (buffer[i] == '\n') i++;
+ for (int j = i; j < length; j++) {
+ int textIndex = j - i;
+ //Text doesn't match query at some point.
+ if (buffer[j] != textToMatch.charAt(textIndex)) {
+ break;
+ }
+ //Text matches query here.
+ if (textIndex == textToMatch.length() - 1) {
+ return extractValue(buffer, j);
+ }
+ }
+ }
+ }
+ } catch (IOException e) {
+ //Ignore any exceptions and fall through to return unknown value.
+ } catch (NumberFormatException e) {
+ }
+ return DEVICEINFO_UNKNOWN;
+ }
+
+ /**
+ * Helper method used by {@link #parseFileForValue(String, FileInputStream) parseFileForValue}. Parses
+ * the next available number after the match in the file being read and returns it as an integer.
+ *
+ * @param index - The index in the buffer array to begin looking.
+ * @return The next number on that line in the buffer, returned as an int. Returns
+ * DEVICEINFO_UNKNOWN = -1 in the event that no more numbers exist on the same line.
+ */
+ private static int extractValue(byte[] buffer, int index) {
+ while (index < buffer.length && buffer[index] != '\n') {
+ if (Character.isDigit(buffer[index])) {
+ int start = index;
+ index++;
+ while (index < buffer.length && Character.isDigit(buffer[index])) {
+ index++;
+ }
+ String str = new String(buffer, 0, start, index - start);
+ return Integer.parseInt(str);
+ }
+ index++;
+ }
+ return DEVICEINFO_UNKNOWN;
+ }
+
+ /**
+ * 获取当前剩余内存(ram)
+ *
+ * @param context
+ * @return
+ */
+ public static long getAvailMemory(Context context) {
+ ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+ ActivityManager.MemoryInfo mi = new ActivityManager.MemoryInfo();
+ am.getMemoryInfo(mi);
+ return mi.availMem;
+ }
+
+ /**
+ * 获取厂商信息
+ *
+ * @return
+ */
+ public static String getBrand() {
+ return Build.BRAND;
+ }
+
+ /**
+ * 获取手机机型
+ *
+ * @return
+ */
+ public static String getModel() {
+ return Build.MODEL;
+ }
+
+ /**
+ * 获取硬件信息(cpu型号)
+ *
+ * @return
+ */
+ public static String getHardWare() {
+ try {
+ FileReader fr = new FileReader("/proc/cpuinfo");
+ BufferedReader br = new BufferedReader(fr);
+ String text;
+ String last = "";
+ while ((text = br.readLine()) != null) {
+ last = text;
+ }
+ //一般机型的cpu型号都会在cpuinfo文件的最后一行
+ if (last.contains("Hardware")) {
+ String[] hardWare = last.split(":\\s+", 2);
+ return hardWare[1];
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return Build.HARDWARE;
+ }
+
+
+ /**
+ * Level judgement based on current memory and CPU.
+ *
+ * @param context - Context object.
+ * @return
+ */
+ public static int judgeDeviceLevel(Context context) {
+ int level;
+ //有一些设备不符合下述的判断规则,则走一个机型判断模式
+ int specialDevice = judgeDeviceLevelInDeviceName();
+ if (specialDevice >= 0) return specialDevice;
+
+ int ramLevel = judgeMemory(context);
+ int cpuLevel = judgeCPU();
+ if (ramLevel == 0 || ramLevel == 1 || cpuLevel == 0) {
+ level = DEVICE_LEVEL_LOW;
+ } else {
+ if (cpuLevel > 1) {
+ level = DEVICE_LEVEL_HIGH;
+ } else {
+ level = DEVICE_LEVEL_MID;
+ }
+ }
+ LogUtils.d(TAG,"DeviceLevel: " + level);
+ return level;
+ }
+
+ /**
+ * -1 不是特定的高低端机型
+ * @return
+ */
+ private static int judgeDeviceLevelInDeviceName() {
+ String currentDeviceName = getDeviceName();
+ for (String deviceName:upscaleDevice) {
+ if (deviceName.equals(currentDeviceName)) {
+ return DEVICE_LEVEL_HIGH;
+ }
+ }
+
+ for (String deviceName:middleDevice) {
+ if (deviceName.equals(currentDeviceName)) {
+ return DEVICE_LEVEL_MID;
+ }
+ }
+
+ for (String deviceName:lowDevice) {
+ if (deviceName.equals(currentDeviceName)) {
+ return DEVICE_LEVEL_LOW;
+ }
+ }
+ return -1;
+ }
+
+ public static final String[] upscaleDevice = {"vivo X6S A","MHA-AL00","VKY-AL00","V1838A"};
+ public static final String[] lowDevice = {};
+ public static final String[] middleDevice = {"OPPO R11s","PAR-AL00","MI 8 Lite","ONEPLUS A6000","PRO 6","PRO 7 Plus"};
+
+ /**
+ * 评定内存的等级.
+ *
+ * @return
+ */
+ private static int judgeMemory(Context context) {
+ long ramMB = getTotalMemory(context) / (1024 * 1024);
+ int level = -1;
+ if (ramMB <= 2000) { //2G或以下的最低档
+ level = 0;
+ } else if (ramMB <= 3000) { //2-3G
+ level = 1;
+ } else if (ramMB <= 4000) { //4G档 2018主流中端机
+ level = 2;
+ } else if (ramMB <= 6000) { //6G档 高端机
+ level = 3;
+ } else { //6G以上 旗舰机配置
+ level = 4;
+ }
+ return level;
+ }
+
+ /**
+ * 评定CPU等级.(按频率和厂商型号综合判断)
+ *
+ * @return
+ */
+ private static int judgeCPU() {
+ int level = 0;
+ String cpuName = getHardWare();
+ int freqMHz = getCPUMaxFreqKHz() / 1024;
+
+ //一个不符合下述规律的高级白名单
+ //如果可以获取到CPU型号名称 -> 根据不同的名称走不同判定策略
+ if (!TextUtils.isEmpty(cpuName)) {
+ if (cpuName.contains("qcom") || cpuName.contains("Qualcomm")) { //高通骁龙
+ return judgeQualcommCPU(cpuName, freqMHz);
+ } else if (cpuName.contains("hi") || cpuName.contains("kirin")) { //海思麒麟
+ return judgeSkinCPU(cpuName, freqMHz);
+ } else if (cpuName.contains("MT")) {//联发科
+ return judgeMTCPU(cpuName, freqMHz);
+ }
+ }
+
+ //cpu型号无法获取的普通规则
+ if (freqMHz <= 1600) { //1.5G 低端
+ level = 0;
+ } else if (freqMHz <= 1950) { //2GHz 低中端
+ level = 1;
+ } else if (freqMHz <= 2500) { //2.2 2.3g 中高端
+ level = 2;
+ } else { //高端
+ level = 3;
+ }
+ return level;
+ }
+
+ /**
+ * 联发科芯片等级判定
+ *
+ * @return
+ */
+ private static int judgeMTCPU(String cpuName, int freqMHz) {
+ //P60之前的全是低端机 MT6771V/C
+ int level = 0;
+ int mtCPUVersion = getMTCPUVersion(cpuName);
+ if (mtCPUVersion == -1) {
+ //读取不出version 按照一个比较严格的方式来筛选出高端机
+ if (freqMHz <= 1600) { //1.5G 低端
+ level = 0;
+ } else if (freqMHz <= 2200) { //2GHz 低中端
+ level = 1;
+ } else if (freqMHz <= 2700) { //2.2 2.3g 中高端
+ level = 2;
+ } else { //高端
+ level = 3;
+ }
+ } else if (mtCPUVersion < 6771) {
+ //均为中低端机
+ if (freqMHz <= 1600) { //1.5G 低端
+ level = 0;
+ } else { //2GHz 中端
+ level = 1;
+ }
+ } else {
+ if (freqMHz <= 1600) { //1.5G 低端
+ level = 0;
+ } else if (freqMHz <= 1900) { //2GHz 低中端
+ level = 1;
+ } else if (freqMHz <= 2500) { //2.2 2.3g 中高端
+ level = 2;
+ } else { //高端
+ level = 3;
+ }
+ }
+
+ return level;
+ }
+
+ /**
+ * 通过联发科CPU型号定义 -> 获取cpu version
+ *
+ * @param cpuName
+ * @return
+ */
+ private static int getMTCPUVersion(String cpuName) {
+ //截取MT后面的四位数字
+ int cpuVersion = -1;
+ if (cpuName.length() > 5) {
+ String cpuVersionStr = cpuName.substring(2, 6);
+ try {
+ cpuVersion = Integer.valueOf(cpuVersionStr);
+ } catch (NumberFormatException exception) {
+ exception.printStackTrace();
+ }
+ }
+
+ return cpuVersion;
+ }
+
+ /**
+ * 高通骁龙芯片等级判定
+ *
+ * @return
+ */
+ private static int judgeQualcommCPU(String cpuName, int freqMHz) {
+ int level = 0;
+ //xxxx inc MSM8937 比较老的芯片
+ //7 8 xxx inc SDM710
+ if (cpuName.contains("MSM")) {
+ //老芯片
+ if (freqMHz <= 1600) { //1.5G 低端
+ level = 0;
+ } else { //2GHz 低中端
+ level = 1;
+ }
+ } else {
+ //新的芯片
+ if (freqMHz <= 1600) { //1.5G 低端
+ level = 0;
+ } else if (freqMHz <= 2000) { //2GHz 低中端
+ level = 1;
+ } else if (freqMHz <= 2500) { //2.2 2.3g 中高端
+ level = 2;
+ } else { //高端
+ level = 3;
+ }
+ }
+
+ return level;
+ }
+
+ /**
+ * 麒麟芯片等级判定
+ *
+ * @param freqMHz
+ * @return
+ */
+ private static int judgeSkinCPU(String cpuName, int freqMHz) {
+ //型号 -> kirin710之后 & 最高核心频率
+ int level = 0;
+ if (cpuName.startsWith("hi")) {
+ //这个是海思的芯片中低端
+ if (freqMHz <= 1600) { //1.5G 低端
+ level = 0;
+ } else if (freqMHz <= 2000) { //2GHz 低中端
+ level = 1;
+ }
+ } else {
+ //这个是海思麒麟的芯片
+ if (freqMHz <= 1600) { //1.5G 低端
+ level = 0;
+ } else if (freqMHz <= 2000) { //2GHz 低中端
+ level = 1;
+ } else if (freqMHz <= 2500) { //2.2 2.3g 中高端
+ level = 2;
+ } else { //高端
+ level = 3;
+ }
+ }
+
+ return level;
+ }
+
+ public static final String Nexus_6P = "Nexus 6P";
+
+ /**
+ * 获取设备名
+ *
+ * @return
+ */
+ public static String getDeviceName() {
+ String deviceName = "";
+ if (Build.MODEL != null) deviceName = Build.MODEL;
+ LogUtils.e(TAG,"deviceName: " + deviceName);
+ return deviceName;
+ }
+}
diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/LogUtils.kt b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/LogUtils.kt
new file mode 100644
index 000000000..4c1a5252d
--- /dev/null
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/LogUtils.kt
@@ -0,0 +1,57 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2023 Agora Community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package io.agora.beautyapi.faceunity.utils
+
+import io.agora.base.internal.Logging
+
+object LogUtils {
+ private const val beautyType = "FaceUnity"
+
+
+ @JvmStatic
+ fun i(tag: String, content: String, vararg args: Any) {
+ val consoleMessage = "[BeautyAPI][$beautyType] : ${String.format(content, args)}"
+ Logging.log(Logging.Severity.LS_INFO, tag, consoleMessage)
+ }
+
+ @JvmStatic
+ fun d(tag: String, content: String, vararg args: Any) {
+ val consoleMessage = "[BeautyAPI][$beautyType] : ${String.format(content, args)}"
+ Logging.d(tag, consoleMessage)
+ }
+
+ @JvmStatic
+ fun w(tag: String, content: String, vararg args: Any){
+ val consoleMessage = "[BeautyAPI][$beautyType] : ${String.format(content, args)}"
+ Logging.w(tag, consoleMessage)
+ }
+
+ @JvmStatic
+ fun e(tag: String, content: String, vararg args: Any){
+ val consoleMessage = "[BeautyAPI][$beautyType] : ${String.format(content, args)}"
+ Logging.e(tag, consoleMessage)
+ }
+
+}
\ No newline at end of file
diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/StatsHelper.kt b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/StatsHelper.kt
new file mode 100644
index 000000000..cb4cf1292
--- /dev/null
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/StatsHelper.kt
@@ -0,0 +1,80 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2023 Agora Community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package io.agora.beautyapi.faceunity.utils
+
+import android.os.Handler
+import android.os.Looper
+import io.agora.beautyapi.faceunity.BeautyStats
+import kotlin.math.max
+import kotlin.math.min
+
+class StatsHelper(
+ private val statsDuration: Long,
+ private val onStatsChanged: (BeautyStats) -> Unit
+) {
+
+ private val mMainHandler = Handler(Looper.getMainLooper())
+ private var mStartTime = 0L
+ private var mCostList = mutableListOf()
+ private var mCostMax = 0L
+ private var mCostMin = Long.MAX_VALUE
+
+ fun once(cost: Long) {
+ val curr = System.currentTimeMillis()
+ if (mStartTime == 0L) {
+ mStartTime = curr
+ } else if (curr - mStartTime >= statsDuration) {
+ mStartTime = curr
+ var total = 0L
+ mCostList.forEach {
+ total += it
+ }
+ val average = total / mCostList.size
+ val costMin = mCostMin
+ val costMax = mCostMax
+ mMainHandler.post {
+ onStatsChanged.invoke(BeautyStats(costMin, costMax, average))
+ }
+
+ mCostList.clear()
+ mCostMax = 0L
+ mCostMin = Long.MAX_VALUE
+ }
+
+ mCostList.add(cost)
+ mCostMax = max(mCostMax, cost)
+ mCostMin = min(mCostMin, cost)
+ }
+
+ fun reset() {
+ mMainHandler.removeCallbacksAndMessages(null)
+ mStartTime = 0
+ mCostList.clear()
+ mCostMax = 0L
+ mCostMin = Long.MAX_VALUE
+ }
+
+
+}
\ No newline at end of file
diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/EGLContextHelper.java b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/EGLContextHelper.java
new file mode 100644
index 000000000..97b3c7a53
--- /dev/null
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/EGLContextHelper.java
@@ -0,0 +1,210 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2023 Agora Community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package io.agora.beautyapi.faceunity.utils.egl;
+
+import static android.opengl.EGL14.EGL_CONTEXT_CLIENT_VERSION;
+
+import android.opengl.GLDebugHelper;
+
+import javax.microedition.khronos.egl.EGL10;
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.egl.EGLContext;
+import javax.microedition.khronos.egl.EGLDisplay;
+import javax.microedition.khronos.egl.EGLSurface;
+
+import io.agora.beautyapi.faceunity.utils.LogUtils;
+
+public class EGLContextHelper {
+ private static final String DEBUG_TAG = "EGLContextManager";
+ private final int mRedSize = 8;
+ private final int mGreenSize = 8;
+ private final int mBlueSize = 8;
+ private final int mAlphaSize = 0;
+ private final int mDepthSize = 16;
+ private final int mStencilSize = 0;
+ private final int mRenderType = 4;
+ public EGLContextHelper(){}
+
+ public void initEGL(EGLContext shareContext) throws Exception {
+ mEGL = (EGL10) GLDebugHelper.wrap(EGLContext.getEGL(),
+ GLDebugHelper.CONFIG_CHECK_GL_ERROR
+ | GLDebugHelper.CONFIG_CHECK_THREAD, null);
+
+ if (mEGL == null) {
+ throw new Exception("Couldn't get EGL");
+ }
+
+ mGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
+
+ if (mGLDisplay == null) {
+ throw new Exception("Couldn't get display for GL");
+ }
+
+ int[] curGLVersion = new int[2];
+ mEGL.eglInitialize(mGLDisplay, curGLVersion);
+
+ LogUtils.i(DEBUG_TAG, "GL version = " + curGLVersion[0] + "."
+ + curGLVersion[1]);
+
+ int[] num_config = new int[1];
+ if(!mEGL.eglChooseConfig(mGLDisplay, mConfigSpec, null, 1,
+ num_config)){
+ throw new IllegalArgumentException("eglChooseConfig failed");
+ }
+ int numConfigs = num_config[0];
+ if (numConfigs <= 0) {
+ throw new IllegalArgumentException(
+ "No configs match configSpec");
+ }
+
+ EGLConfig[] configs = new EGLConfig[numConfigs];
+ if (!mEGL.eglChooseConfig(mGLDisplay, mConfigSpec, configs, numConfigs,
+ num_config)) {
+ throw new IllegalArgumentException("eglChooseConfig#2 failed");
+ }
+ mGLConfig = chooseConfig(mEGL, mGLDisplay, configs);
+ if (mGLConfig == null) {
+ mGLConfig = configs[0];
+ }
+
+ int[] surfaceAttribs = {
+ EGL10.EGL_WIDTH, 1,
+ EGL10.EGL_HEIGHT, 1,
+ EGL10.EGL_NONE
+ };
+ mGLSurface = mEGL.eglCreatePbufferSurface(mGLDisplay, mGLConfig, surfaceAttribs);
+
+ if (mGLSurface == null) {
+ throw new Exception("Couldn't create new surface");
+ }
+
+ int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
+ mGLContext = mEGL.eglCreateContext(mGLDisplay, mGLConfig,
+ shareContext, attrib_list);
+
+ if (mGLContext == null) {
+ throw new Exception("Couldn't create new context");
+ }
+
+
+// if (!mEGL.eglMakeCurrent(mGLDisplay, mGLSurface, mGLSurface, mGLContext)) {
+// throw new Exception("Failed to eglMakeCurrent");
+// }
+
+ }
+
+ public EGLContext getEGLContext() {
+ return mGLContext;
+ }
+
+ public EGLDisplay getGLDisplay() {
+ return mGLDisplay;
+ }
+
+ public EGLConfig getGLConfig() {
+ return mGLConfig;
+ }
+
+ public EGLSurface getGLSurface() {
+ return mGLSurface;
+ }
+
+ public EGL10 getEGL() {
+ return mEGL;
+ }
+
+ EGL10 mEGL;
+ EGLDisplay mGLDisplay;
+ EGLConfig mGLConfig;
+ EGLSurface mGLSurface;
+ EGLContext mGLContext;
+
+ int[] mConfigSpec = new int[]{
+ EGL10.EGL_RED_SIZE, mRedSize,
+ EGL10.EGL_GREEN_SIZE, mGreenSize,
+ EGL10.EGL_BLUE_SIZE, mBlueSize,
+ EGL10.EGL_ALPHA_SIZE, mAlphaSize,
+ EGL10.EGL_DEPTH_SIZE, mDepthSize,
+ EGL10.EGL_STENCIL_SIZE, mStencilSize,
+ EGL10.EGL_RENDERABLE_TYPE, mRenderType,//egl版本 2.0
+ EGL10.EGL_NONE};
+
+ public void release() {
+ mEGL.eglMakeCurrent(mGLDisplay, EGL10.EGL_NO_SURFACE,
+ EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
+ mEGL.eglDestroySurface(mGLDisplay, mGLSurface);
+ mEGL.eglDestroyContext(mGLDisplay, mGLContext);
+ mEGL.eglTerminate(mGLDisplay);
+
+ LogUtils.i(DEBUG_TAG, "GL Cleaned up");
+ }
+
+ public boolean eglMakeCurrent(){
+ if(mGLContext == EGL10.EGL_NO_CONTEXT){
+ return false;
+ }else{
+ return mEGL.eglMakeCurrent(mGLDisplay, mGLSurface, mGLSurface, mGLContext);
+ }
+ }
+
+ public boolean eglMakeNoCurrent(){
+ return mEGL.eglMakeCurrent(mGLDisplay, EGL10.EGL_NO_SURFACE,
+ EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
+ }
+
+ private EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
+ EGLConfig[] configs) {
+ for (EGLConfig config : configs) {
+ int d = findConfigAttrib(egl, display, config,
+ EGL10.EGL_DEPTH_SIZE, 0);
+ int s = findConfigAttrib(egl, display, config,
+ EGL10.EGL_STENCIL_SIZE, 0);
+ if ((d >= mDepthSize) && (s >= mStencilSize)) {
+ int r = findConfigAttrib(egl, display, config,
+ EGL10.EGL_RED_SIZE, 0);
+ int g = findConfigAttrib(egl, display, config,
+ EGL10.EGL_GREEN_SIZE, 0);
+ int b = findConfigAttrib(egl, display, config,
+ EGL10.EGL_BLUE_SIZE, 0);
+ int a = findConfigAttrib(egl, display, config,
+ EGL10.EGL_ALPHA_SIZE, 0);
+ if ((r == mRedSize) && (g == mGreenSize)
+ && (b == mBlueSize) && (a == mAlphaSize)) {
+ return config;
+ }
+ }
+ }
+ return null;
+ }
+
+ private int findConfigAttrib(EGL10 egl, EGLDisplay display,
+ EGLConfig config, int attribute, int defaultValue) {
+ int[] value = new int[1];
+ if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
+ return value[0];
+ }
+ return defaultValue;
+ }
+}
diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/GLCopyHelper.java b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/GLCopyHelper.java
new file mode 100644
index 000000000..b475f39d9
--- /dev/null
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/GLCopyHelper.java
@@ -0,0 +1,84 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2023 Agora Community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package io.agora.beautyapi.faceunity.utils.egl;
+
+import android.opengl.GLES11Ext;
+import android.opengl.GLES20;
+import android.opengl.GLES30;
+
+public class GLCopyHelper {
+ private final int bufferCount;
+
+ public GLCopyHelper(){
+ this(1);
+ }
+
+ public GLCopyHelper(int bufferCount){
+ this.bufferCount = bufferCount;
+ }
+
+ private int[] mDstFrameBuffer;
+ private int[] mSrcFrameBuffer;
+
+ public void copy2DTextureToOesTexture(
+ int srcTexture,
+ int dstTexture,
+ int width, int height,
+ int index){
+ if(mDstFrameBuffer == null){
+ mDstFrameBuffer = new int[bufferCount];
+ GLES20.glGenFramebuffers(bufferCount, mDstFrameBuffer, 0);
+ }
+
+ if(mSrcFrameBuffer == null){
+ mSrcFrameBuffer = new int[bufferCount];
+ GLES20.glGenFramebuffers(bufferCount, mSrcFrameBuffer, 0);
+ }
+
+ GLES30.glBindFramebuffer(GLES30.GL_READ_FRAMEBUFFER, mSrcFrameBuffer[index]);
+ GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, srcTexture);
+ GLES30.glFramebufferTexture2D(GLES30.GL_READ_FRAMEBUFFER, GLES30.GL_COLOR_ATTACHMENT0, GLES30.GL_TEXTURE_2D, srcTexture, 0);
+ GLES30.glBindFramebuffer(GLES30.GL_DRAW_FRAMEBUFFER, mDstFrameBuffer[index]);
+ GLES30.glFramebufferTexture2D(GLES30.GL_DRAW_FRAMEBUFFER,
+ GLES30.GL_COLOR_ATTACHMENT0, GLES11Ext.GL_TEXTURE_EXTERNAL_OES, dstTexture, 0);
+ GLES30.glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GLES30.GL_COLOR_BUFFER_BIT, GLES30.GL_LINEAR);
+ GLES30.glBindFramebuffer(GLES30.GL_DRAW_FRAMEBUFFER, 0);
+ GLES30.glBindFramebuffer(GLES30.GL_READ_FRAMEBUFFER, 0);
+ GLES30.glBindTexture(GLES30.GL_TEXTURE_2D, 0);
+ GLES30.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, 0);
+ }
+
+ public void release(){
+ if(mDstFrameBuffer != null){
+ GLES20.glDeleteFramebuffers(mDstFrameBuffer.length, mDstFrameBuffer, 0);
+ mDstFrameBuffer = null;
+ }
+
+ if(mSrcFrameBuffer != null){
+ GLES20.glDeleteFramebuffers(mSrcFrameBuffer.length, mSrcFrameBuffer, 0);
+ mSrcFrameBuffer = null;
+ }
+ }
+}
diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/GLFrameBuffer.java b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/GLFrameBuffer.java
new file mode 100644
index 000000000..3b61c1c73
--- /dev/null
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/GLFrameBuffer.java
@@ -0,0 +1,205 @@
+package io.agora.beautyapi.faceunity.utils.egl;
+
+import android.graphics.Matrix;
+import android.opengl.GLES11Ext;
+import android.opengl.GLES20;
+
+import io.agora.base.internal.video.EglBase;
+import io.agora.base.internal.video.GlRectDrawer;
+import io.agora.base.internal.video.RendererCommon;
+
+public class GLFrameBuffer {
+
+ private int mFramebufferId = -1;
+ private int mTextureId = -1;
+ private int mWidth, mHeight, mRotation;
+ private boolean isFlipV, isFlipH, isTextureInner, isTextureChanged, isSizeChanged;
+
+ private RendererCommon.GlDrawer drawer;
+
+ private float[] mTexMatrix = GLUtils.IDENTITY_MATRIX;
+
+ public GLFrameBuffer() {
+
+ }
+
+ public boolean setSize(int width, int height) {
+ if (mWidth != width || mHeight != height) {
+ mWidth = width;
+ mHeight = height;
+ isSizeChanged = true;
+ return true;
+ }
+ return false;
+ }
+
+ public void setRotation(int rotation) {
+ if (mRotation != rotation) {
+ mRotation = rotation;
+ }
+ }
+
+ public void setFlipV(boolean flipV) {
+ if (isFlipV != flipV) {
+ isFlipV = flipV;
+ }
+ }
+
+ public void setFlipH(boolean flipH) {
+ if (isFlipH != flipH) {
+ isFlipH = flipH;
+ }
+ }
+
+ public void setTextureId(int textureId){
+ if(mTextureId != textureId){
+ deleteTexture();
+ mTextureId = textureId;
+ isTextureChanged = true;
+ }
+ }
+
+ public int getTextureId(){
+ return mTextureId;
+ }
+
+ public void setTexMatrix(float[] matrix) {
+ if (matrix != null) {
+ mTexMatrix = matrix;
+ } else {
+ mTexMatrix = GLUtils.IDENTITY_MATRIX;
+ }
+ }
+
+ public void resetTransform(){
+ mTexMatrix = GLUtils.IDENTITY_MATRIX;
+ isFlipH = isFlipV = false;
+ mRotation = 0;
+ }
+
+ public int process(int textureId, int textureType) {
+ if (mWidth <= 0 && mHeight <= 0) {
+ throw new RuntimeException("setSize firstly!");
+ }
+
+ if(mTextureId == -1){
+ mTextureId = createTexture(mWidth, mHeight);
+ bindFramebuffer(mTextureId);
+ isTextureInner = true;
+ }else if(isTextureInner && isSizeChanged){
+ GLES20.glDeleteTextures(1, new int[]{mTextureId}, 0);
+ mTextureId = createTexture(mWidth, mHeight);
+ bindFramebuffer(mTextureId);
+ }else if(isTextureChanged){
+ bindFramebuffer(mTextureId);
+ }
+ isTextureChanged = false;
+ isSizeChanged = false;
+
+ if(drawer == null){
+ drawer = new GlRectDrawer();
+ }
+
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFramebufferId);
+ GLUtils.checkGlError("glBindFramebuffer");
+
+ Matrix transform = RendererCommon.convertMatrixToAndroidGraphicsMatrix(mTexMatrix);
+ transform.preTranslate(0.5f, 0.5f);
+ transform.preRotate(mRotation, 0.f, 0.f);
+ transform.preScale(
+ isFlipH ? -1.f: 1.f,
+ isFlipV ? -1.f: 1.f
+ );
+ transform.preTranslate(-0.5f, -0.5f);
+ float[] matrix = RendererCommon.convertMatrixFromAndroidGraphicsMatrix(transform);
+
+ synchronized (EglBase.lock){
+ if(textureType == GLES11Ext.GL_TEXTURE_EXTERNAL_OES){
+ drawer.drawOes(textureId,matrix, mWidth, mHeight, 0, 0, mWidth, mHeight);
+
+ }else{
+ drawer.drawRgb(textureId, matrix, mWidth, mHeight, 0, 0, mWidth, mHeight);
+ }
+ }
+
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_NONE);
+ GLES20.glFinish();
+
+ return mTextureId;
+ }
+
+ public void release(){
+ deleteTexture();
+ deleteFramebuffer();
+
+ if(drawer != null){
+ drawer.release();
+ drawer = null;
+ }
+ }
+
+
+ private void deleteFramebuffer() {
+ if (mFramebufferId != -1) {
+ GLES20.glDeleteFramebuffers(1, new int[]{mFramebufferId}, 0);
+ mFramebufferId = -1;
+ }
+ }
+
+ public int createTexture(int width, int height){
+ int[] textures = new int[1];
+ GLES20.glGenTextures(1, textures, 0);
+ GLUtils.checkGlError("glGenTextures");
+ int textureId = textures[0];
+
+ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
+ GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0,
+ GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
+
+ GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
+ GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
+ GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
+ GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
+ GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
+ GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
+ GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,
+ GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
+
+ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, GLES20.GL_NONE);
+
+ return textureId;
+ }
+
+ public void resizeTexture(int textureId, int width, int height) {
+ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureId);
+ GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0,
+ GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
+ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, GLES20.GL_NONE);
+ }
+
+ private void deleteTexture() {
+ if (isTextureInner && mTextureId != -1) {
+ GLES20.glDeleteTextures(1, new int[]{mTextureId}, 0);
+ }
+ isTextureInner = false;
+ mTextureId = -1;
+ }
+
+ private void bindFramebuffer(int textureId) {
+ if(mFramebufferId == -1){
+ int[] framebuffers = new int[1];
+ GLES20.glGenFramebuffers(1, framebuffers, 0);
+ GLUtils.checkGlError("glGenFramebuffers");
+ mFramebufferId = framebuffers[0];
+ }
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, mFramebufferId);
+ GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,
+ GLES20.GL_COLOR_ATTACHMENT0,
+ GLES20.GL_TEXTURE_2D,
+ textureId, 0);
+
+ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, GLES20.GL_NONE);
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_NONE);
+ }
+
+}
diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/GLTextureBufferQueue.kt b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/GLTextureBufferQueue.kt
new file mode 100644
index 000000000..c8d193f8f
--- /dev/null
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/GLTextureBufferQueue.kt
@@ -0,0 +1,180 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2023 Agora Community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package io.agora.beautyapi.faceunity.utils.egl
+
+import android.opengl.GLES20
+import android.util.Log
+import android.util.Size
+import java.util.concurrent.ConcurrentLinkedQueue
+
+class GLTextureBufferQueue(
+ private val glFrameBuffer: GLFrameBuffer = GLFrameBuffer(),
+ private val cacheCount: Int = 6,
+ private val loggable: Boolean = false
+) {
+ private val TAG = "GLTextureBufferQueue"
+
+ private var cacheIndex = 0
+ private val cacheTextureOuts = arrayOfNulls(cacheCount)
+ private val textureIdQueue = ConcurrentLinkedQueue()
+
+
+ fun enqueue(iN: TextureIn): Int {
+ var size = textureIdQueue.size
+ if (size < cacheCount) {
+ var out = cacheTextureOuts[cacheIndex]
+ val outSize = when (iN.rotation) {
+ 90, 270 -> Size(iN.height, iN.width)
+ else -> Size(iN.width, iN.height)
+ }
+
+ if (out == null) {
+ val textureId = glFrameBuffer.createTexture(outSize.width, outSize.height)
+ out = TextureOut(
+ 0,
+ textureId,
+ GLES20.GL_TEXTURE_2D,
+ outSize.width,
+ outSize.height,
+ iN.isFrontCamera,
+ iN.isMirror,
+ )
+ cacheTextureOuts[cacheIndex] = out
+ } else if (out.width != outSize.width || out.height != outSize.height) {
+ glFrameBuffer.resizeTexture(out.textureId, outSize.width, outSize.height)
+ out = TextureOut(
+ 0,
+ out.textureId,
+ out.textureType,
+ outSize.width,
+ outSize.height,
+ iN.isFrontCamera,
+ iN.isMirror,
+ )
+ cacheTextureOuts[cacheIndex] = out
+ } else if(out.isFrontCamera != iN.isFrontCamera){
+ out = TextureOut(
+ 0,
+ out.textureId,
+ out.textureType,
+ out.width,
+ out.height,
+ iN.isFrontCamera,
+ iN.isMirror,
+ )
+ cacheTextureOuts[cacheIndex] = out
+ }
+
+ glFrameBuffer.textureId = out.textureId
+ glFrameBuffer.setSize(out.width, out.height)
+ glFrameBuffer.resetTransform()
+ glFrameBuffer.setRotation(iN.rotation)
+ if (iN.transform != null) {
+ glFrameBuffer.setTexMatrix(iN.transform)
+ var flipH = iN.isFrontCamera
+ if(iN.isMirror){
+ flipH = !flipH
+ }
+ glFrameBuffer.setFlipH(flipH)
+ } else {
+ var flipH = !iN.isFrontCamera
+ if(iN.isMirror){
+ flipH = !flipH
+ }
+ glFrameBuffer.setFlipH(flipH)
+ }
+ glFrameBuffer.setFlipV(iN.flipV)
+ glFrameBuffer.process(iN.textureId, iN.textureType)
+ out.index = cacheIndex
+ out.tag = iN.tag
+ textureIdQueue.offer(out)
+ if(loggable){
+ Log.d(TAG, "TextureIdQueue enqueue index=$cacheIndex, size=$size")
+ }
+ cacheIndex = (cacheIndex + 1) % cacheCount
+ size++
+
+ } else {
+ if(loggable){
+ Log.e(TAG, "TextureIdQueue is full!!")
+ }
+ }
+
+ return size
+ }
+
+ fun dequeue(remove: Boolean = true): TextureOut? {
+ val size = textureIdQueue.size
+ val poll = if(remove){
+ textureIdQueue.poll()
+ }else{
+ textureIdQueue.peek()
+ }
+ if(loggable){
+ Log.d(TAG, "TextureIdQueue dequeue index=${poll?.index}, size=$size")
+ }
+ return poll
+ }
+
+ fun reset() {
+ cacheIndex = 0
+ textureIdQueue.clear()
+ }
+
+ fun release() {
+ cacheIndex = 0
+ cacheTextureOuts.forEachIndexed { index, textureOut ->
+ if (textureOut != null) {
+ GLES20.glDeleteTextures(1, intArrayOf(textureOut.textureId), 0)
+ cacheTextureOuts[index] = null
+ }
+ }
+ textureIdQueue.clear()
+ glFrameBuffer.release()
+ }
+
+ data class TextureIn(
+ val textureId: Int,
+ val textureType: Int,
+ val width: Int,
+ val height: Int,
+ val rotation: Int,
+ val flipV: Boolean,
+ val isFrontCamera: Boolean,
+ val isMirror: Boolean,
+ val transform: FloatArray?,
+ val tag: Any? = null
+ )
+
+ data class TextureOut(
+ var index: Int = 0,
+ val textureId: Int,
+ val textureType: Int,
+ val width: Int,
+ val height: Int,
+ val isFrontCamera: Boolean,
+ var tag: Any? = null
+ )
+}
\ No newline at end of file
diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/GLUtils.java b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/GLUtils.java
new file mode 100644
index 000000000..e56f743ec
--- /dev/null
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/GLUtils.java
@@ -0,0 +1,279 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2023 Agora Community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package io.agora.beautyapi.faceunity.utils.egl;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.ImageFormat;
+import android.graphics.Rect;
+import android.graphics.YuvImage;
+import android.opengl.GLES11Ext;
+import android.opengl.GLES20;
+import android.opengl.Matrix;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.IntBuffer;
+import java.util.Objects;
+
+import javax.microedition.khronos.egl.EGL10;
+import javax.microedition.khronos.egl.EGLContext;
+
+import io.agora.beautyapi.faceunity.utils.LogUtils;
+
+public class GLUtils {
+ private static final String TAG = "GLUtils";
+ public static final float[] IDENTITY_MATRIX = new float[16];
+
+ static {
+ Matrix.setIdentityM(IDENTITY_MATRIX, 0);
+ }
+
+ private GLUtils() {
+ }
+
+ public static Bitmap getTexture2DImage(int textureID, int width, int height) {
+ try {
+ int[] oldFboId = new int[1];
+ GLES20.glGetIntegerv(GLES20.GL_FRAMEBUFFER_BINDING, IntBuffer.wrap(oldFboId));
+
+ int[] framebuffers = new int[1];
+ GLES20.glGenFramebuffers(1, framebuffers, 0);
+ int framebufferId = framebuffers[0];
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, framebufferId);
+
+ int[] renderbuffers = new int[1];
+ GLES20.glGenRenderbuffers(1, renderbuffers, 0);
+ int renderId = renderbuffers[0];
+ GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, renderId);
+ GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, width, height);
+
+ GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, textureID, 0);
+ GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, renderId);
+ if (GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER) != GLES20.GL_FRAMEBUFFER_COMPLETE) {
+ LogUtils.e(TAG, "Framebuffer error");
+ }
+
+ ByteBuffer rgbaBuf = ByteBuffer.allocateDirect(width * height * 4);
+ rgbaBuf.position(0);
+ GLES20.glReadPixels(0, 0, width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, rgbaBuf);
+
+ Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ bitmap.copyPixelsFromBuffer(rgbaBuf);
+
+ GLES20.glDeleteRenderbuffers(1, IntBuffer.wrap(framebuffers));
+ GLES20.glDeleteFramebuffers(1, IntBuffer.allocate(framebufferId));
+
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, oldFboId[0]);
+
+ return bitmap;
+ } catch (Exception e) {
+ LogUtils.e(TAG, e.toString());
+ }
+ return null;
+ }
+
+ public static Bitmap getTextureOESImage(int textureID, int width, int height) {
+ try {
+ int[] oldFboId = new int[1];
+ GLES20.glGetIntegerv(GLES20.GL_FRAMEBUFFER_BINDING, IntBuffer.wrap(oldFboId));
+
+ int[] framebuffers = new int[1];
+ GLES20.glGenFramebuffers(1, framebuffers, 0);
+ int framebufferId = framebuffers[0];
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, framebufferId);
+
+ int[] renderbuffers = new int[1];
+ GLES20.glGenRenderbuffers(1, renderbuffers, 0);
+ int renderId = renderbuffers[0];
+ GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER, renderId);
+ GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER, GLES20.GL_DEPTH_COMPONENT16, width, height);
+
+ GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES11Ext.GL_TEXTURE_EXTERNAL_OES, textureID, 0);
+ GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER, renderId);
+ if (GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER) != GLES20.GL_FRAMEBUFFER_COMPLETE) {
+ LogUtils.e(TAG, "Framebuffer error");
+ }
+
+ ByteBuffer rgbaBuf = ByteBuffer.allocateDirect(width * height * 4);
+ rgbaBuf.position(0);
+ GLES20.glReadPixels(0, 0, width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, rgbaBuf);
+
+ Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ bitmap.copyPixelsFromBuffer(rgbaBuf);
+
+ GLES20.glDeleteRenderbuffers(1, IntBuffer.wrap(framebuffers));
+ GLES20.glDeleteFramebuffers(1, IntBuffer.allocate(framebufferId));
+
+ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, oldFboId[0]);
+
+ return bitmap;
+ } catch (Exception e) {
+ LogUtils.e(TAG, e.toString());
+ }
+ return null;
+ }
+
+ public static Bitmap nv21ToBitmap(byte[] nv21, int width, int height) {
+ Bitmap bitmap = null;
+ try {
+ YuvImage image = new YuvImage(nv21, ImageFormat.NV21, width, height, null);
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ image.compressToJpeg(new Rect(0, 0, width, height), 80, stream);
+ bitmap = BitmapFactory.decodeByteArray(stream.toByteArray(), 0, stream.size());
+ stream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return bitmap;
+ }
+
+ private static Bitmap readBitmap(int width, int height) {
+ ByteBuffer rgbaBuf = ByteBuffer.allocateDirect(width * height * 4);
+ rgbaBuf.position(0);
+ GLES20.glReadPixels(0, 0, width, height, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, rgbaBuf);
+
+ Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+ bitmap.copyPixelsFromBuffer(rgbaBuf);
+ return bitmap;
+ }
+
+ public static float[] createTransformMatrix(int rotation, boolean flipH, boolean flipV) {
+ float[] renderMVPMatrix = new float[16];
+ float[] tmp = new float[16];
+ Matrix.setIdentityM(tmp, 0);
+
+ boolean _flipH = flipH;
+ boolean _flipV = flipV;
+ if (rotation % 180 != 0) {
+ _flipH = flipV;
+ _flipV = flipH;
+ }
+
+ if (_flipH) {
+ Matrix.rotateM(tmp, 0, tmp, 0, 180, 0, 1f, 0);
+ }
+ if (_flipV) {
+ Matrix.rotateM(tmp, 0, tmp, 0, 180, 1f, 0f, 0);
+ }
+
+ float _rotation = rotation;
+ if (_rotation != 0) {
+ if (_flipH != _flipV) {
+ _rotation *= -1;
+ }
+ Matrix.rotateM(tmp, 0, tmp, 0, _rotation, 0, 0, 1);
+ }
+
+ Matrix.setIdentityM(renderMVPMatrix, 0);
+ Matrix.multiplyMM(renderMVPMatrix, 0, tmp, 0, renderMVPMatrix, 0);
+ return renderMVPMatrix;
+ }
+
+ public static EGLContext getCurrGLContext() {
+ EGL10 egl = (EGL10) javax.microedition.khronos.egl.EGLContext.getEGL();
+ if (egl != null && !Objects.equals(egl.eglGetCurrentContext(), EGL10.EGL_NO_CONTEXT)) {
+ return egl.eglGetCurrentContext();
+ }
+ return null;
+ }
+
+ public static void checkGlError(String op) {
+ int error = GLES20.glGetError();
+ if (error != GLES20.GL_NO_ERROR) {
+ String msg = op + ": glError 0x" + Integer.toHexString(error);
+ LogUtils.e(TAG, msg);
+ throw new RuntimeException(msg);
+ }
+ }
+
+ public static int createProgram(String vertexSource, String fragmentSource) {
+ int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource);
+ if (vertexShader == 0) {
+ return 0;
+ }
+ int pixelShader = loadShader(GLES20.GL_FRAGMENT_SHADER, fragmentSource);
+ if (pixelShader == 0) {
+ return 0;
+ }
+ int program = GLES20.glCreateProgram();
+ checkGlError("glCreateProgram");
+ if (program == 0) {
+ LogUtils.e(TAG, "Could not create program");
+ }
+ GLES20.glAttachShader(program, vertexShader);
+ checkGlError("glAttachShader");
+ GLES20.glAttachShader(program, pixelShader);
+ checkGlError("glAttachShader");
+ GLES20.glLinkProgram(program);
+ int[] linkStatus = new int[1];
+ GLES20.glGetProgramiv(program, GLES20.GL_LINK_STATUS, linkStatus, 0);
+ if (linkStatus[0] != GLES20.GL_TRUE) {
+ LogUtils.e(TAG, "Could not link program: ");
+ LogUtils.e(TAG, GLES20.glGetProgramInfoLog(program));
+ GLES20.glDeleteProgram(program);
+ program = 0;
+ }
+ return program;
+ }
+
+ public static int loadShader(int shaderType, String source) {
+ int shader = GLES20.glCreateShader(shaderType);
+ checkGlError("glCreateShader type=" + shaderType);
+ GLES20.glShaderSource(shader, source);
+ GLES20.glCompileShader(shader);
+ int[] compiled = new int[1];
+ GLES20.glGetShaderiv(shader, GLES20.GL_COMPILE_STATUS, compiled, 0);
+ if (compiled[0] == 0) {
+ LogUtils.e(TAG, "Could not compile shader " + shaderType + ":");
+ LogUtils.e(TAG, " " + GLES20.glGetShaderInfoLog(shader));
+ GLES20.glDeleteShader(shader);
+ shader = 0;
+ }
+ return shader;
+ }
+
+ public static int createTexture(int textureTarget, Bitmap bitmap, int minFilter,
+ int magFilter, int wrapS, int wrapT) {
+ int[] textureHandle = new int[1];
+
+ GLES20.glGenTextures(1, textureHandle, 0);
+ checkGlError("glGenTextures");
+ GLES20.glBindTexture(textureTarget, textureHandle[0]);
+ checkGlError("glBindTexture " + textureHandle[0]);
+ GLES20.glTexParameterf(textureTarget, GLES20.GL_TEXTURE_MIN_FILTER, minFilter);
+ GLES20.glTexParameterf(textureTarget, GLES20.GL_TEXTURE_MAG_FILTER, magFilter); //线性插值
+ GLES20.glTexParameteri(textureTarget, GLES20.GL_TEXTURE_WRAP_S, wrapS);
+ GLES20.glTexParameteri(textureTarget, GLES20.GL_TEXTURE_WRAP_T, wrapT);
+
+ if (bitmap != null) {
+ android.opengl.GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
+ }
+
+ checkGlError("glTexParameter");
+ return textureHandle[0];
+ }
+}
diff --git a/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/TextureProcessHelper.kt b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/TextureProcessHelper.kt
new file mode 100644
index 000000000..1451750b4
--- /dev/null
+++ b/lib_faceunity/src/main/java/io/agora/beautyapi/faceunity/utils/egl/TextureProcessHelper.kt
@@ -0,0 +1,214 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2023 Agora Community
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package io.agora.beautyapi.faceunity.utils.egl
+
+import android.opengl.GLES20
+import io.agora.beautyapi.faceunity.utils.LogUtils
+import java.util.concurrent.Callable
+import java.util.concurrent.ConcurrentLinkedQueue
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.Executors
+import java.util.concurrent.Future
+import javax.microedition.khronos.egl.EGLContext
+
+class TextureProcessHelper(
+ private val cacheCount: Int = 2
+) {
+ private val TAG = "TextureProcessHelper"
+ private val glTextureBufferQueueIn = GLTextureBufferQueue(cacheCount = cacheCount, loggable = true)
+ private val glTextureBufferQueueOut = GLTextureBufferQueue(cacheCount = cacheCount, loggable = false)
+ private val glFrameBuffer = GLFrameBuffer()
+ private val futureQueue = ConcurrentLinkedQueue>()
+ private val workerThread = Executors.newSingleThreadExecutor()
+ private val eglContextHelper =
+ EGLContextHelper()
+ private var eglContextBase: EGLContext? = null
+ private var isReleased = false
+ private var filter: ((GLTextureBufferQueue.TextureOut) -> Int)? = null
+ private var isBegin = false
+ private var frameIndex = 0
+
+ fun setFilter(filter: (GLTextureBufferQueue.TextureOut) -> Int) {
+ this.filter = filter
+ }
+
+ fun process(
+ texId: Int, texType: Int,
+ width: Int, height: Int, rotation: Int,
+ transform: FloatArray,
+ isFrontCamera: Boolean,
+ isMirror: Boolean
+ ): Int {
+ if (isReleased) {
+ return -1
+ }
+ val currGLContext = GLUtils.getCurrGLContext() ?: return -1
+
+ if (eglContextBase == null) {
+ eglContextBase = currGLContext
+ executeSync {
+ eglContextHelper.initEGL(eglContextBase)
+ eglContextHelper.eglMakeCurrent()
+ }
+ } else if (eglContextBase != currGLContext) {
+ eglContextBase = currGLContext
+ executeSync {
+ eglContextHelper.release()
+ eglContextHelper.initEGL(eglContextBase)
+ eglContextHelper.eglMakeCurrent()
+ }
+ }
+
+ glTextureBufferQueueIn.enqueue(
+ GLTextureBufferQueue.TextureIn(
+ texId,
+ texType,
+ width,
+ height,
+ rotation,
+ false,
+ isFrontCamera,
+ isMirror,
+ transform,
+ frameIndex
+ )
+ )
+ frameIndex ++
+
+ if (isReleased) {
+ return -1
+ }
+
+ futureQueue.offer(workerThread.submit(Callable {
+ if (isReleased) {
+ return@Callable -2
+ }
+
+ val frame = glTextureBufferQueueIn.dequeue(false) ?: return@Callable -2
+ val filterTexId = filter?.invoke(frame) ?: -1
+ if (filterTexId >= 0) {
+ glTextureBufferQueueOut.enqueue(
+ GLTextureBufferQueue.TextureIn(
+ filterTexId,
+ GLES20.GL_TEXTURE_2D,
+ frame.width,
+ frame.height,
+ 0,
+ false,
+ false,
+ true,
+ null,
+ frame.tag
+ )
+ )
+ } else {
+ glTextureBufferQueueOut.enqueue(
+ GLTextureBufferQueue.TextureIn(
+ frame.textureId,
+ frame.textureType,
+ frame.width,
+ frame.height,
+ 0,
+ false,
+ false,
+ true,
+ null,
+ frame.tag
+ )
+ )
+ }
+ glTextureBufferQueueIn.dequeue(true)
+ return@Callable 0
+ }))
+
+ var ret = 0
+ if (isBegin || futureQueue.size >= cacheCount) {
+ isBegin = true
+ try {
+ val get = futureQueue.poll()?.get() ?: -1
+ if (get == 0) {
+ val dequeue = glTextureBufferQueueOut.dequeue() ?: return -1
+ glFrameBuffer.setSize(dequeue.width, dequeue.height)
+ ret = glFrameBuffer.process(dequeue.textureId, dequeue.textureType)
+ }
+ }catch (e: Exception){
+ LogUtils.e(TAG, "process end with exception: $e")
+ }
+ }
+
+ return ret
+ }
+
+ fun reset(){
+ if(frameIndex == 0){
+ return
+ }
+ isBegin = false
+ frameIndex = 0
+ var future = futureQueue.poll()
+ while (future != null) {
+ future.cancel(true)
+ future = futureQueue.poll()
+ }
+ glTextureBufferQueueIn.reset()
+// glFrameBuffer.release()
+ executeSync {
+ glTextureBufferQueueOut.reset()
+ }
+ }
+
+ fun size() = futureQueue.size
+
+ fun release() {
+ isReleased = true
+ filter = null
+ isBegin = false
+ frameIndex = 0
+ var future = futureQueue.poll()
+ while (future != null) {
+ future.cancel(true)
+ future = futureQueue.poll()
+ }
+ glTextureBufferQueueIn.release()
+ glFrameBuffer.release()
+ executeSync {
+ glTextureBufferQueueOut.release()
+ if (eglContextBase != null) {
+ eglContextHelper.release()
+ eglContextBase = null
+ }
+ }
+ workerThread.shutdown()
+ }
+
+ fun executeSync(run: () -> Unit) {
+ val latch = CountDownLatch(1)
+ workerThread.execute {
+ run.invoke()
+ latch.countDown()
+ }
+ latch.await()
+ }
+}
\ No newline at end of file
diff --git a/live/build.gradle b/live/build.gradle
index 323d07a01..3828a60ac 100644
--- a/live/build.gradle
+++ b/live/build.gradle
@@ -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"
}
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: ':common')
api project(path:':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"
}
\ No newline at end of file
+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"
}
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"
}
\ No newline at end of file
diff --git a/live/src/main/AndroidManifest.xml b/live/src/main/AndroidManifest.xml
index d4ed503f4..3eb4b9258 100644
--- a/live/src/main/AndroidManifest.xml
+++ b/live/src/main/AndroidManifest.xml
@@ -84,7 +84,10 @@
android:name=".activity.WebViewActivityMedal"
android:screenOrientation="portrait" />
+
+
+
+
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java
index 3c108f099..e4fb57369 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java
@@ -83,10 +83,13 @@ import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
import com.yunbao.live.presenter.LiveLinkMicPkPresenter;
import com.yunbao.live.presenter.LiveLinkMicPresenter;
import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
+import com.yunbao.live.presenter.LiveSwLinkMicPkPresenter;
import com.yunbao.live.socket.SocketClient;
import com.yunbao.live.socket.SocketMessageListener;
import com.yunbao.live.socket.SocketRyChatUtil;
import com.yunbao.live.socket.SocketRyClient;
+import com.yunbao.live.socket.SocketSwChatUtil;
+import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.utils.LoadDian9TuUtil;
import com.yunbao.live.views.AbsLiveViewHolder;
import com.yunbao.live.views.LiveAddImpressViewHolder;
@@ -125,9 +128,13 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
protected LiveEndViewHolder mLiveEndViewHolder;
protected LiveLinkMicPresenter mLiveLinkMicPresenter;//观众与主播连麦逻辑
protected LiveLinkMicAnchorPresenter mLiveLinkMicAnchorPresenter;//主播与主播连麦逻辑
- protected LiveLinkMicPkPresenter mLiveLinkMicPkPresenter;//主播与主播PK逻辑
- public static LiveRyLinkMicPkPresenter mLiveRyLinkMicPkPresenter;//主播与主播PK逻辑
+ protected LiveLinkMicPkPresenter mLiveLinkMicPkPresenter;//主播与主播PK逻辑 腾讯
+ public static LiveRyLinkMicPkPresenter mLiveRyLinkMicPkPresenter;//主播与主播PK逻辑 融云
+
+ public static LiveSwLinkMicPkPresenter mLiveSwLinkMicPkPresenter;//主播与主播PK逻辑 声网
public SocketClient mSocketClient;
+ public SocketSwClient mSocketSwClient;
+
public SocketRyClient mSocketRyClient;
protected LiveBean mLiveBean;
@@ -160,6 +167,8 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
protected List mAudienceList = new ArrayList<>();
protected LiveMicAnchorDialogFragment.OnMicListener micListener = null;
+ public static boolean isSw;
+
@Override
protected void main() {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
@@ -233,13 +242,22 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
// if (isRy == false) {
// SocketChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1);
// } else {
- SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1);
+ if(isSw){
+ SocketSwChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1);
+ }else{
+ SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, mLiveTypeVal, 1);
+ }
+
// }
}
// if (isRy == false) {
// SocketChatUtil.getFakeFans(mLiveUid);
// } else {
- SocketRyChatUtil.getFakeFans(mLiveUid);
+ if(isSw){
+ SocketSwChatUtil.getFakeFans(mLiveUid);
+ }else{
+ SocketRyChatUtil.getFakeFans(mLiveUid);
+ }
// }
}
}
@@ -393,18 +411,29 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean);
}
-
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean);
+ }
}
@Override
public void onEndPk(long leftUid, long rightUid, long left, long right, LivePKUserListBean bean) {
if (mLiveRyLinkMicPkPresenter != null) {
+ L.eSw("onEndPk 结束PK mLiveRyLinkMicPkPresenter");
if (mLiveUid.equals(leftUid + "")) {
mLiveRyLinkMicPkPresenter.onPkProgressEnd(left, right, bean);
} else {
mLiveRyLinkMicPkPresenter.onPkProgressEnd(right, left, bean);
}
}
+ if (mLiveSwLinkMicPkPresenter != null) {
+ L.eSw("onEndPk 结束PK mLiveSwLinkMicPkPresenter");
+ if (mLiveUid.equals(leftUid + "")) {
+ mLiveSwLinkMicPkPresenter.onPkProgressEnd(left, right, bean);
+ } else {
+ mLiveSwLinkMicPkPresenter.onPkProgressEnd(right, left, bean);
+ }
+ }
}
/**
@@ -557,6 +586,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
*/
@Override
public void onAnchorAcceptLinkMic() {
+ L.eSw("onAnchorAcceptLinkMic(1)");
if (mLiveLinkMicPresenter != null) {
mLiveLinkMicPresenter.onAnchorAcceptLinkMic();
}
@@ -668,6 +698,10 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkMicPkClose(1);
}
+
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onLinkMicPkClose(1);
+ }
// }
@@ -718,7 +752,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
@Override
public void onLinkMicPkApply(UserBean u, String stream, int forwhat) {
//主播直播间实现此逻辑
-
+ L.eSw("onLinkMicPkApply----------------------------------------------");
}
/**
@@ -727,12 +761,20 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
@Override
public void onLinkMicPkStart(final String pkUid, final String pkhead, final String pkname, String isLadders) {
if (mContext instanceof LiveAudienceActivity) return;
- Log.e("ry", "pkUid = " + pkUid + ", pkhead = " + pkhead + ", pkname = " + pkname + ", isLadders = " + isLadders);
- if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) {
- mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1);
- pr = new pkRunnable(pkUid, pkhead, pkname, isLadders);
- mHandler.postDelayed(pr, 4000);//3秒后执行Runnable中的run方法
+ L.eSw("pkUid = " + pkUid + ", pkhead = " + pkhead + ", pkname = " + pkname + ", isLadders = " + isLadders);
+ if (isSw) {
+ if (mLiveSwLinkMicPkPresenter != null && mLiveRoomViewHolder != null) {
+ mLiveSwLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1);
+ pr = new pkRunnable(pkUid, pkhead, pkname, isLadders);
+ mHandler.postDelayed(pr, 4000);//3秒后执行Runnable中的run方法
+ }
+ } else {
+ if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) {
+ mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1);
+ pr = new pkRunnable(pkUid, pkhead, pkname, isLadders);
+ mHandler.postDelayed(pr, 4000);//3秒后执行Runnable中的run方法
+ }
}
}
@@ -773,6 +815,8 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
mLiveRyLinkMicPkPresenter.onLinkMicPkClose(i);
} else if (mLiveLinkMicPkPresenter != null) {
mLiveLinkMicPkPresenter.onLinkMicPkClose(i);
+ } else if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onLinkMicPkClose(i);
}
}
@@ -811,6 +855,9 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
} else if (mLiveLinkMicPkPresenter != null) {
mLiveLinkMicPkPresenter.onLinkMicPkEnd(winUid);
mLiveRoomViewHolder.setDelOtherInfo();
+ } else if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onLinkMicPkEnd(winUid);
+ mLiveRoomViewHolder.setDelOtherInfo();
}
}
@@ -967,7 +1014,11 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
onCoinChanged(coin);
}
String[] data = new String[]{obj.getString("barragetoken")};
- SocketRyChatUtil.sendDanmuMessage(mLiveUid, contents, obj.getIntValue("level_fans"));
+ if(isSw){
+ SocketSwChatUtil.sendDanmuMessage(mLiveUid, contents, obj.getIntValue("level_fans"));
+ }else{
+ SocketRyChatUtil.sendDanmuMessage(mLiveUid, contents, obj.getIntValue("level_fans"));
+ }
} else if (code == 1001) {
DialogUitl.showSimpleDialog(mContext, msg, new DialogUitl.SimpleCallback2() {
@Override
@@ -1001,15 +1052,44 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
}
}
int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE;
- SocketRyChatUtil.sendChatMessage(mLiveUid, content, IMLoginManager.get(mContext).getUserInfo().anchorUserType(), mSocketUserType, guardType, atUserID, atUserName);
+ if(isSw){
+ SocketSwChatUtil.sendChatMessage(mLiveUid, content, IMLoginManager.get(mContext).getUserInfo().anchorUserType(), mSocketUserType, guardType, atUserID, atUserName);
+ }else{
+ SocketRyChatUtil.sendChatMessage(mLiveUid, content, IMLoginManager.get(mContext).getUserInfo().anchorUserType(), mSocketUserType, guardType, atUserID, atUserName);
+ }
+ }
+ /**
+ * 发 系统 消息 融云
+ */
+ public static void sendSystemMessageSw(String content) {
+ if(isSw){
+ SocketSwChatUtil.sendSystemMessage(mLiveUid, content);
+ }else{
+ SocketRyChatUtil.sendSystemMessage(mLiveUid, content);
+ }
+ }
+
+ /**
+ * 发 系统 消息 声网
+ */
+ public static void sendSystemMessageRy(String content) {
+ if(isSw){
+ SocketSwChatUtil.sendSystemMessage(mLiveUid, content);
+ }else{
+ SocketRyChatUtil.sendSystemMessage(mLiveUid, content);
+ }
}
/**
* 发 系统 消息
*/
- public static void sendSystemMessage(String content) {
- SocketRyChatUtil.sendSystemMessage(mLiveUid, content);
+ public void sendSystemMessage(String content) {
+ if(isSw){
+ SocketSwChatUtil.sendSystemMessage(mLiveUid, content);
+ }else{
+ SocketRyChatUtil.sendSystemMessage(mLiveUid, content);
+ }
}
@@ -1018,7 +1098,11 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
*/
public void sendGiftMessage(LiveGiftBean giftBean, String giftToken, String ancherName, String by) {
int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE;
- SocketRyChatUtil.sendGiftMessage(giftBean.getType(), giftToken, mLiveUid, ancherName, guardType, by);
+ if(isSw){
+ SocketSwChatUtil.sendGiftMessage(giftBean.getType(), giftToken, mLiveUid, ancherName, guardType, by);
+ }else{
+ SocketRyChatUtil.sendGiftMessage(giftBean.getType(), giftToken, mLiveUid, ancherName, guardType, by);
+ }
}
@@ -1026,28 +1110,44 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
* 主播或管理员踢人
*/
public void kickUser(String toUid, String toName) {
- SocketRyChatUtil.sendKickMessage(mLiveUid, toUid, toName);
+ if(isSw){
+ SocketSwChatUtil.sendKickMessage(mLiveUid, toUid, toName);
+ }else{
+ SocketRyChatUtil.sendKickMessage(mLiveUid, toUid, toName);
+ }
}
/**
* 禁言
*/
public void setShutUp(String toUid, String toName, int type) {
- SocketRyChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type);
+ if(isSw){
+ SocketSwChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type);
+ }else{
+ SocketRyChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type);
+ }
}
/**
* 期限禁言
*/
public void setShutUp(String toUid, String toName, int type, int time) {
- SocketRyChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type, time);
+ if(isSw){
+ SocketSwChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type, time);
+ }else{
+ SocketRyChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type, time);
+ }
}
/**
* 设置或取消管理员消息
*/
public void sendSetAdminMessage(int action, String toUid, String toName) {
- SocketRyChatUtil.sendSetAdminMessage(mLiveUid, action, toUid, toName);
+ if(isSw){
+ SocketSwChatUtil.sendSetAdminMessage(mLiveUid, action, toUid, toName);
+ }else{
+ SocketRyChatUtil.sendSetAdminMessage(mLiveUid, action, toUid, toName);
+ }
}
@@ -1055,14 +1155,24 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
* 超管关闭直播间
*/
public void superCloseRoom() {
- SocketRyChatUtil.superCloseRoom(mLiveUid);
+ if(isSw){
+ SocketSwChatUtil.superCloseRoom(mLiveUid);
+ }else{
+ SocketRyChatUtil.superCloseRoom(mLiveUid);
+ }
+
}
/**
* 更新主播映票数
*/
public void sendUpdateVotesMessage(int deltaVal) {
- SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, deltaVal);
+ if(isSw){
+ SocketSwChatUtil.sendUpdateVotesMessage(mLiveUid, deltaVal);
+ }else{
+ SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, deltaVal);
+ }
+
}
@@ -1070,12 +1180,21 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
* 发送购买守护成功消息
*/
public void sendBuyGuardMessage(String votes, int guardNum, int guardType) {
- SocketRyChatUtil.sendBuyGuardMessage(mLiveUid, votes, guardNum, guardType);
+ if(isSw){
+ SocketSwChatUtil.sendBuyGuardMessage(mLiveUid, votes, guardNum, guardType);
+ }else{
+ SocketRyChatUtil.sendBuyGuardMessage(mLiveUid, votes, guardNum, guardType);
+ }
+
}
public void sendBuyGuardMessage2(String votes, int guardNum, int guardType, String ancherName, String liveId) {
if (guardType != 1) {
- SocketRyChatUtil.sendBuyGuardMessage2(mLiveUid, votes, guardNum, guardType, ancherName, liveId);
+ if(isSw){
+ SocketSwChatUtil.sendBuyGuardMessage2(mLiveUid, votes, guardNum, guardType, ancherName, liveId);
+ }else{
+ SocketRyChatUtil.sendBuyGuardMessage2(mLiveUid, votes, guardNum, guardType, ancherName, liveId);
+ }
}
}
@@ -1083,7 +1202,11 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
* 发送发红包成功消息
*/
public void sendRedPackMessage() {
- SocketRyChatUtil.sendRedPackMessage(mLiveUid);
+ if(isSw){
+ SocketSwChatUtil.sendRedPackMessage(mLiveUid);
+ }else{
+ SocketRyChatUtil.sendRedPackMessage(mLiveUid);
+ }
}
@@ -1335,32 +1458,31 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
if (outRankHideFirst) {
//获取隐身的用户的ID
- LiveNetManager.get(mContext)
- .getNobleRankHideUserList(new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(NobleRankHideUserListModel data) {
- outRankHide = data.getInRankHide();
- LiveUserMoreDialogFragment fragment = new LiveUserMoreDialogFragment();
- fragment.setLiveGuardInfo(mLiveGuardInfo);
- Bundle bundle = new Bundle();
- bundle.putString(Constants.LIVE_UID, mLiveUid);
- bundle.putString(Constants.STREAM, mStream);
- bundle.putString("By", i + "");
- bundle.putBoolean("only", isOnly);
- bundle.putBoolean("noble", noble);
- bundle.putString("outRankHide", GsonUtils.toJson(outRankHide));
- bundle.putBoolean("showBuyView", !showBuyView);
- fragment.setArguments(bundle);
- fragment.show(getSupportFragmentManager(), "LiveUserMoreDialogFragment");
- outRankHideFirst = false;
- }
+ LiveNetManager.get(mContext).getNobleRankHideUserList(new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(NobleRankHideUserListModel data) {
+ outRankHide = data.getInRankHide();
+ LiveUserMoreDialogFragment fragment = new LiveUserMoreDialogFragment();
+ fragment.setLiveGuardInfo(mLiveGuardInfo);
+ Bundle bundle = new Bundle();
+ bundle.putString(Constants.LIVE_UID, mLiveUid);
+ bundle.putString(Constants.STREAM, mStream);
+ bundle.putString("By", i + "");
+ bundle.putBoolean("only", isOnly);
+ bundle.putBoolean("noble", noble);
+ bundle.putString("outRankHide", GsonUtils.toJson(outRankHide));
+ bundle.putBoolean("showBuyView", !showBuyView);
+ fragment.setArguments(bundle);
+ fragment.show(getSupportFragmentManager(), "LiveUserMoreDialogFragment");
+ outRankHideFirst = false;
+ }
- @Override
- public void onError(String error) {
- Log.e("LiveUserMoreDialog", error);
- ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
- }
- });
+ @Override
+ public void onError(String error) {
+ Log.e("LiveUserMoreDialog", error);
+ ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
+ }
+ });
} else {
LiveUserMoreDialogFragment fragment = new LiveUserMoreDialogFragment();
fragment.setLiveGuardInfo(mLiveGuardInfo);
@@ -1527,6 +1649,13 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
}
}
+ @Override
+ public void onLinkDRMicPkQuit(String uid) {
+ if(mLiveSwLinkMicPkPresenter!=null){
+ mLiveSwLinkMicPkPresenter.onLinkDRMicPkQuit(uid);
+ }
+ }
+
@Override
public boolean isSoftInputShowed() {
if (mKeyBoardHeightUtil != null) {
@@ -1671,27 +1800,30 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
micListener = fragment.getMicListener();
fragment.setMicQueueList(mMicQueueList);
fragment.setAudienceList(mAudienceList);
- fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment");
+ if(isSw){
+ fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment");
+ }else{
+ fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment");
+ }
}
/**
* 获取连麦列表
*/
public void showMicList(String uid, LiveRoomViewHolder mLiveRoomViewHolder) {
- LiveNetManager.get(mContext)
- .getDRMicUserList(uid, new com.yunbao.common.http.base.HttpCallback>() {
- @Override
- public void onSuccess(List data) {
- if (mLiveRoomViewHolder != null) {
- mLiveRoomViewHolder.updataMicList(data);
- }
- }
+ LiveNetManager.get(mContext).getDRMicUserList(uid, new com.yunbao.common.http.base.HttpCallback>() {
+ @Override
+ public void onSuccess(List data) {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.updataMicList(data);
+ }
+ }
- @Override
- public void onError(String error) {
- System.out.println("live.getDrLm error = " + error);
- }
- });
+ @Override
+ public void onError(String error) {
+ System.out.println("live.getDrLm error = " + error);
+ }
+ });
}
@Override
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java
index 9a2484077..75e1bbd4b 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveAnchorActivity.java
@@ -282,7 +282,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
+ CommonAppConfig.getInstance().getUid() + "&token="
+ CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid
+ "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0");
- ZhuangBanActivity.forward(mContext, url, false,0);
+ ZhuangBanActivity.forward(mContext, url, false, 0);
break;
case Constants.LIVE_FUNC_LINK_MIC://连麦
openLinkMicAnchorWindow();
@@ -471,7 +471,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
}
mLiveReadyViewHolder = null;
if (mLiveRoomViewHolder == null) {
- mLiveRoomViewHolder = new LiveRoomViewHolder(false, 2, mContext, mContainer, (GifImageView) findViewById(R.id.gift_gif), (SVGAImageView) findViewById(R.id.gift_svga), mContainerWrap, getWindowManager());
+ mLiveRoomViewHolder = new LiveRoomViewHolder(false, 2, mContext, mContainer, (GifImageView) findViewById(R.id.gift_gif), (SVGAImageView) findViewById(R.id.gift_svga), mContainerWrap, getWindowManager(),false);
mLiveRoomViewHolder.addToParent();
mLiveRoomViewHolder.subscribeActivityLifeCycle();
mLiveRoomViewHolder.setLiveInfo(mLiveUid, mStream, obj.getIntValue("userlist_time") * 1000);
@@ -632,6 +632,9 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
// } else {
// SocketRyChatUtil.closeLive(mLiveUid, mSocketRyClient);
//断开socket
+ if (mSocketSwClient != null) {
+ mSocketSwClient.disConnect();
+ }
if (mSocketRyClient != null) {
mSocketRyClient.disConnect();
}
@@ -885,7 +888,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
}
});
} else {
- ToastUtil.show("主播正在PK,稍後再試");
+ ToastUtil.show(getString(R.string.pking_over));
}
}
}
@@ -938,7 +941,7 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
}
});
} else {
- ToastUtil.show("主播正在PK,稍後再試");
+ ToastUtil.show(mContext.getString(R.string.pking_over));
}
}
}
@@ -997,9 +1000,15 @@ public class LiveAnchorActivity extends LiveActivity implements LiveFunctionClic
}
}
+ @Override
+ public void onLinkDRMicPKToUser(UserBean u) {
+
+ }
+
//多人PK接受
@Override
public void onLinkDRMicPkApplyOk(UserBean u) {
+ L.eSw("onLinkDRMicPkApplyOk(UserBean u)");
if (mLiveLinkMicPkPresenter != null) {
mLiveLinkMicPkPresenter.onLinkDRMicPkApplyOk(u);
}
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
index b11031d34..45456e670 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
@@ -15,6 +15,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
import android.widget.ImageView;
import androidx.annotation.IdRes;
@@ -36,6 +37,9 @@ import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.enums.PopupPosition;
import com.lxj.xpopup.interfaces.XPopupCallback;
import com.lzf.easyfloat.EasyFloat;
+import com.lzf.easyfloat.enums.ShowPattern;
+import com.yunbao.common.dialog.DebugDialog;
+import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
@@ -125,7 +129,9 @@ import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience;
import com.yunbao.live.dialog.SignDialogFragment;
import com.yunbao.live.event.LinkMicTxAccEvent;
import com.yunbao.live.event.LiveAudienceEvent;
+import com.yunbao.live.event.LiveOpenSuccessEvent;
import com.yunbao.live.http.ImHttpUtil;
+import com.yunbao.live.utils.LiveTextRender;
import com.yunbao.live.views.LiveRoomPlayViewHolder;
import com.yunbao.live.views.LiveRoomViewHolder;
import com.yunbao.live.views.PortraitLiveManager;
@@ -208,6 +214,7 @@ public class LiveAudienceActivity extends LiveActivity {
mProcessResultUtil = new ProcessResultUtil(this);
Intent intent = getIntent();
mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY);
+ isSw = intent.getBooleanExtra(Constants.LIVE_SDK_IS_SW, false);
L.e(TAG, "直播sdk----->" + (mLiveSDK == Constants.LIVE_SDK_KSY ? "金山云" : "腾讯云"));
mLiveType = intent.getIntExtra(Constants.LIVE_TYPE, Constants.LIVE_TYPE_NORMAL);
mLiveTypeVal = intent.getIntExtra(Constants.LIVE_TYPE_VAL, 0);
@@ -226,6 +233,43 @@ public class LiveAudienceActivity extends LiveActivity {
fragment.show(((FragmentActivity) mContext).getSupportFragmentManager(), "YoursystemisolderDialog");
IMLoginManager.get(mContext).setXiaJBG(true);
}
+ /* new Handler(Looper.getMainLooper())
+ .postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ DebugDialog.getInstance(new DebugDialog.DebugDialogRunnable() {
+ @Override
+ public void run(DebugDialog dialog) {
+ dialog.setShowPattern(ShowPattern.ALL_TIME);
+ dialog.show();
+
+ dialog.setView("+",new Button(mContext),view -> LiveTextRender.textTemp++);
+ dialog.setView("-",new Button(mContext),view -> LiveTextRender.textTemp--);
+ dialog.setView("+",new Button(mContext),view -> LiveTextRender.textTemp++);
+ dialog.setView("中/英",new Button(mContext),view ->{
+ if(LiveTextRender.userName.startsWith("中")){
+ LiveTextRender.userName="英文34567890";
+ }else{
+ LiveTextRender.userName="中文测试中文测试中文";
+ }
+ });
+ dialog.setView("长/短",new Button(mContext),view ->{
+ if(LiveTextRender.userName.length()>5){
+ LiveTextRender.userName="abcdefg";
+ }else{
+ LiveTextRender.userName="中文中文";
+ }
+ });
+ LiveTextRender.onItemClickListener = new OnItemClickListener() {
+ @Override
+ public void onItemClick(String bean, int position) {
+ dialog.setParams(bean.split("\\|")[0], bean.split("\\|")[1]+"|"+position);
+ }
+ };
+ }
+ });
+ }
+ },1000);*/
}
private final MicStatusManager.OnMicStatusListener onMicStatusListener = new MicStatusManager.OnMicStatusListener() {
@@ -299,38 +343,36 @@ public class LiveAudienceActivity extends LiveActivity {
Log.e(TAG, "mCurrentItem:" + mCurrentItem);
if (mCurrentItem == itemModelList.size() - 1) {
if (isRadPacetModle) {//从红包专区进去的走红包专区列表
- MainNetManager.get(mContext)
- .getRedPacket(new com.yunbao.common.http.base.HttpCallback>() {
- @Override
- public void onSuccess(List data) {
- if (TextUtils.equals(data.get(0).getUid(), mLiveBean.getUid())) {
- data.remove(0);
- }
- itemModelList.addAll(data);
- mPagerAdapter.notifyDataSetChanged();
- }
+ MainNetManager.get(mContext).getRedPacket(new com.yunbao.common.http.base.HttpCallback>() {
+ @Override
+ public void onSuccess(List data) {
+ if (TextUtils.equals(data.get(0).getUid(), mLiveBean.getUid())) {
+ data.remove(0);
+ }
+ itemModelList.addAll(data);
+ mPagerAdapter.notifyDataSetChanged();
+ }
- @Override
- public void onError(String error) {
+ @Override
+ public void onError(String error) {
- }
- });
+ }
+ });
} else {
- MainNetManager.get(mContext)
- .anchorRecommendType("30", new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(AnchorRecommendModel data) {
- if (TextUtils.equals(data.getList().get(0).getUid(), mLiveBean.getUid())) {
- data.getList().remove(0);
- }
- itemModelList.addAll(data.getList());
- mPagerAdapter.notifyDataSetChanged();
- }
+ MainNetManager.get(mContext).anchorRecommendType("30", isSw ? "1" : "0", new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(AnchorRecommendModel data) {
+ if (TextUtils.equals(data.getList().get(0).getUid(), mLiveBean.getUid())) {
+ data.getList().remove(0);
+ }
+ itemModelList.addAll(data.getList());
+ mPagerAdapter.notifyDataSetChanged();
+ }
- @Override
- public void onError(String error) {
- }
- });
+ @Override
+ public void onError(String error) {
+ }
+ });
}
}
}
@@ -351,13 +393,16 @@ public class LiveAudienceActivity extends LiveActivity {
if (itemModelList.size() == 0) {
return;
}
+ Log.e("直播间接口调用排查", "transformPage 11");
ViewGroup viewGroup = (ViewGroup) page;
Log.e(TAG, "position:" + mCurrentItem);
if ((position < 0 && viewGroup.getId() != mCurrentItem)) {
+ Log.e("直播间接口调用排查", "transformPage 22");
// room_container 为视频播放的根布局 id
View rootView = viewGroup.findViewById(R.id.drawer_layout);
if (rootView != null && rootView.getParent() != null && rootView.getParent() instanceof ViewGroup) {
((ViewGroup) (rootView.getParent())).removeView(rootView);
+ Log.e("直播间接口调用排查", "transformPage 33");
manager.onRemove(false);
}
}
@@ -366,8 +411,6 @@ public class LiveAudienceActivity extends LiveActivity {
loadData(viewGroup, mCurrentItem);
}
}
-
-
});
getDrawer();
@@ -403,7 +446,7 @@ public class LiveAudienceActivity extends LiveActivity {
mHandler.removeCallbacks(pr);
pr = null;
}
- manager.onAdd(mLiveBean, mLiveType, mLiveTypeVal, mLiveSDK);
+ manager.onAdd(mLiveBean, mLiveType, mLiveTypeVal, mLiveSDK, isSw);
//加载完页面后再后台静默下载礼物svga
downloadAllGift();
@@ -412,7 +455,9 @@ public class LiveAudienceActivity extends LiveActivity {
} else {
new LiveRoomCheckLivePresenter(mContext, data.getUid(), data.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw1) {
+ L.eSw("onLiveRoomChanged:" + isSw1);
+ isSw = isSw1;
liveIndex = false;
try {
mLiveSDK = Integer.parseInt(liveSdk);
@@ -440,7 +485,7 @@ public class LiveAudienceActivity extends LiveActivity {
}
mViewGroup.addView(manager.getRootView());
- manager.onAdd(mLiveBean, liveType, mLiveTypeVal, mLiveSDK);
+ manager.onAdd(mLiveBean, liveType, mLiveTypeVal, mLiveSDK, isSw);
//加载完页面后再后台静默下载礼物svga
downloadAllGift();
over();
@@ -482,12 +527,7 @@ public class LiveAudienceActivity extends LiveActivity {
if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream)) {
return;
}
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP)
- .setmLiveUid(mLiveUid)
- .setmStream(mStream)
- .setPk(isPk)
- .setLiveGuardInfo(mLiveGuardInfo));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP).setmLiveUid(mLiveUid).setmStream(mStream).setPk(isPk).setLiveGuardInfo(mLiveGuardInfo));
});
}
@@ -495,13 +535,7 @@ public class LiveAudienceActivity extends LiveActivity {
if (TextUtils.isEmpty(mLiveUid) || TextUtils.isEmpty(mStream)) {
return;
}
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP)
- .setmLiveUid(mLiveUid)
- .setmStream(mStream)
- .setPk(isPk)
- .setLiveGuardInfo(mLiveGuardInfo)
- .setmWishGiftId(giftId));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP).setmLiveUid(mLiveUid).setmStream(mStream).setPk(isPk).setLiveGuardInfo(mLiveGuardInfo).setmWishGiftId(giftId));
}
public void openGiftWindow(String giftId, String for_by) {
@@ -510,14 +544,7 @@ public class LiveAudienceActivity extends LiveActivity {
}
new Handler(Looper.getMainLooper()).post(() -> {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP)
- .setmLiveUid(mLiveUid)
- .setmStream(mStream)
- .setPk(isPk)
- .setLiveGuardInfo(mLiveGuardInfo)
- .setmWishGiftId(giftId)
- .setUname("1"));//setUname==by
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP).setmLiveUid(mLiveUid).setmStream(mStream).setPk(isPk).setLiveGuardInfo(mLiveGuardInfo).setmWishGiftId(giftId).setUname("1"));//setUname==by
});
}
@@ -566,8 +593,20 @@ public class LiveAudienceActivity extends LiveActivity {
}
@Override
- public void onLinkDRMicPkApplyOk(UserBean u) {
+ public void onLinkDRMicPKToUser(UserBean u) {
+ //manager.getmLivePlayViewHolder().setDrMicInfo(u);
+ }
+ @Override
+ public void onLinkDRMicPkQuit(String uid) {
+
+ }
+
+ @Override
+ public void onLinkDRMicPkApplyOk(UserBean u) {
+ L.eSw("onLinkDRMicPkApplyOk:" + u.getId());
+ //多人PK 连麦
+ //manager.getmLivePlayViewHolder().setDrMicInfo(u);
}
@Override
@@ -583,39 +622,33 @@ public class LiveAudienceActivity extends LiveActivity {
@Override
public void onBackPressed() {
if (manager != null && manager.getsudGameMin()) {
- new XPopup.Builder(mContext)
- .asCustom(new HintCustomPopup(mContext,
- mContext.getString(com.yunbao.common.R.string.dialog_tip),
- mContext.getString(com.yunbao.common.R.string.the_live_room))
- .setLiveOpenOk(mContext.getString(com.yunbao.common.R.string.confirm))
- .setLiveOpenCancel(mContext.getString(com.yunbao.common.R.string.cancel))
- .setCallBack(new HintCustomPopup.HintCustomCallBack() {
- @Override
- public void onSure() {
- MobclickAgent.onEvent(mContext, "live_room_close", "退出直播间");
- OpenAdManager.getInstance().dismiss();
- try {
- manager.onBackPressed();
- if (MicStatusManager.getInstance().getMicStatus() == MicStatusManager.MIC_TYPE_REQUEST) {
- manager.micIngTypeOne(mLiveBean, mLiveType, mLiveTypeVal);
- } else if (MicStatusManager.getInstance().getMicStatus() == MicStatusManager.MIC_TYPE_OPEN) {
- manager.micIngTypeTwo(mLiveBean, mLiveType, mLiveTypeVal);
- } else {
- manager.onRemove(true);
+ new XPopup.Builder(mContext).asCustom(new HintCustomPopup(mContext, mContext.getString(com.yunbao.common.R.string.dialog_tip), mContext.getString(com.yunbao.common.R.string.the_live_room)).setLiveOpenOk(mContext.getString(com.yunbao.common.R.string.confirm)).setLiveOpenCancel(mContext.getString(com.yunbao.common.R.string.cancel)).setCallBack(new HintCustomPopup.HintCustomCallBack() {
+ @Override
+ public void onSure() {
+ MobclickAgent.onEvent(mContext, "live_room_close", "退出直播间");
+ OpenAdManager.getInstance().dismiss();
+ try {
+ manager.onBackPressed();
+ if (MicStatusManager.getInstance().getMicStatus() == MicStatusManager.MIC_TYPE_REQUEST) {
+ manager.micIngTypeOne(mLiveBean, mLiveType, mLiveTypeVal);
+ } else if (MicStatusManager.getInstance().getMicStatus() == MicStatusManager.MIC_TYPE_OPEN) {
+ manager.micIngTypeTwo(mLiveBean, mLiveType, mLiveTypeVal);
+ } else {
+ manager.onRemove(true);
- }
- Bus.get().post(new HideShowEvent().setClose(true));
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ }
+ Bus.get().post(new HideShowEvent().setClose(true));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
- @Override
- public void onCancel() {
+ @Override
+ public void onCancel() {
- }
- })).show();
+ }
+ })).show();
} else {
MobclickAgent.onEvent(mContext, "live_room_close", "退出直播间");
OpenAdManager.getInstance().dismiss();
@@ -638,8 +671,7 @@ public class LiveAudienceActivity extends LiveActivity {
}
public void end() {
- if (manager != null)
- manager.end();
+ if (manager != null) manager.end();
}
/**
@@ -694,24 +726,21 @@ public class LiveAudienceActivity extends LiveActivity {
* 计时收费更新主播映票数
*/
public void roomChargeUpdateVotes() {
- if (manager != null)
- manager.sendUpdateVotesMessage();
+ if (manager != null) manager.sendUpdateVotesMessage();
}
/**
* 暂停播放
*/
public void pausePlay() {
- if (manager != null)
- manager.pausePlay();
+ if (manager != null) manager.pausePlay();
}
/**
* 恢复播放
*/
public void resumePlay() {
- if (manager != null)
- manager.resumePlay();
+ if (manager != null) manager.resumePlay();
}
public CountDownTimer getCountDownTimer() {
@@ -722,8 +751,7 @@ public class LiveAudienceActivity extends LiveActivity {
* 充值成功
*/
public void onChargeSuccess() {
- if (manager != null)
- manager.onChargeSuccess();
+ if (manager != null) manager.onChargeSuccess();
}
public void setCoinNotEnough(boolean coinNotEnough) {
@@ -739,6 +767,14 @@ public class LiveAudienceActivity extends LiveActivity {
manager.onLinkMicTxAccEvent(e);
}
+ /**
+ * 腾讯sdk连麦时候切换低延时流
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onLinkMicTxAccEvent(LiveOpenSuccessEvent e) {
+ manager.loadTimeoutRunnableGone();
+ }
+
/**
* 腾讯sdk时候主播连麦回调
*
@@ -819,7 +855,8 @@ public class LiveAudienceActivity extends LiveActivity {
mStream = liveBean.getStream();
mAncherName = liveBean.getUserNiceName();
mAncherIcon = liveBean.getAvatar();
- manager.onAdd(liveBean, mLiveType, mLiveTypeVal, mLiveSDK);
+ //暂时 true
+ manager.onAdd(liveBean, mLiveType, mLiveTypeVal, mLiveSDK, isSw);
}
}
}
@@ -845,8 +882,7 @@ public class LiveAudienceActivity extends LiveActivity {
}
GiftCacheUtil.getInstance().restart();
if (manager.isEnterRoom()) {
- new Handler(Looper.getMainLooper()).postDelayed(() -> OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE,
- LiveGuardInfo.isGuard(mLiveGuardInfo)), 400);
+ new Handler(Looper.getMainLooper()).postDelayed(() -> OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE, LiveGuardInfo.isGuard(mLiveGuardInfo)), 400);
}
}
@@ -858,8 +894,7 @@ public class LiveAudienceActivity extends LiveActivity {
private void adjustFullScreen(Configuration config) {
final WindowInsetsControllerCompat insetsController = ViewCompat.getWindowInsetsController(getWindow().getDecorView());
- if (insetsController == null)
- return;
+ if (insetsController == null) return;
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
insetsController.hide(WindowInsetsCompat.Type.systemBars());
} else {
@@ -909,7 +944,7 @@ public class LiveAudienceActivity extends LiveActivity {
if (userIndex != -1) {
list.remove(userIndex);
}
- CustomDrawerPopupView customDrawerPopupView = new CustomDrawerPopupView(mContext).setList(list).setLiveId(mLiveBean.getUid());
+ CustomDrawerPopupView customDrawerPopupView = new CustomDrawerPopupView(mContext, isSw).setList(list).setLiveId(mLiveBean.getUid());
customDrawerPopupView.setCallBack(new CustomDrawerPopupView.CustomDrawerPopupCallBack() {
@Override
@@ -933,10 +968,11 @@ public class LiveAudienceActivity extends LiveActivity {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw1) {
if (liveBean == null) {
return;
}
+ isSw = isSw1;
if (MicStatusManager.getInstance().isMic(liveUid)) {
MicStatusManager.getInstance().showDownMicDialog(mContext);
return;
@@ -958,8 +994,7 @@ public class LiveAudienceActivity extends LiveActivity {
public void informationTransfer(CustomDrawerPopupEvent event) {
//跳转贵族
if (TextUtils.equals(event.getRightsInterests(), getString(com.yunbao.common.R.string.noble))) {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.NOBLE));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.NOBLE));
//跳转守护
} else if (TextUtils.equals(event.getRightsInterests(), getString(com.yunbao.common.R.string.guard_guard))) {
Bus.get().post(new LiveAudienceEvent()
@@ -968,8 +1003,7 @@ public class LiveAudienceActivity extends LiveActivity {
manager.onGuardRed();
//跳转粉丝团
} else if (TextUtils.equals(event.getRightsInterests(), getString(com.yunbao.common.R.string.fan_club))) {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.FAN_CLUB));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.FAN_CLUB));
}
}
@@ -995,69 +1029,53 @@ public class LiveAudienceActivity extends LiveActivity {
@Override
public void evenTheWheat() {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LIAN_MAI));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIAN_MAI));
}
@Override
public void effectsSetting() {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.EFFECTS_SETTINGS));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.EFFECTS_SETTINGS));
}
@Override
public void slideSetting() {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.SLIDE_SETTINGS));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SLIDE_SETTINGS));
}
@Override
public void floatSetting() {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.FLOAT_SETTING));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.FLOAT_SETTING));
}
@Override
public void systemNotice() {
- Bus.get().post(new LiveAudienceEvent()
- .setBean(mLiveBean)
- .setType(LiveAudienceEvent.LiveAudienceType.NOTICE));
+ Bus.get().post(new LiveAudienceEvent().setBean(mLiveBean).setType(LiveAudienceEvent.LiveAudienceType.NOTICE));
}
@Override
public void changeVideo() {
- Bus.get().post(new LiveAudienceEvent()
- .setBean(mLiveBean)
- .setType(LiveAudienceEvent.LiveAudienceType.LIVE_VIDEO));
+ Bus.get().post(new LiveAudienceEvent().setBean(mLiveBean).setType(LiveAudienceEvent.LiveAudienceType.LIVE_VIDEO));
}
@Override
public void online() {
- Bus.get().post(new LiveAudienceEvent()
- .setBean(mLiveBean)
- .setType(LiveAudienceEvent.LiveAudienceType.ONLINE));
+ Bus.get().post(new LiveAudienceEvent().setBean(mLiveBean).setType(LiveAudienceEvent.LiveAudienceType.ONLINE));
}
@Override
public void reportLayout() {
- Bus.get().post(new LiveAudienceEvent()
- .setBean(mLiveBean)
- .setType(LiveAudienceEvent.LiveAudienceType.REPORT));
+ Bus.get().post(new LiveAudienceEvent().setBean(mLiveBean).setType(LiveAudienceEvent.LiveAudienceType.REPORT));
}
@Override
public void share() {
- Bus.get().post(new LiveAudienceEvent()
- .setBean(mLiveBean)
- .setType(LiveAudienceEvent.LiveAudienceType.LIVE_SHARE));
+ Bus.get().post(new LiveAudienceEvent().setBean(mLiveBean).setType(LiveAudienceEvent.LiveAudienceType.LIVE_SHARE));
}
@Override
public void changeFontSize() {
- Bus.get().post(new LiveAudienceEvent()
- .setBean(mLiveBean)
- .setType(LiveAudienceEvent.LiveAudienceType.FONT_SIZE));
+ Bus.get().post(new LiveAudienceEvent().setBean(mLiveBean).setType(LiveAudienceEvent.LiveAudienceType.FONT_SIZE));
}
@Override
@@ -1065,23 +1083,18 @@ public class LiveAudienceActivity extends LiveActivity {
if (manager != null && manager.getsudGameMin()) {
ToastUtil.show(WordUtil.isNewZh() ? "您已在游戏房间中" : "You are already in the game room");
} else {
- new XPopup.Builder(mContext)
- .enableDrag(false)
+ //直播间来的
+ new XPopup.Builder(mContext).enableDrag(false)
// .dismissOnTouchOutside(false)
// .dismissOnBackPressed(false)
- .moveUpToKeyboard(false)
- .asCustom(new SudGameListPopup(mContext, interactionID, child, mLiveUid))
+ .moveUpToKeyboard(false).asCustom(new SudGameListPopup(mContext, interactionID, child, mLiveUid))
.show();
}
}
});
- new XPopup.Builder(mContext)
- .hasShadowBg(false)
- .isDestroyOnDismiss(true)
- .isLightStatusBar(false)
- .popupPosition(PopupPosition.Right)//右边
+ new XPopup.Builder(mContext).hasShadowBg(false).isDestroyOnDismiss(true).isLightStatusBar(false).popupPosition(PopupPosition.Right)//右边
.hasStatusBarShadow(true) //启用状态栏阴影
.setPopupCallback(new XPopupCallback() {
@Override
@@ -1127,9 +1140,7 @@ public class LiveAudienceActivity extends LiveActivity {
public void onClickOutside(BasePopupView popupView) {
}
- })
- .asCustom(customDrawerPopupView)
- .show();
+ }).asCustom(customDrawerPopupView).show();
}
break;
@@ -1179,15 +1190,9 @@ public class LiveAudienceActivity extends LiveActivity {
//粉絲團粉絲團
//不是粉絲
if (LiveAudienceActivity.is_fans == null || "2".equals(LiveAudienceActivity.is_fans)) {
- bundle.putString(Constants.URL,
- (CommonAppConfig.HOST + "/h5/live/joinFansClub.html" +
- "?uid=" + userInfo.getId() +
- "&token=" + userInfo.getToken() + "&anchorUid=" + mLiveUid) + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0));
+ bundle.putString(Constants.URL, (CommonAppConfig.HOST + "/h5/live/joinFansClub.html" + "?uid=" + userInfo.getId() + "&token=" + userInfo.getToken() + "&anchorUid=" + mLiveUid) + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0));
} else {
- bundle.putString(Constants.URL,
- (CommonAppConfig.HOST + "/h5/live/fansClub.html" +
- "?uid=" + userInfo.getId() +
- "&token=" + userInfo.getToken() + "&anchorUid=" + mLiveUid) + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0));
+ bundle.putString(Constants.URL, (CommonAppConfig.HOST + "/h5/live/fansClub.html" + "?uid=" + userInfo.getId() + "&token=" + userInfo.getToken() + "&anchorUid=" + mLiveUid) + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0));
}
bundle.putString("liveUid", mLiveUid);
bundle.putString("anchorName", mAncherName);
@@ -1197,25 +1202,18 @@ public class LiveAudienceActivity extends LiveActivity {
break;
case GUARD:
if (event.getObject() == null) {
- openNewGuardListWindow(mContext instanceof LiveRyAnchorActivity);
+ openNewGuardListWindow(mContext instanceof LiveSwAnchorActivity);
} else {
openNewBuyGuardWindow(true);
}
break;
case LIVE_WKS://周星榜
- String weeklyStarUrl = CommonAppConfig.HOST + "/h5/activity/weekStar/index.html?&uid="
- + userInfo.getId() +
- "&token=" + userInfo.getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
+ String weeklyStarUrl = CommonAppConfig.HOST + "/h5/activity/weekStar/index.html?&uid=" + userInfo.getId() + "&token=" + userInfo.getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
ZhuangBanActivity.forward(mContext, weeklyStarUrl, false, 1);
break;
case NOBLE:
Constants.isTitle = true;
- String nobleUrl = CommonAppConfig.HOST + "/h5/Noble/index.html?nickname=" + userInfo.getUserNicename()
- + "&usernobId=" + userInfo.getNobleId()
- + "&token=" + userInfo.getToken()
- + "&anchorUid=" + mLiveBean.getUid()
- + "&ancherName=" + mLiveBean.getUserNiceName()
- + "&uid=" + userInfo.getId() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
+ String nobleUrl = CommonAppConfig.HOST + "/h5/Noble/index.html?nickname=" + userInfo.getUserNicename() + "&usernobId=" + userInfo.getNobleId() + "&token=" + userInfo.getToken() + "&anchorUid=" + mLiveBean.getUid() + "&ancherName=" + mLiveBean.getUserNiceName() + "&uid=" + userInfo.getId() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
ZhuangBanActivity.forward(mContext, nobleUrl, false, 1);
break;
case LIAN_MAI:
@@ -1229,25 +1227,23 @@ public class LiveAudienceActivity extends LiveActivity {
manager.micIngTypeTwo(event.getBean(), event.getLiveType(), event.getLiveTypeVal());
} else {
//获取房间连麦状态
- HttpClient.getInstance().get("live.getDrLm", "live.getDrLm")
- .params("uid", mLiveUid, true)
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- if (code == 0) {
- LiveMicUserDialogFragment fragment = new LiveMicUserDialogFragment();
- Bundle bundle = new Bundle();
- bundle.putString(Constants.LIVE_UID, mLiveUid);
- bundle.putString(Constants.STREAM, mStream);
- bundle.putString("By", "1");
- fragment.setArguments(bundle);
- fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveUserMoreDialogFragment");
- LiveMicUserDialogFragment.activity = ((LiveAudienceActivity) mContext);
- } else {
- ToastUtil.show(mContext.getString(R.string.no_mic_opn));
- }
- }
- });
+ HttpClient.getInstance().get("live.getDrLm", "live.getDrLm").params("uid", mLiveUid, true).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0) {
+ LiveMicUserDialogFragment fragment = new LiveMicUserDialogFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString(Constants.LIVE_UID, mLiveUid);
+ bundle.putString(Constants.STREAM, mStream);
+ bundle.putString("By", "1");
+ fragment.setArguments(bundle);
+ fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveUserMoreDialogFragment");
+ LiveMicUserDialogFragment.activity = ((LiveAudienceActivity) mContext);
+ } else {
+ ToastUtil.show(mContext.getString(R.string.no_mic_opn));
+ }
+ }
+ });
}
break;
case EFFECTS_SETTINGS:
@@ -1268,31 +1264,20 @@ public class LiveAudienceActivity extends LiveActivity {
}
break;
case OPEN_PARAMETERS:
- mDanmuPrice = TextUtils.equals(event.getParametersModel().getmDanmuPrice(), mDanmuPrice) ?
- mDanmuPrice : event.getParametersModel().getmDanmuPrice();
- mSocketUserType = TextUtils.equals(String.valueOf(mSocketUserType), String.valueOf(event.getParametersModel().getmSocketUserType())) ?
- mSocketUserType : event.getParametersModel().getmSocketUserType();
- mChatLevel = TextUtils.equals(String.valueOf(mChatLevel), String.valueOf(event.getParametersModel().getmChatLevel())) ?
- mChatLevel : event.getParametersModel().getmChatLevel();
- mDanMuLevel = TextUtils.equals(String.valueOf(mDanMuLevel), String.valueOf(event.getParametersModel().getmDanMuLevel())) ?
- mDanMuLevel : event.getParametersModel().getmDanMuLevel();
- mLiveType = TextUtils.equals(String.valueOf(mLiveType), String.valueOf(event.getParametersModel().getmLiveType())) ?
- mLiveType : event.getParametersModel().getmLiveType();
- mLiveTypeVal = TextUtils.equals(String.valueOf(mLiveTypeVal), String.valueOf(event.getParametersModel().getmLiveTypeVal())) ?
- mLiveTypeVal : event.getParametersModel().getmLiveTypeVal();
- mLiveGuardInfo = event.getParametersModel().getmLiveGuardInfo() == null ?
- mLiveGuardInfo : event.getParametersModel().getmLiveGuardInfo();
- liveBg = TextUtils.equals(String.valueOf(liveBg), String.valueOf(event.getParametersModel().getLiveBg())) ?
- liveBg : event.getParametersModel().getLiveBg();
- is_fans = TextUtils.equals(String.valueOf(is_fans), String.valueOf(event.getParametersModel().getIs_fans())) ?
- is_fans : event.getParametersModel().getIs_fans();
- fansNum = TextUtils.equals(String.valueOf(fansNum), String.valueOf(event.getParametersModel().getFansNum())) ?
- fansNum : event.getParametersModel().getFansNum();
+ mDanmuPrice = TextUtils.equals(event.getParametersModel().getmDanmuPrice(), mDanmuPrice) ? mDanmuPrice : event.getParametersModel().getmDanmuPrice();
+ mSocketUserType = TextUtils.equals(String.valueOf(mSocketUserType), String.valueOf(event.getParametersModel().getmSocketUserType())) ? mSocketUserType : event.getParametersModel().getmSocketUserType();
+ mChatLevel = TextUtils.equals(String.valueOf(mChatLevel), String.valueOf(event.getParametersModel().getmChatLevel())) ? mChatLevel : event.getParametersModel().getmChatLevel();
+ mDanMuLevel = TextUtils.equals(String.valueOf(mDanMuLevel), String.valueOf(event.getParametersModel().getmDanMuLevel())) ? mDanMuLevel : event.getParametersModel().getmDanMuLevel();
+ mLiveType = TextUtils.equals(String.valueOf(mLiveType), String.valueOf(event.getParametersModel().getmLiveType())) ? mLiveType : event.getParametersModel().getmLiveType();
+ mLiveTypeVal = TextUtils.equals(String.valueOf(mLiveTypeVal), String.valueOf(event.getParametersModel().getmLiveTypeVal())) ? mLiveTypeVal : event.getParametersModel().getmLiveTypeVal();
+ mLiveGuardInfo = event.getParametersModel().getmLiveGuardInfo() == null ? mLiveGuardInfo : event.getParametersModel().getmLiveGuardInfo();
+ liveBg = TextUtils.equals(String.valueOf(liveBg), String.valueOf(event.getParametersModel().getLiveBg())) ? liveBg : event.getParametersModel().getLiveBg();
+ is_fans = TextUtils.equals(String.valueOf(is_fans), String.valueOf(event.getParametersModel().getIs_fans())) ? is_fans : event.getParametersModel().getIs_fans();
+ fansNum = TextUtils.equals(String.valueOf(fansNum), String.valueOf(event.getParametersModel().getFansNum())) ? fansNum : event.getParametersModel().getFansNum();
break;
case ACTIVITY_CENTER://活动中心
String url = CommonAppConfig.HOST + "/h5/live/hallOfFame/index.html?g=Appapi&m=Turntable&a=tricky";
- url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
- + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
+ url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
Log.i("tag", url);
Intent intent = new Intent(mContext, ZhuangBanActivity.class);
intent.putExtra("url", url);
@@ -1314,10 +1299,7 @@ public class LiveAudienceActivity extends LiveActivity {
break;
case POPULAR:
url = CommonAppConfig.HOST + "/h5/activity/PopularityTask/index.html";
- url += "?anchorUid=" + mLiveUid
- + "&stream=" + mStream
- + "&uid=" + CommonAppConfig.getInstance().getUid()
- + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
+ url += "?anchorUid=" + mLiveUid + "&stream=" + mStream + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
bundle.putString("url", url);
bundle.putInt("show_type", 0);
@@ -1390,16 +1372,13 @@ public class LiveAudienceActivity extends LiveActivity {
}
if (micListener != null) {
micListener.updateMicList(mMicQueueList);
- DialogUitl.showSimpleDialog(mContext,
- String.format(mContext.getString(R.string.live_mic_user_apply), ((LinkMicUserBean) event.getObject()).getUserNicename()),
- new DialogUitl.SimpleCallback() {
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- openMicWindow(2);
- dialog.dismiss();
- }
- }
- );
+ DialogUitl.showSimpleDialog(mContext, String.format(mContext.getString(R.string.live_mic_user_apply), ((LinkMicUserBean) event.getObject()).getUserNicename()), new DialogUitl.SimpleCallback() {
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ openMicWindow(2);
+ dialog.dismiss();
+ }
+ });
}
break;
case LINK_MIC_CANCEL:
@@ -1447,7 +1426,7 @@ public class LiveAudienceActivity extends LiveActivity {
if (manager.getmLivePlayViewHolder() != null) {
manager.getmLivePlayViewHolder().setPkEndview();
manager.setPkStatus(false);
-
+ manager.mLivePlayViewHolder.endPk();
}
if (manager != null) {
manager.removeDetailView();
@@ -1622,22 +1601,14 @@ public class LiveAudienceActivity extends LiveActivity {
if (type.equals(bean.getType())) {
switch (type) {
case "1":
- startActivity(new Intent(mContext, SystemMessageActivity.class)
- .putExtra("type", bean.getType())
- .putExtra("uid", "")
- .putExtra("title", bean.getTitle())
- .putExtra("headImg", ""));
+ startActivity(new Intent(mContext, SystemMessageActivity.class).putExtra("type", bean.getType()).putExtra("uid", "").putExtra("title", bean.getTitle()).putExtra("headImg", ""));
break;
case "3":
AppEventsLogger.newLogger(mContext).logEvent("FB_customer_service");
if (bean.getLink() != null && !"".equals(bean.getLink())) {
WebViewActivity.forward(mContext, bean.getLink(), true);
} else {
- startActivity(new Intent(mContext, SystemMessageActivity.class)
- .putExtra("type", bean.getType())
- .putExtra("uid", "")
- .putExtra("title", "")
- .putExtra("headImg", ""));
+ startActivity(new Intent(mContext, SystemMessageActivity.class).putExtra("type", bean.getType()).putExtra("uid", "").putExtra("title", "").putExtra("headImg", ""));
}
break;
@@ -1666,24 +1637,25 @@ public class LiveAudienceActivity extends LiveActivity {
Map map = new HashMap<>();
map.put("num", "9");
map.put("live_recommend", "sidebar");
+ map.put(" is_shengwang", isSw ? "1" : "0");
+
//推荐位
- MainNetManager.get(mContext)
- .anchorRecommend(map, new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(AnchorRecommendModel anchorRecommendModel) {
- list.clear();
- slideInfoModels.clear();
- List models = anchorRecommendModel.getList();
+ MainNetManager.get(mContext).anchorRecommend(map, new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(AnchorRecommendModel anchorRecommendModel) {
+ list.clear();
+ slideInfoModels.clear();
+ List models = anchorRecommendModel.getList();
- list.addAll(models);
- slideInfoModels = anchorRecommendModel.getSlide();
- }
+ list.addAll(models);
+ slideInfoModels = anchorRecommendModel.getSlide();
+ }
- @Override
- public void onError(String error) {
- ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
- }
- });
+ @Override
+ public void onError(String error) {
+ ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
+ }
+ });
}
@@ -1756,11 +1728,7 @@ public class LiveAudienceActivity extends LiveActivity {
case 0:
if (liveSudGamePopupXPopup == null) {
liveSudGamePopupXPopup = new LiveSudGamePopup(mContext, event.getCreateSudRoomModel());
- new XPopup.Builder(mContext)
- .enableDrag(false)
- .dismissOnTouchOutside(false)
- .dismissOnBackPressed(false)
- .asCustom(liveSudGamePopupXPopup).show();
+ new XPopup.Builder(mContext).enableDrag(false).dismissOnTouchOutside(false).dismissOnBackPressed(false).asCustom(liveSudGamePopupXPopup).show();
} else {
if (liveSudGamePopupXPopup != null) {
liveSudGamePopupXPopup.dialog.show();
@@ -1856,17 +1824,14 @@ public class LiveAudienceActivity extends LiveActivity {
if (!TextUtils.isEmpty(event.getRightsInterests())) {
//跳转贵族
if (TextUtils.equals(event.getRightsInterests(), getString(com.yunbao.common.R.string.noble))) {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.NOBLE));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.NOBLE));
//跳转守护
} else if (TextUtils.equals(event.getRightsInterests(), getString(com.yunbao.common.R.string.guard_guard))) {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.GUARD));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.GUARD));
manager.onGuardRed();
//跳转粉丝团
} else if (TextUtils.equals(event.getRightsInterests(), getString(com.yunbao.common.R.string.fan_club))) {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.FAN_CLUB));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.FAN_CLUB));
}
}
//互动游戏
@@ -1875,12 +1840,11 @@ public class LiveAudienceActivity extends LiveActivity {
if (manager != null && manager.getsudGameMin()) {
ToastUtil.show(WordUtil.isNewZh() ? "您已在游戏房间中" : "You are already in the game room");
} else {
- new XPopup.Builder(mContext)
- .enableDrag(false)
+ //直播间来的
+ new XPopup.Builder(mContext).enableDrag(false)
// .dismissOnTouchOutside(false)
// .dismissOnBackPressed(false)
- .moveUpToKeyboard(false)
- .asCustom(new SudGameListPopup(mContext, event.getInteractionID(), event.getChild(), mLiveUid))
+ .moveUpToKeyboard(false).asCustom(new SudGameListPopup(mContext, event.getInteractionID(), event.getChild(), mLiveUid))
.show();
}
@@ -1938,9 +1902,7 @@ public class LiveAudienceActivity extends LiveActivity {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
- new XPopup.Builder(mContext)
- .asCustom(new DragonExpirePopup(mContext, mLiveUid, maturityDateRemindModel, mStream))
- .show();
+ new XPopup.Builder(mContext).asCustom(new DragonExpirePopup(mContext, mLiveUid, maturityDateRemindModel, mStream)).show();
}
}, 3000);
@@ -1987,34 +1949,33 @@ public class LiveAudienceActivity extends LiveActivity {
private void checkMsgRed() {
- LiveNetManager.get(mContext)
- .getContactMsg(1, new com.yunbao.common.http.base.HttpCallback>() {
- @Override
- public void onSuccess(List data) {
- Log.i(TAG, "onSuccess: " + data.size());
- for (LiveUserMailBoxModel datum : data) {
- Log.i(TAG, "for data : " + datum);
- }
- setData(data);
+ LiveNetManager.get(mContext).getContactMsg(1, new com.yunbao.common.http.base.HttpCallback>() {
+ @Override
+ public void onSuccess(List data) {
+ Log.i(TAG, "onSuccess: " + data.size());
+ for (LiveUserMailBoxModel datum : data) {
+ Log.i(TAG, "for data : " + datum);
+ }
+ setData(data);
+ }
+
+ @Override
+ public void onError(String error) {
+ Log.e(TAG, "onError: " + error);
+ setData(new ArrayList<>());
+ }
+
+ void setData(List data) {
+ for (LiveUserMailBoxModel model : data) {
+ if (model.getIsRead() == 0) {
+ showMsgRed(0);
+ return;
}
-
- @Override
- public void onError(String error) {
- Log.e(TAG, "onError: " + error);
- setData(new ArrayList<>());
- }
-
- void setData(List data) {
- for (LiveUserMailBoxModel model : data) {
- if (model.getIsRead() == 0) {
- showMsgRed(0);
- return;
- }
- }
+ }
- showMsgRed(-1);
- }
- });
+ showMsgRed(-1);
+ }
+ });
}
}
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java
index fc6fcaec2..6a05e3d2b 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java
@@ -552,7 +552,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition super Bitmap> transition) {
boolean ret = RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(BitmapUtil.getInstance().convertMirror(resource), rect);
- sendSystemMessage(mContext.getString(R.string.live_anchor_leave));
+ sendSystemMessageRy(mContext.getString(R.string.live_anchor_leave));
}
@Override
@@ -565,7 +565,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
leave_img.setVisibility(View.GONE);
// 清除水印
boolean ret = RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(null, rect);
- sendSystemMessage(mContext.getString(R.string.live_anchor_come_back));
+ sendSystemMessageRy(mContext.getString(R.string.live_anchor_come_back));
}
HttpClient.getInstance().get("Live.isLeave", "Live.isLeave")
@@ -719,6 +719,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
fragment.show(getSupportFragmentManager(), "LiveLinkMicListDialogFragment");*/
FreePkDialogFragment fragment = new FreePkDialogFragment();
fragment.setDrPkNum(pk_nub);
+ fragment.setLiveUid(mLiveUid);
fragment.show(getSupportFragmentManager(), "LiveLinkMicListDialogFragment");
}
@@ -736,6 +737,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
public void openRandomPkWindow() {
RandomPkDialogFragment fragment = new RandomPkDialogFragment();
Bundle bundle = new Bundle();
+ bundle.putBoolean("isSw",false);
fragment.setArguments(bundle);
fragment.show(getSupportFragmentManager(), "RandomPkDialogFragment");
}
@@ -784,7 +786,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
}
mLiveReadyViewHolder = null;
if (mLiveRoomViewHolder == null) {
- mLiveRoomViewHolder = new LiveRoomViewHolder(true, 2, mContext, mContainer, (GifImageView) findViewById(R.id.gift_gif), (SVGAImageView) findViewById(R.id.gift_svga), mContainerWrap, getWindowManager());
+ mLiveRoomViewHolder = new LiveRoomViewHolder(true, 2, mContext, mContainer, (GifImageView) findViewById(R.id.gift_gif), (SVGAImageView) findViewById(R.id.gift_svga), mContainerWrap, getWindowManager(),isSw);
mLiveRoomViewHolder.setManager(manager);
mLiveRoomViewHolder.addToParent();
mLiveRoomViewHolder.subscribeActivityLifeCycle();
@@ -970,7 +972,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
JSONObject obj = JSON.parseObject(info[0]);
JSONObject datas = obj.getJSONObject("data");
try {
- SocketRyChatUtil.closeLive(datas.getString("votes"), datas.getString("length"), datas.getString("nums"), mLiveUid, mSocketRyClient);
+ SocketRyChatUtil.closeLive(datas.getString("votes"), datas.getString("length"), datas.getString("nums"), mLiveUid);
} catch (Exception e) {
e.printStackTrace();
}
@@ -1235,8 +1237,6 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
JSONObject obj = JSON.parseObject(info[0]);
if (obj != null) {
if (obj.getString("ispk").equals("0")) {
-
-
IMRTCManager.getInstance().requestJoinOtherRoom(pkUid, true, extra, new IRCRTCResultCallback() {
@Override
public void onSuccess() {
@@ -1268,7 +1268,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
});
} else {
- ToastUtil.show("主播正在PK,稍後再試");
+ ToastUtil.show(mContext.getString(R.string.pking_over));
if (RandomPkManager.getInstance().isRandomModel()) {
RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
}
@@ -1343,7 +1343,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
}
});
} else {
- ToastUtil.show("主播正在PK,稍後再試");
+ ToastUtil.show(mContext.getString(R.string.pking_over));
}
}
}
@@ -1402,6 +1402,11 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
}
}
+ @Override
+ public void onLinkDRMicPKToUser(UserBean u) {
+
+ }
+
//多人PK接受
@Override
public void onLinkDRMicPkApplyOk(UserBean u) {
@@ -1641,7 +1646,10 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
}
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.seisShowGif(true);
- mLiveRoomViewHolder.endDRGif();
+ if(isDRPK==1){
+ mLiveRoomViewHolder.endDRGif();
+ }
+
}
// if (mLiveRoomViewHolder != null) {
// mLiveRoomViewHolder.hotAddVisibility(false);
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveSwAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveSwAnchorActivity.java
new file mode 100644
index 000000000..3c288e87f
--- /dev/null
+++ b/live/src/main/java/com/yunbao/live/activity/LiveSwAnchorActivity.java
@@ -0,0 +1,1963 @@
+package com.yunbao.live.activity;
+
+import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_DISABLE;
+import static com.tencent.trtc.TRTCCloudDef.TRTC_VIDEO_MIRROR_TYPE_ENABLE;
+import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
+import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
+import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_dr_pk_nub;
+import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_start_dr_pk;
+import static com.yunbao.live.views.LiveRyAnchorViewHolder.btn_start_dr_pk_view;
+
+import android.app.Dialog;
+import android.content.Context;
+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;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+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;
+import com.yunbao.common.bean.SendMoneyLongModel;
+import com.yunbao.common.bean.UserBean;
+import com.yunbao.common.dialog.NotCancelableDialog;
+import com.yunbao.common.event.AllServerNotifyFFGGGDJANEvent;
+import com.yunbao.common.event.GiftWallIlluminateEvent;
+import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent;
+import com.yunbao.common.event.LoginInvalidEvent;
+import com.yunbao.common.event.SendBlindGiftEvent;
+import com.yunbao.common.event.SendMoneyLongEndEvent;
+import com.yunbao.common.event.ShowHideEvent;
+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.LiveHttpConsts;
+import com.yunbao.common.http.LiveHttpUtil;
+import com.yunbao.common.http.live.LiveNetManager;
+import com.yunbao.common.manager.IMLoginManager;
+import com.yunbao.common.manager.MicUserManager;
+import com.yunbao.common.manager.MicedUserManager;
+import com.yunbao.common.manager.RandomPkManager;
+import com.yunbao.common.utils.BitmapUtil;
+import com.yunbao.common.utils.Bus;
+import com.yunbao.common.utils.DateFormatUtil;
+import com.yunbao.common.utils.DialogUitl;
+import com.yunbao.common.utils.L;
+import com.yunbao.common.utils.LogUtil;
+import com.yunbao.common.utils.MicStatusManager;
+import com.yunbao.common.utils.StringUtil;
+import com.yunbao.common.utils.ToastUtil;
+import com.yunbao.common.utils.WordUtil;
+import com.yunbao.common.views.LiveNewWishListPopup;
+import com.yunbao.common.views.LiveRobotSettingCustomPopup;
+import com.yunbao.common.views.LiveSudGamePopup;
+import com.yunbao.faceunity.FaceManager;
+import com.yunbao.live.R;
+import com.yunbao.live.bean.LiveChatBean;
+import com.yunbao.live.bean.LiveGuardInfo;
+import com.yunbao.live.bean.LiveKsyConfigBean;
+import com.yunbao.live.bean.LiveReceiveGiftBean;
+import com.yunbao.live.bean.NewAllServerNotifyGuardEvent;
+import com.yunbao.live.dialog.FreePkDialogFragment;
+import com.yunbao.live.dialog.LiveInputDialogFragment;
+import com.yunbao.live.dialog.LiveNewFunctionDialogFragment;
+import com.yunbao.live.dialog.LivePrankDialogFragment;
+import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience;
+import com.yunbao.live.dialog.RandomPkDialogFragment;
+import com.yunbao.live.event.LinkMicTxMixStreamEvent;
+import com.yunbao.live.event.LiveAudienceEvent;
+import com.yunbao.live.interfaces.LiveFunctionClickListener;
+import com.yunbao.live.interfaces.LivePushListener;
+import com.yunbao.live.music.LiveMusicDialogFragment;
+import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
+import com.yunbao.live.presenter.LiveLinkMicPresenter;
+import com.yunbao.live.presenter.LiveSwLinkMicPkPresenter;
+import com.yunbao.live.socket.SocketSwChatUtil;
+import com.yunbao.live.socket.SocketSwClient;
+import com.yunbao.live.socket.SocketSendBean;
+import com.yunbao.live.views.LiveEndViewHolder;
+import com.yunbao.live.views.LiveMusicViewHolder;
+import com.yunbao.live.views.LiveNewReadySwViewHolder;
+import com.yunbao.live.views.LivePushSwViewHolder;
+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;
+import cn.rongcloud.rtc.base.RCRTCRect;
+import cn.rongcloud.rtc.base.RTCErrorCode;
+import io.agora.beautyapi.faceunity.agora.SWManager;
+import io.rong.imlib.IRongCallback;
+import io.rong.imlib.RongIMClient;
+import io.rong.imlib.model.Conversation;
+import io.rong.imlib.model.Message;
+import io.rong.message.TextMessage;
+import pl.droidsonroids.gif.GifImageView;
+
+
+/**
+ * Created by cxf on 2018/10/7.
+ * 主播直播间
+ */
+
+public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionClickListener {
+
+ private static final String TAG = "LiveSwAnchorActivity";
+
+ public static void forward(Context context, int liveSdk, LiveKsyConfigBean bean) {
+ Intent intent = new Intent(context, LiveSwAnchorActivity.class);
+ intent.putExtra(Constants.LIVE_SDK, liveSdk);
+ intent.putExtra(Constants.LIVE_KSY_CONFIG, bean);
+ context.startActivity(intent);
+ }
+
+ private ViewGroup mRoot;
+ private ViewGroup mContainerWrap;
+ public LivePushSwViewHolder mLivePushViewHolder;
+ public LiveNewReadySwViewHolder mLiveReadyViewHolder;
+ public static LiveRyAnchorViewHolder mLiveAnchorViewHolder;
+ private LiveMusicViewHolder mLiveMusicViewHolder;
+ private boolean mStartPreview;//是否开始预览
+ private boolean mStartLive;//是否开始了直播
+ private List mGameList;//游戏开关
+ private boolean mBgmPlaying;//是否在播放背景音乐
+ private LiveKsyConfigBean mLiveKsyConfigBean;
+ private HttpCallback mCheckLiveCallback;
+ private File mLogFile;
+ private int mReqCount;
+ private boolean mPaused;
+ 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 backIndex = 0;//0=未判断,1=已判断
+ private FaceManager manager;
+ private ImageView leave_img;
+
+ private final RandomPkManager.OnRandomPkTimer onRandomPkTimer = new RandomPkManager.OnRandomPkTimer() {
+ @Override
+ public void onTimer(String time) {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.setRandomPkTimer(String.format(mContext.getString(R.string.random_pk_info_btn_ing), time));
+ }
+ }
+
+ @Override
+ public void onStartPK(String pkUid) {
+ JSONObject msg1 = buildLinkMicJSON();
+ msg1.put("random_pk", "1");
+ if (RandomPkManager.getInstance().isRankModel()) {
+ msg1.put("is_ladders", "https://downs.yaoulive.com/rank_top_box.png");
+ }
+ linkMicAnchorApply(pkUid, pkUid, true);
+ }
+
+ @Override
+ public void onPking() {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.setRandomPkTimer(null);
+ }
+ }
+
+ @Override
+ public void onPkEnd() {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.setRandomPkTimer(null);
+ }
+ }
+ };
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.activity_live_anchor;
+ }
+
+ @Override
+ protected void main() {
+ super.main();
+ Bus.getOn(this);
+ Intent intent = getIntent();
+ initFaceManager();
+ leave_img = findViewById(R.id.leave_img);
+ mLiveSDK = intent.getIntExtra(Constants.LIVE_SDK, Constants.LIVE_SDK_KSY);
+ if(mLiveSDK ==Constants.LIVE_SDK_SW){
+ isSw = true;
+ }
+ mLiveKsyConfigBean = intent.getParcelableExtra(Constants.LIVE_KSY_CONFIG);
+ L.e(TAG, "直播sdk----->" + (mLiveSDK == Constants.LIVE_SDK_KSY ? "金山云" : "腾讯云"));
+ mRoot = (ViewGroup) findViewById(R.id.root);
+ mSocketUserType = Constants.SOCKET_USER_TYPE_ANCHOR;
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ mLiveUid = u.getId();
+ mLiveBean = new LiveBean();
+ mLiveBean.setUid(mLiveUid);
+ mLiveBean.setUserNiceName(u.getUserNiceName());
+ mLiveBean.setAvatar(u.getAvatar());
+ mLiveBean.setAvatarThumb(u.getAvatarThumb());
+ mLiveBean.setLevelAnchor(u.getLevelAnchor());
+ mLiveBean.setGoodNum(u.getGoodName());
+ mLiveBean.setCity(u.getCity());
+ mBeautySdkType = CommonAppConfig.getInstance().getBeautySdkType();
+
+ mLivePushViewHolder = new LivePushSwViewHolder(mContext, (ViewGroup) findViewById(R.id.preview_container));
+ mLivePushViewHolder.setLiveActivityContainer(mContainer);
+
+ mLivePushViewHolder.addToParent();
+ mLivePushViewHolder.subscribeActivityLifeCycle();
+ mContainerWrap = (ViewGroup) findViewById(R.id.container_wrap);
+ mContainer = (ViewGroup) findViewById(R.id.container);
+ mLiveSwLinkMicPkPresenter = new LiveSwLinkMicPkPresenter(mContext, mLivePushViewHolder, true, mContainer);
+
+ RandomPkManager.getInstance().addOnRandomPkTimer(onRandomPkTimer);
+
+ manager.setOnMirrorChanged(new FaceManager.OnMirrorChanged() {
+ @Override
+ public void onChange(boolean falg) {
+ mLivePushViewHolder.setEnableBeauty(falg);
+ }
+ });
+
+ //添加开播前设置控件
+ mLiveReadyViewHolder = new LiveNewReadySwViewHolder(mContext, mContainer, mLiveSDK);
+ mLiveReadyViewHolder.setManager(manager);
+ mLiveReadyViewHolder.addToParent();
+ mLiveReadyViewHolder.setLiveUid(mLiveUid);
+ mLiveReadyViewHolder.subscribeActivityLifeCycle();
+ mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePushViewHolder, true, mLiveSDK, mContainer);
+ mLiveLinkMicAnchorPresenter = new LiveLinkMicAnchorPresenter(mContext, mLivePushViewHolder, true, mLiveSDK, mContainer);
+ mLivePushViewHolder.setLivePushListener(new LivePushListener() {
+ @Override
+ public void onPreviewStart() {
+ //开始预览回调
+ mStartPreview = true;
+ }
+
+ @Override
+ public void onPushStart() {
+ //开始推流回调
+ LiveHttpUtil.changeLive(mStream);
+
+
+ }
+
+ @Override
+ public void onPushFailed() {
+ //推流失败回调
+ ToastUtil.show(mContext.getString(R.string.live_push_failed));
+ }
+ });
+
+
+ }
+
+ private void initFaceManager() {
+ manager = new FaceManager();
+ manager.initFURender(mContext);
+ //暂时去掉
+ //manager.drawRongFrame(mContext);
+ }
+
+ public boolean isStartPreview() {
+ return mStartPreview;
+ }
+
+ /**
+ * 主播直播间功能按钮点击事件
+ *
+ * @param functionID
+ */
+ int mrr = 0;
+ public int leave = 0;
+
+
+ @Override
+ public void onClick(int functionID) {
+ 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;
+ case Constants.LIVE_FUNC_ZG://zg
+ // ToastUtil.show("開發中,敬請期待");
+ LivePrankDialogFragment fragment = new LivePrankDialogFragment();
+ fragment.setmLiveUid(mLiveUid);
+ fragment.show(getSupportFragmentManager(), "LivePrankDialogFragment");
+ break;
+ case Constants.LIVE_FUNC_MIC://語音
+ //ToastUtil.show("開發中,敬請期待");
+ if (isDRPK != 1) {
+ openMicWindow(1);
+ } else {
+ ToastUtil.show(WordUtil.isNewZh() ? "您已在PK中" : "You are already in the PK");
+ }
+ break;
+ case Constants.LIVE_FUNC_DR://多人PK
+// if (LiveRyLinkMicPkPresenter.inputStreamList.size() == 4) {
+// return;
+// }
+ if (isDRPK != 1) {
+ HttpClient.getInstance().get("live.getdrnum", "live.getdrnum")
+ .execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0) {
+ JSONObject obj = JSONObject.parseObject(info[0]);
+ pk_nub = Integer.valueOf(obj.getString("pk_num_day"));
+
+ btn_dr_pk_nub.setText(String.format(getString(R.string.number_of_remaining_times), String.valueOf(pk_nub)));
+ DialogUitl.showSimpleDialog(mContext, String.format(getString(R.string.confirmed_to_proceed), String.valueOf(pk_nub)),
+ false,
+ new DialogUitl.SimpleCallback2() {
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ HttpClient.getInstance().get("live.createDRPKroom", "live.createDRPKroom")
+ .params("type", "1")
+ .params("sign", "1")
+ .execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+
+ if (code == 0) {
+ LiveSwLinkMicPkPresenter.mApplyUid = CommonAppConfig.getInstance().getUid();
+ btn_start_dr_pk.setVisibility(View.VISIBLE);
+// dr_pk_view.setVisibility(View.VISIBLE);
+ L.eSw("ac2222222222222222222");
+ final SocketSendBean msg1 = new SocketSendBean()
+ .param("_method_", SOCKET_LIVE_DRPK)
+ .param("action", 9)
+ .param("msgtype", 1);
+ msg1.create();
+
+ Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
+ TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
+ Message message = Message.obtain("g" + mLiveUid, conversationType, messageContent);
+
+ RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
+ @Override
+ public void onAttached(Message message) {
+
+ }
+
+ @Override
+ public void onSuccess(Message message) {
+ isDRPK = 1;
+ btn_start_dr_pk_view.setVisibility(View.VISIBLE);
+ mLiveSwLinkMicPkPresenter.setDRInitiator(true);
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+ Log.i("tx", "发送失败" + errorCode + message);
+
+ }
+ });
+
+ } else {
+ ToastUtil.show(msg);
+ }
+ }
+ });
+
+ }
+
+ @Override
+ public void onCancelClick() {
+
+ }
+ });
+ } else {
+ ToastUtil.show(msg);
+ }
+ }
+ });
+ } else {
+ ToastUtil.show(WordUtil.isNewZh() ? "您已在PK中" : "You are already in the PK");
+ }
+ break;
+ case Constants.LIVE_FUNC_BEAUTY://美颜
+ beauty();
+ break;
+ case Constants.LIVE_FUNC_CAMERA://切换镜头
+ toggleCamera();
+ break;
+ case Constants.LIVE_FUNC_FLASH://切换闪光灯
+ toggleFlash();
+ break;
+ case Constants.LIVE_FUNC_MUSIC://伴奏
+ openMusicWindow();
+ break;
+ case Constants.LIVE_FUNC_SHARE://分享
+ openShareWindow();
+ break;
+ case Constants.LIVE_FUNC_GAME://游戏
+ openGameWindow();
+ break;
+ case Constants.LIVE_FUNC_RED_PACK://红包
+ openRedPackSendWindow();
+ break;
+ case Constants.LIVE_FUNC_ZSLK://暫時離開
+ leaveLive();
+ break;
+ case Constants.LIVE_FUNC_WKS:
+ String url = CommonAppConfig.HOST + "/h5/activity/weekStar/index.html?&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid;
+ ZhuangBanActivity.forward(mContext, url, false, 0);
+ break;
+ case Constants.LIVE_FUNC_LINK_MIC://连麦
+ if (isDRPK != 1) {
+ //openLinkMicAnchorWindow(false);
+ openFreePkWindow();
+ } else {
+ ToastUtil.show(WordUtil.isNewZh() ? "您已在PK中" : "You are already in the PK");
+ }
+ break;
+ case Constants.LIVE_FUNC_WISHLIST://心愿单
+ openWishListWindow();
+ break;
+ case Constants.LIVE_FUNC_MIRROR://鏡像
+
+ TRTCCloudDef.TRTCRenderParams t = new TRTCCloudDef.TRTCRenderParams();
+ if (mrr == 0) {
+ mrr = 1;
+ t.mirrorType = TRTC_VIDEO_MIRROR_TYPE_ENABLE;
+ } else if (mrr == 1) {
+ mrr = 0;
+ t.mirrorType = TRTC_VIDEO_MIRROR_TYPE_DISABLE;
+ }
+ break;
+ case Constants.LIVE_FUNC_RANDOM_PK:
+ if (isDRPK != 1) {
+ openRandomPkWindow();
+ } else {
+ ToastUtil.show(WordUtil.isNewZh() ? "您已在PK中" : "You are already in the PK");
+ }
+ break;
+ default:
+ break;
+ }
+
+ }
+
+
+ /**
+ * 主播展示离开直播间
+ */
+ private void leaveLive() {
+ if (PKing || isDRPK == 1) {
+ return;
+ }
+ RCRTCRect rect = new RCRTCRect(0f, 0f, 1.0f);
+ if (leave == 0) {
+ leave = 1;
+ leave_img.setVisibility(View.VISIBLE);
+ Glide.with(mContext).asBitmap().load(R.mipmap.zslk).into(new CustomTarget() {
+ @Override
+ public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition super Bitmap> transition) {
+
+ boolean ret = RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(BitmapUtil.getInstance().convertMirror(resource), rect);
+ sendSystemMessageSw(mContext.getString(R.string.live_anchor_leave));
+ }
+
+ @Override
+ public void onLoadCleared(@Nullable Drawable placeholder) {
+
+ }
+ });
+ } else if (leave == 1) {
+ leave = 0;
+ leave_img.setVisibility(View.GONE);
+ // 清除水印
+ boolean ret = RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(null, rect);
+ sendSystemMessageSw(mContext.getString(R.string.live_anchor_come_back));
+ }
+
+ HttpClient.getInstance().get("Live.isLeave", "Live.isLeave")
+ .params("uid", CommonAppConfig.getInstance().getUid())
+ .params("isleave", leave)
+ .params("token", CommonAppConfig.getInstance().getToken())
+ .execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+
+ }
+ });
+ }
+
+
+ /**
+ * 打开心愿单窗口
+ */
+ public void openWishListWindow() {
+// LiveNewWishListDialogFragment fragment = new LiveNewWishListDialogFragment();
+// if (mContext instanceof LiveRyAnchorActivity) {
+// fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveWishListDialogFragment");
+// }
+ new XPopup.Builder(mContext)
+ .enableDrag(false)
+ .asCustom(new LiveNewWishListPopup(LiveSwAnchorActivity.this))
+
+ .show();
+ }
+
+ //打开相机前执行
+ public void beforeCamera() {
+ if (mLivePushViewHolder != null) {
+ mLivePushViewHolder.setOpenCamera(true);
+ }
+ }
+
+
+ /**
+ * 切换镜头
+ */
+ public void toggleCamera() {
+ if (mLivePushViewHolder != null) {
+ mLivePushViewHolder.toggleCamera();
+ }
+ }
+
+ /**
+ * 切换闪光灯
+ */
+ public void toggleFlash() {
+ if (mLivePushViewHolder != null) {
+ mLivePushViewHolder.toggleFlash();
+ }
+ }
+
+ /**
+ * 设置美颜
+ */
+ public void beauty() {
+ if (mLiveReadyViewHolder != null) {
+ mLiveReadyViewHolder.hide();
+ }
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.changeFaceUnityView();
+ }
+ }
+
+ /**
+ * 飘心
+ */
+ public void light() {
+ if (mLiveRoomViewHolder != null) {
+ }
+ }
+
+ /**
+ * 打开音乐窗口
+ */
+ private void openMusicWindow() {
+ if (isLinkMicAnchor() || isLinkMicAnchor()) {
+ ToastUtil.show(mContext.getString(R.string.link_mic_not_bgm));
+ return;
+ }
+ LiveMusicDialogFragment fragment = new LiveMusicDialogFragment();
+ fragment.setActionListener(new LiveMusicDialogFragment.ActionListener() {
+ @Override
+ public void onChoose(String musicId) {
+ if (mLivePushViewHolder != null) {
+ if (mLiveMusicViewHolder == null) {
+ mLiveMusicViewHolder = new LiveMusicViewHolder(mContext, mContainer, mLivePushViewHolder);
+ mLiveMusicViewHolder.subscribeActivityLifeCycle();
+ mLiveMusicViewHolder.addToParent();
+ }
+ mLiveMusicViewHolder.play(musicId);
+ mBgmPlaying = true;
+ }
+ }
+ });
+ fragment.show(getSupportFragmentManager(), "LiveMusicDialogFragment");
+ }
+
+ /**
+ * 关闭背景音乐
+ */
+ public void stopBgm() {
+ if (mLiveMusicViewHolder != null) {
+ mLiveMusicViewHolder.release();
+ }
+ mLiveMusicViewHolder = null;
+ mBgmPlaying = false;
+ }
+
+ public boolean isBgmPlaying() {
+ return mBgmPlaying;
+ }
+
+
+ /**
+ * 打开功能弹窗
+ */
+ public void showFunctionDialog() {
+ LiveNewFunctionDialogFragment fragment = new LiveNewFunctionDialogFragment();
+ Bundle bundle = new Bundle();
+ boolean hasGame = false;
+ if (CommonAppConfig.GAME_ENABLE && mGameList != null) {
+ hasGame = mGameList.size() > 0;
+ }
+ bundle.putBoolean(Constants.HAS_GAME, hasGame);
+ bundle.putInt("leave", leave);
+ bundle.putString("liveUid", mLiveUid);
+ bundle.putBoolean("isPk", isDRPK == 1 || PKing || mLivePushViewHolder.isPking());
+ bundle.putLong("liveTime", mLiveAnchorViewHolder.getmAnchorLiveTime());
+ bundle.putBoolean(Constants.OPEN_FLASH, mLivePushViewHolder != null && mLivePushViewHolder.isFlashOpen());
+ fragment.setArguments(bundle);
+ fragment.setFunctionClickListener(this);
+ fragment.show(getSupportFragmentManager(), "LiveFunctionDialogFragment");
+ }
+
+ /**
+ * 打开主播连麦窗口
+ */
+ public void openLinkMicAnchorWindow(boolean isDRPK) {
+ if (mLiveLinkMicAnchorPresenter != null && !mLiveLinkMicAnchorPresenter.canOpenLinkMicAnchor()) {
+ return;
+ }
+/* LiveLinkMicListDialogFragment fragment = new LiveLinkMicListDialogFragment();
+ Bundle bundle = new Bundle();
+ bundle.putBoolean("isDRPK", isDRPK);
+ fragment.setArguments(bundle);
+ fragment.show(getSupportFragmentManager(), "LiveLinkMicListDialogFragment");*/
+ FreePkDialogFragment fragment = new FreePkDialogFragment();
+ fragment.setDrPkNum(pk_nub);
+ fragment.setLiveUid(mLiveUid);
+ fragment.show(getSupportFragmentManager(), "LiveLinkMicListDialogFragment");
+
+ }
+
+ public void openFreePkWindow() {
+ FreePkDialogFragment fragment = new FreePkDialogFragment();
+ Bundle bundle = new Bundle();
+ fragment.setArguments(bundle);
+ fragment.show(getSupportFragmentManager(), "FreePkDialogFragment");
+ }
+
+ /**
+ * 随机PK
+ */
+ public void openRandomPkWindow() {
+ RandomPkDialogFragment fragment = new RandomPkDialogFragment();
+ Bundle bundle = new Bundle();
+ bundle.putBoolean("isSw",true);
+ fragment.setArguments(bundle);
+ fragment.show(getSupportFragmentManager(), "RandomPkDialogFragment");
+ }
+
+ /**
+ * 打开选择游戏窗口
+ */
+ private void openGameWindow() {
+ if (isLinkMic() || isLinkMicAnchor()) {
+ ToastUtil.show(mContext.getString(R.string.live_link_mic_cannot_game));
+ return;
+ }
+ }
+
+ /**
+ * 关闭游戏
+ */
+ public void closeGame() {
+// if (mGamePresenter != null) {
+// mGamePresenter.closeGame();
+// }
+ }
+
+ /**
+ * 开播成功
+ *
+ * @param data createRoom返回的数据
+ */
+ public void startLiveSuccess(String data, int liveType, int liveTypeVal) {
+ Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((" + data);
+ mLiveType = liveType;
+ mLiveTypeVal = liveTypeVal;
+ //处理createRoom返回的数据
+ JSONObject obj = JSON.parseObject(data);
+ mStream = obj.getString("stream");
+ mDanmuPrice = obj.getString("barrage_fee");
+ String playUrl = obj.getString("pull");
+ L.e("createRoom----播放地址--->" + playUrl);
+ mLiveBean.setPull(playUrl);
+ mTxAppId = obj.getString("tx_appid");
+
+ //移除开播前的设置控件,添加直播间控件
+ if (mLiveReadyViewHolder != null) {
+ mLiveReadyViewHolder.removeFromParent();
+ mLiveReadyViewHolder.release();
+ }
+ mLiveReadyViewHolder = null;
+ if (mLiveRoomViewHolder == null) {
+ mLiveRoomViewHolder = new LiveRoomViewHolder(true, 2, mContext, mContainer, (GifImageView) findViewById(R.id.gift_gif), (SVGAImageView) findViewById(R.id.gift_svga), mContainerWrap, getWindowManager(),isSw);
+ mLiveRoomViewHolder.setManager(manager);
+ mLiveRoomViewHolder.addToParent();
+ mLiveRoomViewHolder.subscribeActivityLifeCycle();
+ mLiveRoomViewHolder.setLiveInfo(mLiveUid, mStream, obj.getIntValue("userlist_time") * 1000);
+ mLiveRoomViewHolder.setVotes(obj.getString("votestotal"));
+ mLiveRoomViewHolder.setMedaRankNum(obj.getString("medalRankNum"));
+ mLiveRoomViewHolder.startFace();
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u != null) {
+ mLiveRoomViewHolder.setRoomNum(u.getLiangNameTip());
+ mLiveRoomViewHolder.setName(u.getUserNiceName());
+ mLiveRoomViewHolder.setAvatar(u.getAvatar());
+ mLiveRoomViewHolder.setAnchorLevel(u.getLevelAnchor());
+ mLiveRoomViewHolder.setAnchorGoodNumber(u.getGoodName());
+ mLiveRoomViewHolder.initHourRankList();
+ }
+ mLiveRoomViewHolder.startAnchorLight();
+ //初始化女神说
+ mLiveRoomViewHolder.initAnchorSay();
+ mLiveRoomViewHolder.setGiftWall(obj.getString("gift_wall_lighten_number"), obj.getString("gift_wall_lighten_total"));
+ }
+ if (mLiveAnchorViewHolder == null) {
+ mLiveAnchorViewHolder = new LiveRyAnchorViewHolder(mContext, mContainer);
+ mLiveAnchorViewHolder.setLiveBean(mLiveBean);
+ mLiveAnchorViewHolder.addToParent();
+ mLiveAnchorViewHolder.startAnchorLiveTime();
+ }
+ mLiveBottomViewHolder = mLiveAnchorViewHolder;
+ mSocketSwClient = new SocketSwClient(mLiveUid, this, mContext);
+ mSocketSwClient.setLivePushSwViewHolder(mLivePushViewHolder);
+ CommonAppContext.Ingroup = 1;
+
+ if (mLiveLinkMicPresenter != null) {
+ mLiveLinkMicPresenter.setSocketClient(mSocketClient);
+ }
+ if (mLiveLinkMicAnchorPresenter != null) {
+ mLiveLinkMicAnchorPresenter.setSocketClient(mSocketClient);
+ mLiveLinkMicAnchorPresenter.setPlayUrl(playUrl);
+ mLiveLinkMicAnchorPresenter.setSelfStream(mStream);
+ }
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.setSelfStream(mStream);
+ }
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.setLiveUid(mLiveUid, "");
+ }
+
+ //开始推流
+ if (mLivePushViewHolder != null) {
+ mLivePushViewHolder.startPush(obj.getString("push"));
+ }
+ //开始显示直播时长
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.startAnchorLiveTime();
+ mLiveRoomViewHolder.startAnchorCheckLive();
+ mLiveRoomViewHolder.setAnchorGoodNumber(obj.getString("goodnum"));
+ }
+ mStartLive = true;
+ mLiveRoomViewHolder.startRefreshUserList();
+ mLiveRoomViewHolder.hideFloatMsg();
+ mLiveRoomViewHolder.initPkRank(null);
+
+ //守护相关
+ mLiveGuardInfo = new LiveGuardInfo();
+ int guardNum = obj.getIntValue("guard_nums");
+ mLiveGuardInfo.setGuardNum(guardNum);
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.setGuardNum(guardNum);
+
+ }
+
+ //奖池等级
+ int giftPrizePoolLevel = obj.getIntValue("jackpot_level");
+ if (giftPrizePoolLevel >= 0) {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.showPrizePoolLevel(String.valueOf(giftPrizePoolLevel));
+ }
+ }
+
+ //游戏相关
+ if (CommonAppConfig.GAME_ENABLE) {
+ mGameList = JSON.parseArray(obj.getString("game_switch"), Integer.class);
+ }
+ getAiRobotStatus();
+ MicedUserManager.get().removeAllMicUserList();
+ MicUserManager.get().removeAllMicUserList();
+ }
+
+ /**
+ * 关闭直播
+ */
+ public void closeLive() {
+ DialogUitl.showSimpleDialog(mContext, mContext.getString(R.string.live_end_live), new DialogUitl.SimpleCallback() {
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ MicStatusManager.getInstance().closeMic(mContext);
+ MicedUserManager.get().removeAllMicUserList();
+ MicUserManager.get().removeAllMicUserList();
+ PKing = false;
+ isDRPK = 0;
+ DRPKing = -1;
+ endLive();
+ RandomPkManager.getInstance().release();
+ }
+ });
+ }
+
+ public void endLives() {
+
+
+ RCRTCEngine.getInstance().getDefaultVideoStream().stopCamera(new IRCRTCResultCallback() {
+ @Override
+ public void onSuccess() {
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode errorCode) {
+
+ }
+ });
+ RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
+ @Override
+ public void onSuccess() {
+ Log.i("ry", "退出成功");
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode errorCode) {
+ Log.i("ry", "退出失败" + errorCode);
+ }
+ });
+
+
+ if (mLivePushViewHolder != null) {
+ mLivePushViewHolder.release();
+ }
+ if (mLiveLinkMicPresenter != null) {
+ mLiveLinkMicPresenter.release();
+ }
+ mLivePushViewHolder = null;
+ mLiveLinkMicPresenter = null;
+
+ superBackPressed();
+
+
+ release();
+ mStartLive = false;
+ }
+
+ /**
+ * 结束直播
+ */
+ public void endLive() {
+ RCRTCEngine.getInstance().getDefaultVideoStream().stopCamera(new IRCRTCResultCallback() {
+ @Override
+ public void onSuccess() {
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode errorCode) {
+
+ }
+ });
+ RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
+ @Override
+ public void onSuccess() {
+ Log.i("ry", "退出成功");
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode errorCode) {
+ Log.i("ry", "退出失败" + errorCode);
+ }
+ });
+ //请求关播的接口
+ 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");
+ try {
+ SocketSwChatUtil.closeLive(datas.getString("votes"), datas.getString("length"), datas.getString("nums"), mLiveUid);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ if (mLiveEndViewHolder == null) {
+ mLiveEndViewHolder = new LiveEndViewHolder(mContext, mRoot, mLiveBean.getUid());
+ mLiveEndViewHolder.subscribeActivityLifeCycle();
+ mLiveEndViewHolder.addToParent();
+ mLiveEndViewHolder.showData(mLiveBean, mStream);
+ mLiveEndViewHolder.upData(datas.getString("votes"), datas.getString("length"), Long.parseLong(datas.getString("nums")));
+ }
+ if (mLiveAnchorViewHolder != null) {
+ mLiveAnchorViewHolder.release();
+ mLiveAnchorViewHolder = null;
+ }
+
+ if (mLivePushViewHolder != null) {
+ mLivePushViewHolder.release();
+ }
+ if (mLiveLinkMicPresenter != null) {
+ mLiveLinkMicPresenter.release();
+ }
+ mLivePushViewHolder = null;
+ mLiveLinkMicPresenter = null;
+ release();
+ mStartLive = false;
+ } else {
+ ToastUtil.show(msg);
+ }
+ }
+
+ @Override
+ public boolean showLoadingDialog() {
+ return true;
+ }
+
+ @Override
+ public Dialog createLoadingDialog() {
+ return DialogUitl.loadingDialog(mContext, mContext.getString(R.string.live_end_ing));
+ }
+ });
+ }
+
+
+ @Override
+ public void onBackPressed() {
+
+ if (mStartLive) {
+ if (!canBackPressed()) {
+ return;
+ }
+ closeLive();
+ } else {
+ endLives();
+ }
+
+ }
+
+ public void superBackPressed() {
+ super.onBackPressed();
+ }
+
+ public void release() {
+ LiveHttpUtil.cancel(LiveHttpConsts.CHANGE_LIVE);
+ LiveHttpUtil.cancel(LiveHttpConsts.STOP_LIVE);
+ LiveHttpUtil.cancel(LiveHttpConsts.LIVE_PK_CHECK_LIVE);
+ LiveHttpUtil.cancel(LiveHttpConsts.SET_LINK_MIC_ENABLE);
+ CommonHttpUtil.cancel(CommonHttpConsts.CHECK_TOKEN_INVALID);
+ if (mLiveReadyViewHolder != null) {
+ mLiveReadyViewHolder.release();
+ }
+ if (mLiveMusicViewHolder != null) {
+ mLiveMusicViewHolder.release();
+ }
+ if (mLivePushViewHolder != null) {
+ mLivePushViewHolder.release();
+ }
+ if (mLiveLinkMicPresenter != null) {
+ mLiveLinkMicPresenter.release();
+ }
+ mLiveMusicViewHolder = null;
+ mLiveReadyViewHolder = null;
+ mLivePushViewHolder = null;
+ mLiveLinkMicPresenter = null;
+ //断开socket
+ if (mSocketSwClient != null) {
+ mSocketSwClient.disConnect();
+ }
+ super.release();
+ }
+
+ private boolean isKeyBack = false;
+
+ @Override
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ isKeyBack = true;
+ }
+ return super.onKeyUp(keyCode, event);
+ }
+
+ @Override
+ protected void onDestroy() {
+ if (manager != null) {
+ manager.release();
+ }
+ LiveHttpUtil.cancel(LiveHttpConsts.ANCHOR_CHECK_LIVE);
+ super.onDestroy();
+ if (mLivePushViewHolder != null) {
+ mLivePushViewHolder.onDestroy();
+ }
+ if (mLiveReadyViewHolder != null) {
+ mLiveReadyViewHolder.onDestroy();
+ }
+ if (mLiveAnchorViewHolder != null) {
+ mLiveAnchorViewHolder.onDestroy();
+ }
+ mLivePushViewHolder = null;
+ mLiveReadyViewHolder = null;
+ mLiveAnchorViewHolder = null;
+ if (MicStatusManager.getInstance().isAnchorOpenRoom()) {
+ MicStatusManager.getInstance().closeMic(mContext);
+ }
+ L.e("LiveAnchorActivity-------onDestroy------->");
+ RandomPkManager.getInstance().unregisterOnRandomPkTimer(onRandomPkTimer);
+ Bus.getOff(this);
+ }
+
+
+ @Override
+ protected void onPause() {
+// if (mLiveRoomViewHolder != null) {
+// mLiveRoomViewHolder.anchorPause();
+// }
+ super.onPause();
+// if (isKeyBack) {
+// sendSystemMessage(mContext.getString(R.string.live_anchor_leave));
+// }
+// mPaused = true;
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+// if (mPaused) {
+// if (mLiveRoomViewHolder != null) {
+// mLiveRoomViewHolder.anchorResume();
+// }
+// sendSystemMessage(mContext.getString(R.string.live_anchor_come_back));
+// CommonHttpUtil.checkTokenInvalid();
+// }
+// mPaused = false;
+ }
+
+
+ /**
+ * 直播间 主播登录失效
+ */
+ @Override
+ public void onAnchorInvalid() {
+ super.onAnchorInvalid();
+ endLive();
+ }
+
+ /**
+ * 超管关闭直播间
+ */
+ @Override
+ public void onSuperCloseLive() {
+ endLive();
+ DialogUitl.showSimpleTipDialog(mContext, mContext.getString(R.string.live_illegal));
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onLoginInvalidEvent(LoginInvalidEvent e) {
+ release();
+ }
+
+ public void setBtnFunctionDark() {
+ if (mLiveAnchorViewHolder != null) {
+ mLiveAnchorViewHolder.setBtnFunctionDark();
+ }
+ }
+
+ /**
+ * 主播与主播连麦 主播收到其他主播发过来的连麦申请
+ */
+ @Override
+ public void onLinkMicAnchorApply(UserBean u, String stream) {
+ if (mLiveLinkMicAnchorPresenter != null) {
+ mLiveLinkMicAnchorPresenter.onLinkMicAnchorApply(u, stream);
+ }
+ }
+
+ /**
+ * 主播与主播连麦 对方主播拒绝连麦的回调
+ */
+ @Override
+ public void onLinkMicAnchorRefuse() {
+ if (mLiveLinkMicAnchorPresenter != null) {
+ mLiveLinkMicAnchorPresenter.onLinkMicAnchorRefuse();
+ }
+ }
+
+ /**
+ * 主播与主播连麦 对方主播无响应的回调
+ */
+ @Override
+ public void onLinkMicAnchorNotResponse() {
+ if (mLiveLinkMicAnchorPresenter != null) {
+ mLiveLinkMicAnchorPresenter.onLinkMicNotResponse();
+ }
+ }
+
+ /**
+ * 主播与主播连麦 对方主播正在游戏
+ */
+ @Override
+ public void onlinkMicPlayGaming() {
+ if (mLiveLinkMicAnchorPresenter != null) {
+ mLiveLinkMicAnchorPresenter.onlinkMicPlayGaming();
+ }
+ }
+
+
+ /**
+ * 主播与主播连麦 对方主播正在忙的回调
+ */
+ @Override
+ public void onLinkMicAnchorBusy() {
+ if (mLiveLinkMicAnchorPresenter != null) {
+ mLiveLinkMicAnchorPresenter.onLinkMicAnchorBusy();
+ }
+ }
+
+ /**
+ * 发起主播连麦PK申请
+ *
+ * @param pkUid 对方主播的uid
+ * @param stream 对方主播的stream
+ */
+ public void linkMicAnchorApply(String pkUid, String stream) {
+ JSONObject msg1 = buildLinkMicJSON();
+ linkMicAnchorApply(pkUid, stream, false);
+ }
+
+ public JSONObject buildLinkMicJSON() {
+ JSONObject msg1 = new JSONObject();
+ msg1.put("uid", CommonAppConfig.getInstance().getUid());
+ msg1.put("pkuid", CommonAppConfig.getInstance().getUid());
+ msg1.put("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
+ msg1.put("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar());
+ return msg1;
+ }
+
+ public void linkMicAnchorApply(final String pkUid, String stream, boolean extra) {
+
+ LiveHttpUtil.livePkCheckLive(pkUid, stream, mStream, 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")) {
+ final SocketSendBean msg1 = new SocketSendBean()
+ .param("_method_", SOCKET_LINK_MIC_PK)
+ .param("action", 1)
+ .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
+ .param("pkuid", pkUid)
+ .param("uid", CommonAppConfig.getInstance().getUid())
+ .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
+ .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
+ .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
+ //判断是否是随机PK
+ if(extra){
+ msg1.param("random_pk", "1");
+ msg1.param("msgtype","11");
+ if (RandomPkManager.getInstance().isRankModel()) {
+ msg1.param("is_ladders", "https://downs.yaoulive.com/rank_top_box.png");
+ }
+ }
+ msg1.create();
+
+ 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("g" + pkUid, 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("tx", "发送成功");
+ }
+
+ @Override
+ public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
+ Log.e("tx", "发送失败" + errorCode.getMessage());
+
+ }
+ });
+ } else {
+ ToastUtil.show(mContext.getString(R.string.pking_over));
+ if (RandomPkManager.getInstance().isRandomModel()) {
+ RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
+ }
+ }
+ }
+ }
+ }
+ });
+
+
+ }
+
+ /**
+ * 发起多人主播连麦PK申请
+ *
+ * @param pkUid 对方主播的uid
+ * @param stream 对方主播的stream (无需steam)
+ */
+ public void linkDrMicAnchorApply(String pkUid, String stream) {
+ linkDrMicAnchorApply(pkUid, stream, SOCKET_LIVE_DRPK);
+ if (mLiveAnchorViewHolder != null) {
+ mLiveAnchorViewHolder.setYaoqing(pkUid);
+ }
+ }
+
+ public void linkDrMicRemoveListUid(String uid){
+ if (mLiveAnchorViewHolder != null) {
+ mLiveAnchorViewHolder.removeYaoqing(uid);
+ }
+ }
+
+
+ /**
+ * 发起多人主播连麦PK申请
+ *
+ * @param pkUid 对方主播的uid
+ * @param stream 对方主播的stream (无需steam)
+ * @param extra PK类型
+ */
+ public void linkDrMicAnchorApply(final String pkUid, String stream, String extra) {
+
+ LiveHttpUtil.livePkCheckLive(pkUid, stream, mStream, 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")) {
+
+ // TODO: 2024/4/19 邀请主播进行多人连麦
+ final SocketSendBean msg1 = new SocketSendBean()
+ .param("_method_", SOCKET_LIVE_DRPK)
+ .param("action", 1)
+ .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
+ .param("pkuid", pkUid)
+ .param("uid", CommonAppConfig.getInstance().getUid())
+ .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
+ .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
+ msg1.create();
+
+ String targetId = "g" + pkUid;
+ Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
+ TextMessage messageContent = TextMessage.obtain(msg1.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 (SocketSwClient.mSocketHandler != null) {
+ SocketSwClient.mSocketHandler.processBroadcast(message.toString() + "");
+ }
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+ Log.e("tx", "aaa" + errorCode.toString());
+ //ToastUtil.show(errorCode.code + ":" + errorCode.msg);
+ }
+ });
+ } else {
+ ToastUtil.show(mContext.getString(R.string.pking_over));
+ }
+ }
+ }
+ }
+ });
+
+
+ }
+
+ /**
+ * 设置连麦pk按钮是否可见
+ */
+ public void setPkBtnVisible(boolean visible) {
+ if (mLiveAnchorViewHolder != null) {
+ if (visible) {
+ if (mLiveLinkMicAnchorPresenter.isLinkMic()) {
+ mLiveAnchorViewHolder.setPkBtnVisible(true);
+ }
+ } else {
+ mLiveAnchorViewHolder.setPkBtnVisible(false);
+ }
+ }
+ }
+
+ /**
+ * 发起主播连麦pk
+ */
+ public void applyLinkMicPk() {
+ String pkUid = null;
+ if (mLiveLinkMicAnchorPresenter != null) {
+ pkUid = mLiveLinkMicAnchorPresenter.getPkUid();
+ }
+ if (!TextUtils.isEmpty(pkUid) && mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.applyLinkMicPk(pkUid, mStream);
+ }
+ }
+
+ /**
+ * 主播与主播PK 主播收到对方主播发过来的PK申请的回调
+ *
+ * @param u 对方主播的信息
+ * @param stream 对方主播的stream
+ */
+ @Override
+ public void onLinkMicPkApply(UserBean u, String stream, int forwhat) {
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onLinkMicPkApply(u, stream, 0);
+ }
+ }
+
+ //多人PK接受
+ @Override
+ public void onLinkDRMicPkApply(UserBean u) {
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onLinkDRMicPkApply(u);
+ }
+ }
+
+ @Override
+ public void onLinkDRMicPKToUser(UserBean u) {
+
+ }
+
+ //多人PK接受
+ @Override
+ public void onLinkDRMicPkApplyOk(UserBean u) {
+ L.eSw("onLinkDRMicPkApplyOk111111");
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onLinkDRMicPkApplyOk(u);
+ }
+ }
+
+ /**
+ * 主播与主播PK 对方主播拒绝pk的回调
+ */
+ @Override
+ public void onLinkMicPkRefuse() {
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onLinkMicPkRefuse();
+ }
+ }
+
+ /**
+ * 主播与主播PK 对方主播正在忙的回调
+ */
+ @Override
+ public void onLinkMicPkBusy() {
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onLinkMicPkBusy();
+ }
+ }
+
+ /**
+ * 主播与主播PK 对方主播无响应的回调
+ */
+ @Override
+ public void onLinkMicPkNotResponse() {
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onLinkMicPkNotResponse();
+ }
+ }
+
+ @Override
+ public void onLinkMicToPk(String uid, String pkhead, String pkname) {
+
+ }
+
+ @Override
+ public void prankTurntable(String msgtype, int time, JSONObject jsonObject) {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.closeAndOpenTrickery(msgtype, time, jsonObject);
+ }
+ }
+
+
+ /**
+ * 腾讯sdk连麦时候主播混流
+ */
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onLinkMicTxMixStreamEvent(LinkMicTxMixStreamEvent e) {
+
+ }
+
+ /**
+ * 主播checkLive
+ */
+ public void checkLive() {
+ if (mCheckLiveCallback == null) {
+ mCheckLiveCallback = new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0 && info.length > 0) {
+ int status = JSON.parseObject(info[0]).getIntValue("status");
+ printLog(DateFormatUtil.getCurTimeString2() + " <=== " + mReqCount + "----status=" + status + "\n");
+ if (status == 0) {
+ NotCancelableDialog dialog = new NotCancelableDialog();
+ dialog.setContent(mContext.getString(R.string.live_anchor_error));
+ dialog.setActionListener(new NotCancelableDialog.ActionListener() {
+ @Override
+ public void onConfirmClick(Context context, DialogFragment dialog) {
+ dialog.dismiss();
+ release();
+ superBackPressed();
+ }
+ });
+ dialog.show(getSupportFragmentManager(), "VersionUpdateDialog");
+ }
+ }
+ }
+ };
+ }
+ mReqCount++;
+ printLog(DateFormatUtil.getCurTimeString2() + " ===> " + mReqCount + "\n");
+ LiveHttpUtil.anchorCheckLive(mLiveUid, mStream, mCheckLiveCallback);
+ }
+
+ @Override
+ public void onSendGift(LiveReceiveGiftBean bean, SendBlindGiftEvent event) {
+ if (event != null) {
+ LiveChatBean liveChatBean = null;
+ if (!TextUtils.isEmpty(event.isBlindBoxStatus()) && TextUtils.equals(event.isBlindBoxStatus(), "true")) {
+ if (!TextUtils.isEmpty(event.getDressName()) && !TextUtils.isEmpty(event.getDressMsg())) {
+ liveChatBean = new LiveChatBean();
+ liveChatBean.setUserNiceName(event.getUserNiceName());
+ liveChatBean.setType(LiveChatBean.BLIND_BOX);
+ liveChatBean.setGiftName(event.getDressName());
+ liveChatBean.setContent(event.getDressMsg());
+ }
+ //插入盲盒礼物消息
+ bean.getLiveChatBean().setType(LiveChatBean.BLIND_BOX);
+ bean.getLiveChatBean().setContent(WordUtil.isNewZh() ? event.getGiftMsg() : event.getGiftMsgen());
+ bean.getLiveChatBean().setGiftName(WordUtil.isNewZh() ? event.getGiftname() : event.getGiftname_en());
+ bean.getLiveChatBean().setUserNiceName(event.getUserNiceName());
+ }
+
+
+ if (mLiveRoomViewHolder != null) {
+ if (bean.getmLiveUId().equals(bean.getRoomnum())) {
+ if (liveChatBean != null) {
+ mLiveRoomViewHolder.insertChat(liveChatBean, 1);
+ }
+ mLiveRoomViewHolder.insertChat(bean.getLiveChatBean(), 1);
+ }
+ mLiveRoomViewHolder.showGiftMessage(bean, false);
+ mLiveRoomViewHolder.updataWishList(bean.getGiftId(), bean.getGiftCount());
+ }
+ } else {
+ //购买守护
+ if (bean.ismTypeBuyGuard()) {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.showGuardGifMessage(bean);
+ }
+ } else {
+
+ if (mLiveRoomViewHolder != null) {
+ if (bean.getmLiveUId().equals(bean.getRoomnum())) {
+ mLiveRoomViewHolder.insertChat(bean.getLiveChatBean(), 1);
+ }
+ mLiveRoomViewHolder.showGiftMessage(bean, false);
+ mLiveRoomViewHolder.updataWishList(bean.getGiftId(), bean.getGiftCount());
+ }
+
+ }
+ }
+
+ }
+
+ private void printLog(String content) {
+ if (mLogFile == null) {
+ File dir = new File(CommonAppConfig.LOG_PATH);
+ if (!dir.exists()) {
+ dir.mkdirs();
+ }
+ mLogFile = new File(dir, DateFormatUtil.getCurTimeString2() + "_" + mLiveUid + "_" + mStream + ".txt");
+ }
+ L.e(TAG, content);
+ LogUtil.print(mLogFile, content);
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onOpenDrawer(LiveAudienceEvent event) {
+ Bundle bundle = new Bundle();
+ IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
+ switch (event.getType()) {
+ case LIVE_WKS:
+ String weeklyStarUrl = CommonAppConfig.HOST + "/h5/activity/weekStar/index.html?&uid="
+ + userInfo.getId() +
+ "&token=" + userInfo.getToken() + "&anchorUid=" + mLiveUid;
+ ZhuangBanActivity.forward(mContext, weeklyStarUrl, false, 0);
+ break;
+ case WISH_LIST:
+ LiveWishListDialogFragment4Audience fragment4Audience = new LiveWishListDialogFragment4Audience();
+ bundle.putString(Constants.LIVE_UID, mLiveUid);
+ fragment4Audience.setArguments(bundle);
+ if (mContext instanceof LiveSwAnchorActivity) {
+ fragment4Audience.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveWishListDialogFragment4Audience");
+ }
+ break;
+ case UN_LEAVELIVE:
+ if (leave == 1) {
+ leaveLive();
+ }
+ break;
+ case LINK_MIC:
+ if (!StringUtil.isEmpty(((LinkMicUserBean) event.getObject()).getId())) {
+ mMicQueueList.put(((LinkMicUserBean) event.getObject()).getId(), (LinkMicUserBean) event.getObject());
+ }
+ if (micListener != null) {
+ micListener.updateMicList(mMicQueueList);
+ DialogUitl.showSimpleDialog(mContext,
+ String.format(mContext.getString(R.string.live_mic_user_apply), ((LinkMicUserBean) event.getObject()).getUserNicename()),
+ new DialogUitl.SimpleCallback() {
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ openMicWindow(2);
+ dialog.dismiss();
+ }
+ }
+ );
+ }
+ break;
+ case LINK_MIC_CANCEL:
+ mMicQueueList.remove(((LinkMicUserBean) event.getObject()).getId());
+ if (micListener != null) {
+ micListener.updateMicList(mMicQueueList);
+ }
+ break;
+ case LINK_MIC_UPDATE_MIC_LIST:
+ List list = (List) event.getObject();
+ mMicQueueList.clear();
+ for (LinkMicUserBean bean : list) {
+ if (!StringUtil.isEmpty(bean.getId())) {
+ mMicQueueList.put(bean.getId(), bean);
+ }
+ }
+ if (micListener != null) {
+ micListener.updateMicList(mMicQueueList);
+ }
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.updataMicList(list);
+ Log.i("多人连麦", "onOpenDrawer: " + list.size());
+ for (LinkMicUserBean userBean : list) {
+ Log.i("多人连麦", "u list: " + userBean.toString());
+ }
+ }
+ break;
+ case LINK_MIC_UPDATE_AUDIENCE_LIST:
+ mAudienceList = (List) event.getObject();
+ if (micListener != null) {
+ micListener.updateAudienceList(mAudienceList);
+ }
+ break;
+ case LINK_MIC_CLOSE:
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.updataCleanMic();
+ }
+ break;
+ case LEAVE_DR_ROOM:
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.seisShowGif(true);
+ if(DRPKing==1){
+ mLiveRoomViewHolder.endDRGif();
+ }
+ }
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.leaveDRRoom();
+ }
+ SWManager.get().setDrPkNumClarity(1);
+// if (mLiveRoomViewHolder != null) {
+// mLiveRoomViewHolder.hotAddVisibility(false);
+// }
+ break;
+ case LEAVE_PK_SCORE:
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.closeButtonGone();
+ mLiveSwLinkMicPkPresenter.upDataPkScore(event.getPkScores(), event.getUid(), event.getTime(),true);
+ }
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.seisShowGif(true);
+ }
+// if (mLiveRoomViewHolder != null) {
+// mLiveRoomViewHolder.hotAddVisibility(true);
+// }
+ break;
+ case PK_TIME_COUNT:
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.endDRGif();
+ }
+ break;
+ case DISCONNEXT_PK_TIME:
+ if (mLivePushViewHolder != null) {
+ //mLivePushViewHolder.changeToBig();
+ mLivePushViewHolder.anchorClose();
+ mLiveSwLinkMicPkPresenter.leaveDRRoom();
+ }
+ break;
+ case AI_AUTOMATIC_SPEECH:
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.aiAutomaticSpeech((event.getAiAutomaticSpeechModel()));
+ }
+ break;
+ case UPDATA_ROBOT:
+ getAiRobotStatus();
+ break;
+ //主播强制下播
+ case LIVE_END:
+ endLive();
+ break;
+ case RED_PACKET:
+ if (manager != null) {
+ mLiveRoomViewHolder.redPacketManage(event.getRedPacketModel());
+ }
+ break;
+ case BLIND_BOX:
+ if (mLiveRoomViewHolder != null) {
+ if (event.getAllServerNotifyEvent().isRedPacket())
+ mLiveRoomViewHolder.blindBoxAllServerNotify(event.getAllServerNotifyEvent());
+ }
+ break;
+ case GIFT_WALL:
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.showGiftWall(event.getUid(), event.isVoicePress(), event.getUname(), event.getAvatar());
+ }
+ break;
+ case INPUT_DIALOG:
+ LiveInputDialogFragment liveInputDialogFragment = new LiveInputDialogFragment();
+ Bundle liveInputBundle = new Bundle();
+ liveInputBundle.putString(Constants.LIVE_DANMU_PRICE, mDanmuPrice);
+ liveInputBundle.putString(Constants.COIN_NAME, mCoinName);
+ liveInputBundle.putString(Constants.LIVE_UID, mLiveUid);
+ liveInputBundle.putString(Constants.LIVE_STREAM, mStream);
+ liveInputBundle.putString(Constants.LIVE_UID, mLiveUid);
+ if (event.getOlineUserlistModel() == null) {
+ liveInputBundle.putString("TagUser", "");
+ } else {
+ liveInputBundle.putString("TagUser", GsonUtils.toJson(event.getOlineUserlistModel()));
+ }
+ liveInputDialogFragment.setArguments(liveInputBundle);
+ liveInputDialogFragment.show(getSupportFragmentManager(), "LiveInputDialogFragment");
+ break;
+
+ }
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onSendMoneyLongModel(SendMoneyLongModel sendMoneyLongModel) {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.onSendMoneyLongModel(sendMoneyLongModel);
+ }
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onSendMoneyLongEndEvent(SendMoneyLongEndEvent sendMoneyLongModel) {
+ Log.e("DateRemindModel", sendMoneyLongModel.toString());
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.onSendMoneyLongEndEvent(sendMoneyLongModel);
+ }
+
+
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void GiftWallIlluminateEvent(GiftWallIlluminateEvent event) {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.setGiftWall(String.valueOf(event.getNewNumber()), String.valueOf(event.getMaxNumber()));
+ }
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onShowHideEvent(ShowHideEvent event) {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.onShowHideEvent();
+
+ }
+ }
+
+ /**
+ * 检查指定直播间连麦人数
+ *
+ * @param mLiveUid 直播间
+ */
+ public static void checkMicUserLength(String mLiveUid, LiveFunctionClickListener listener) {
+ LiveHttpUtil.getMicList(mLiveUid, 0, new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0) {
+ try {
+ JSONObject obj = JSON.parseObject(info[0]);
+ List list = JSON.parseArray(obj.getString("userlist"), MicUserBean.class);
+ listener.onClick(list.size());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+ }
+ });
+ }
+
+ /**
+ * 获取机器人配置;取得求关注时间间隔
+ */
+ private long robotTime = 0;
+
+ private void getAiRobotStatus() {
+ Log.e("随机打招呼", "(((((((((((((((((((((((((((((((((((((((((((((((");
+ LiveNetManager.get(mContext)
+ .getAiRobotStatus(new com.yunbao.common.http.base.HttpCallback() {
+ @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>() {
+ @Override
+ public void onSuccess(List 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(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
+ }
+ });
+ }
+
+ //机器人求关注轮询器
+ 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 (SocketSwClient.mSocketHandler != null) {
+ SocketSwClient.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);
+ }
+
+ private LiveSudGamePopup liveSudGamePopupXPopup = null;
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onLiveSudGamePopupShowOrHideEvent(LiveSudGamePopupShowOrHideEvent event) {
+ switch (event.getType()) {
+ case 0:
+ if (liveSudGamePopupXPopup == null) {
+ liveSudGamePopupXPopup = new LiveSudGamePopup(mContext, event.getCreateSudRoomModel());
+ new XPopup.Builder(mContext)
+ .enableDrag(false)
+ .dismissOnTouchOutside(false)
+ .dismissOnBackPressed(false)
+ .asCustom(liveSudGamePopupXPopup).show();
+ } else {
+ if (liveSudGamePopupXPopup != null) {
+ liveSudGamePopupXPopup.dialog.show();
+ }
+ }
+
+
+ break;
+
+ case 1:
+ if (liveSudGamePopupXPopup != null) {
+ liveSudGamePopupXPopup.dialog.hide();
+ }
+
+ break;
+ case 2:
+ if (liveSudGamePopupXPopup != null) {
+ liveSudGamePopupXPopup.BusGetOff();
+ liveSudGamePopupXPopup.dialog.dismiss();
+ liveSudGamePopupXPopup = null;
+ }
+ break;
+ }
+
+
+ }
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onAllServerNotifyFFGGGDJANEvent(AllServerNotifyFFGGGDJANEvent event) {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.showAllServerNotifyFFGGGD(event,false);
+ }
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onNewAllServerNotifyGuardEvent(NewAllServerNotifyGuardEvent event) {
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.buyGuardNew(event);
+ }
+ }
+
+}
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveTRTCAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveTRTCAnchorActivity.java
index 0db3b6e73..6f99feee7 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveTRTCAnchorActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveTRTCAnchorActivity.java
@@ -213,7 +213,7 @@ public class LiveTRTCAnchorActivity extends TRTCBaseActivity {
return;
}
String title = mEditTitle.getText().toString().trim();
- LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, null,0, new HttpCallback() {
+ LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, null,0,false, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, final String[] info) {
if (code == 0 && info.length > 0) {
diff --git a/live/src/main/java/com/yunbao/live/activity/PDLIiveChatActivity.java b/live/src/main/java/com/yunbao/live/activity/PDLIiveChatActivity.java
index 42ce00194..a9f9b3138 100644
--- a/live/src/main/java/com/yunbao/live/activity/PDLIiveChatActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/PDLIiveChatActivity.java
@@ -197,8 +197,8 @@ public class PDLIiveChatActivity extends FragmentActivity {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
}
@Override
diff --git a/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java b/live/src/main/java/com/yunbao/live/activity/SudRyGameActivity.java
similarity index 97%
rename from live/src/main/java/com/yunbao/live/activity/SudGameActivity.java
rename to live/src/main/java/com/yunbao/live/activity/SudRyGameActivity.java
index 5385e5801..719666c70 100644
--- a/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/SudRyGameActivity.java
@@ -19,6 +19,7 @@ import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
+import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.R;
import com.yunbao.common.activity.AbsActivity;
@@ -40,7 +41,7 @@ import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
-import com.yunbao.common.manager.imrongcloud.GameMicManager;
+import com.yunbao.common.manager.imrongcloud.GameRyMicManager;
import com.yunbao.common.sud.QuickStartGameViewModel;
import com.yunbao.common.sud.decorator.SudFSMMGDecorator;
import com.yunbao.common.sud.model.GameConfigModel;
@@ -71,8 +72,8 @@ import cn.rongcloud.rtc.api.RCRTCRoom;
import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
import cn.rongcloud.rtc.base.RTCErrorCode;
-@Route(path = RouteUtil.PATH_SudGameActivity)
-public class SudGameActivity extends AbsActivity implements GameMicManager.MeetingCallback {
+@Route(path = RouteUtil.PATH_SudRyGameActivity)
+public class SudRyGameActivity extends AbsActivity implements GameRyMicManager.MeetingCallback {
private FrameLayout gameContainer;
private long mInteractionID;
private String mLiveUid;
@@ -80,7 +81,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
private CreateSudRoomModel mCreateSudRoomModel;
private TextView roomName, roomNumber;
- private GameMicManager gameMicManager;
+ private GameRyMicManager gameMicManager;
private ImageView gameCloseWheat, gameSeat;
private boolean disable = true, publishDefault = false;
@@ -107,7 +108,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
private List customSidebarChildModels = new ArrayList<>();
private void initDate() {
-
+ CommonAppConfig.getInstance().getConfig().isSw();
LiveNetManager.get(mContext)
.getCustomSidebarInfo("1", new HttpCallback>() {
@Override
@@ -137,9 +138,9 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
.getRoomMicStatus(new HttpCallback() {
@Override
public void onSuccess(RoomMicStatusModel data) {
- gameMicManager = new GameMicManager();
- gameMicManager.attachView(SudGameActivity.this);
- gameMicManager.config(SudGameActivity.this);
+ gameMicManager = new GameRyMicManager();
+ gameMicManager.attachView(SudRyGameActivity.this);
+ gameMicManager.config(SudRyGameActivity.this);
//语音
if (TextUtils.equals(data.getMicStatus(), "1")) {
imOff = true;
@@ -276,7 +277,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
bundle.putString(Constants.STREAM, "");
bundle.putString(Constants.TO_UID, sudGameUserModel.getId() + "");
fragment.setArguments(bundle);
- fragment.show(((SudGameActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
+ fragment.show(((SudRyGameActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
}
});
userList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
diff --git a/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java b/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java
new file mode 100644
index 000000000..d66881c79
--- /dev/null
+++ b/live/src/main/java/com/yunbao/live/activity/SudSwGameActivity.java
@@ -0,0 +1,744 @@
+package com.yunbao.live.activity;
+
+import android.Manifest;
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.Handler;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.lifecycle.Observer;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.lxj.xpopup.XPopup;
+import com.yunbao.common.CommonAppConfig;
+import com.yunbao.common.Constants;
+import com.yunbao.common.R;
+import com.yunbao.common.activity.AbsActivity;
+import com.yunbao.common.adapter.SudGameChatAdapter;
+import com.yunbao.common.adapter.SudGameUserListAdapter;
+import com.yunbao.common.bean.CheckRemainingBalance;
+import com.yunbao.common.bean.CreateSudRoomModel;
+import com.yunbao.common.bean.CustomSidebarChildModel;
+import com.yunbao.common.bean.CustomSidebarInfoModel;
+import com.yunbao.common.bean.HttpCallbackModel;
+import com.yunbao.common.bean.RoomMicStatusModel;
+import com.yunbao.common.bean.SudGameChatImModel;
+import com.yunbao.common.bean.SudGameUserModel;
+import com.yunbao.common.dialog.SudGameInputPopupWindow;
+import com.yunbao.common.event.CheckRemainingBalanceEvent;
+import com.yunbao.common.event.SubGameEvent;
+import com.yunbao.common.event.SudGameSocketImEvent;
+import com.yunbao.common.glide.ImgLoader;
+import com.yunbao.common.http.base.HttpCallback;
+import com.yunbao.common.http.live.LiveNetManager;
+import com.yunbao.common.manager.IMLoginManager;
+import com.yunbao.common.manager.imrongcloud.GameSwMicManager;
+import com.yunbao.common.sud.QuickStartGameViewModel;
+import com.yunbao.common.sud.decorator.SudFSMMGDecorator;
+import com.yunbao.common.sud.model.GameConfigModel;
+import com.yunbao.common.sud.model.GameViewInfoModel;
+import com.yunbao.common.sud.state.SudMGPAPPState;
+import com.yunbao.common.sud.state.SudMGPMGState;
+import com.yunbao.common.utils.Bus;
+import com.yunbao.common.utils.DpUtil;
+import com.yunbao.common.utils.ProcessResultUtil;
+import com.yunbao.common.utils.RouteUtil;
+import com.yunbao.common.utils.ToastUtil;
+import com.yunbao.common.utils.WordUtil;
+import com.yunbao.common.views.LiveSudGameHistoryPopup;
+import com.yunbao.common.views.TopGradual;
+import com.yunbao.common.views.weight.ViewClicksAntiShake;
+import com.yunbao.live.dialog.LiveUserDialogFragment;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import cn.rongcloud.rtc.api.RCRTCEngine;
+import cn.rongcloud.rtc.api.RCRTCRemoteUser;
+import cn.rongcloud.rtc.api.RCRTCRoom;
+import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
+import cn.rongcloud.rtc.base.RTCErrorCode;
+import io.agora.beautyapi.faceunity.agora.SWAuManager;
+import io.rong.imlib.IRongCoreCallback;
+import io.rong.imlib.IRongCoreEnum;
+import io.rong.imlib.chatroom.base.RongChatRoomClient;
+
+@Route(path = RouteUtil.PATH_SudSwGameActivity)
+public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.MeetingCallback {
+ private FrameLayout gameContainer;
+ private long mInteractionID;
+ private String mLiveUid;
+ private final QuickStartGameViewModel gameViewModel = new QuickStartGameViewModel(); // 创建ViewModel
+
+ private CreateSudRoomModel mCreateSudRoomModel;
+ private TextView roomName, roomNumber;
+ private GameSwMicManager gameMicManager;
+ private ImageView gameCloseWheat, gameSeat;
+ private boolean disable = true, publishDefault = false;
+
+ private RecyclerView chatList, userList;
+ private SudGameChatAdapter mLiveChatAdapter;
+ private SudGameUserListAdapter sudGameUserListAdapter;
+ private ProcessResultUtil mProcessResultUtil;
+ private List muteUser = new ArrayList<>();
+ private boolean imOff;
+ private boolean isSw = CommonAppConfig.getInstance().getConfig().isSw();
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.activity_sud_game;
+ }
+
+ @Override
+ protected void main() {
+ Bus.getOn(this);
+ super.main();
+ initView();
+ initDate();
+ }
+
+ private List customSidebarChildModels = new ArrayList<>();
+
+ private void initDate() {
+
+ LiveNetManager.get(mContext).getCustomSidebarInfo("1", new HttpCallback>() {
+ @Override
+ public void onSuccess(List data) {
+ for (CustomSidebarInfoModel datum : data) {
+ if (datum.getType().equals("6")) {
+ customSidebarChildModels = datum.getChild();
+ return;
+ }
+ }
+ }
+
+ @Override
+ public void onError(String error) {
+
+ }
+ });
+
+ // 设置禁用麦克风采集
+ //RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
+ ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
+ gameCloseWheat.setVisibility(View.INVISIBLE);
+
+ mProcessResultUtil = new ProcessResultUtil(this);
+ LiveNetManager.get(mContext).getRoomMicStatus(new HttpCallback() {
+ @Override
+ public void onSuccess(RoomMicStatusModel data) {
+ gameMicManager = new GameSwMicManager();
+ gameMicManager.attachView(SudSwGameActivity.this);
+ gameMicManager.config(SudSwGameActivity.this);
+ //初始化声网引擎
+ SWAuManager.get().initRtcEngineAudio(mContext);
+ //语音
+ if (TextUtils.equals(data.getMicStatus(), "1")) {
+ imOff = true;
+ gameSeat.setVisibility(View.VISIBLE);
+ userList.setVisibility(View.VISIBLE);
+ new Handler().postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if (!mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
+ ToastUtil.show("拒绝权限将无法使用上麦功能");
+ mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
+ @Override
+ public void run() {
+
+ }
+ });
+ }
+ }
+ }, 1500);
+ } else {
+ imOff = false;
+ gameSeat.setVisibility(View.GONE);
+ userList.setVisibility(View.GONE);
+ }
+ if (TextUtils.equals(data.getImStatus(), "1")) {
+ findViewById(R.id.game_review_input).setVisibility(View.VISIBLE);
+ chatList.setVisibility(View.VISIBLE);
+ } else {
+ findViewById(R.id.game_review_input).setVisibility(View.GONE);
+ chatList.setVisibility(View.GONE);
+ }
+ gameMicManager.setmRoomID(mLiveUid);
+ if (isSw) {
+ SWAuManager.get().joinAudioRoom("v" + mLiveUid, CommonAppConfig.SWToken, Integer.parseInt(CommonAppConfig.getInstance().getUid()));
+ onJoinRoomSuccess(null);
+ onJoinSuccess();
+ } else {
+ gameMicManager.joinRoom(mLiveUid, imOff);
+ }
+ }
+
+ @Override
+ public void onError(String error) {
+ imOff = false;
+ //文字
+ findViewById(R.id.game_review_input).setVisibility(View.GONE);
+ chatList.setVisibility(View.GONE);
+ //语音
+ gameCloseWheat.setVisibility(View.GONE);
+ gameSeat.setVisibility(View.GONE);
+ userList.setVisibility(View.GONE);
+ }
+ });
+ }
+
+ private void onJoinSuccess() {
+ RongChatRoomClient.getInstance().joinChatRoom("v" + mLiveUid, -1, new IRongCoreCallback.OperationCallback() {
+ @Override
+ public void onSuccess() {
+ Log.i("tx", "加入成功");
+ gameMicManager.enterRoom();
+ }
+
+ @Override
+ public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
+ Log.i("tx", "加入" + "失败" + coreErrorCode);
+ if (WordUtil.isNewZh()) {
+ ToastUtil.show("網絡不佳無法連接,請重新進入");
+ } else {
+ ToastUtil.show("The network is not connected, please re-enter");
+ }
+ }
+ });
+ }
+
+
+ @Override
+ protected void onDestroy() {
+
+ LiveNetManager.get(mContext).leaveMic(mLiveUid, new HttpCallback() {
+ @Override
+ public void onSuccess(HttpCallbackModel data) {
+
+ }
+
+ @Override
+ public void onError(String error) {
+
+ }
+ });
+ if(isSw){
+ SWAuManager.get().exitChannelAll();
+ }
+ if (gameMicManager != null) {
+ gameMicManager.leaveRoom();
+ gameMicManager.detachView();
+ }
+
+ Bus.getOff(this);
+
+ super.onDestroy();
+ }
+
+ private void initView() {
+
+ String createSudRoomJson = getIntent().getStringExtra("CreateSudRoom");
+ mCreateSudRoomModel = new Gson().fromJson(createSudRoomJson, CreateSudRoomModel.class);
+ mInteractionID = mCreateSudRoomModel.getLongSudGameId();
+ mLiveUid = mCreateSudRoomModel.getSudGameRoomId();
+
+ gameContainer = findViewById(R.id.game_container);
+ roomName = findViewById(R.id.room_name);
+ roomNumber = findViewById(R.id.room_number);
+ gameCloseWheat = findViewById(R.id.game_close_wheat);
+ gameSeat = findViewById(R.id.game_seat);
+ chatList = findViewById(R.id.chat_list);
+ userList = findViewById(R.id.user_list);
+ //聊天栏
+ FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams) chatList.getLayoutParams();
+ params1.topMargin = DpUtil.dp2px(65);
+ chatList.setLayoutParams(params1);
+
+ chatList.setHasFixedSize(true);
+ LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
+ layoutManager.setOrientation(RecyclerView.VERTICAL);
+ layoutManager.setStackFromEnd(true);
+ chatList.setLayoutManager(layoutManager);
+ chatList.addItemDecoration(new TopGradual());
+ chatList.setItemViewCacheSize(10);
+ mLiveChatAdapter = new SudGameChatAdapter(mContext);
+ chatList.setAdapter(mLiveChatAdapter);
+ sudGameUserListAdapter = new SudGameUserListAdapter(new ArrayList<>());
+ ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_seat : R.mipmap.icon_game_seat_en, gameSeat);
+ sudGameUserListAdapter.setSudGameSmallCallBack(new SudGameUserListAdapter.SudGameSmallCallBack() {
+ @Override
+ public void unMute(String userID, int position) {
+ if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) {
+ if (isSw) {
+ //靜音
+ SWAuManager.get().setMicAudio(Integer.parseInt(userID), false);
+ onSubscribeSuccess(userID, false, position);
+ } else {
+ gameMicManager.refreshStreams(userID, false, position);
+ }
+ } else {
+ ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself");
+ }
+ muteUser.remove(userID);
+ }
+
+ @Override
+ public void mute(String userID, int position) {
+ muteUser.add(userID);
+ if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) {
+ if (isSw) {
+ //开启声音
+ SWAuManager.get().setMicAudio(Integer.parseInt(userID), true);
+ onSubscribeSuccess(userID, true, position);
+ } else {
+ gameMicManager.refreshStreams(userID, true, position);
+ }
+ } else {
+ ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself");
+ }
+ }
+
+ @Override
+ public void viewInformation(SudGameUserModel sudGameUserModel) {
+ LiveUserDialogFragment fragment = new LiveUserDialogFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString(Constants.LIVE_UID, "uid");
+ bundle.putString(Constants.STREAM, "");
+ bundle.putString(Constants.TO_UID, sudGameUserModel.getId() + "");
+ fragment.setArguments(bundle);
+ fragment.show(((SudSwGameActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
+ }
+ });
+ userList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
+ userList.setAdapter(sudGameUserListAdapter);
+ if (mCreateSudRoomModel != null) {
+ roomName.setText(mCreateSudRoomModel.getRoomName());
+ roomNumber.setText(mCreateSudRoomModel.getSudGameRoomId());
+ }
+
+ ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.exit), new ViewClicksAntiShake.ViewClicksCallBack() {
+ @Override
+ public void onViewClicks() {
+ gameViewModel.onDestroy();
+ finish();
+ }
+ });
+ ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.sud_history), new ViewClicksAntiShake.ViewClicksCallBack() {
+ @Override
+ public void onViewClicks() {
+
+ new XPopup.Builder(mContext).enableDrag(false).asCustom(new LiveSudGameHistoryPopup(mContext, customSidebarChildModels)).show();
+ }
+ });
+
+ ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_seat), new ViewClicksAntiShake.ViewClicksCallBack() {
+ @Override
+ public void onViewClicks() {
+ if (imOff && gameMicManager != null) {
+ if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
+ if (publishDefault) {
+ disable = true;
+ // 设置禁用麦克风采集
+ if (isSw) {
+ //下麥
+ SWAuManager.get().setMicAn(false);
+ onUnPublishStreamsSuccess();
+ } else {
+ RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
+// ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
+ gameMicManager.unPublishStreams();
+ }
+ } else {
+ if (sudGameUserListAdapter.isMicMax()) {
+ ToastUtil.show(WordUtil.isNewZh() ? "上麥人數最大7人" : "The maximum number of people on the microphone is 7");
+ } else {
+ //上麦
+ if (isSw) {
+ SWAuManager.get().setMicAn(true);
+ onPublishSuccess();
+ } else {
+ gameMicManager.publishDefaultAVStream();
+ }
+ }
+ }
+ } else {
+ mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
+ @Override
+ public void run() {
+
+ }
+ });
+ }
+ }
+ }
+ });
+ ViewClicksAntiShake.clicksAntiShake(gameCloseWheat, new ViewClicksAntiShake.ViewClicksCallBack() {
+ @Override
+ public void onViewClicks() {
+ if (imOff && gameMicManager != null) {
+
+ gameCloseWheat.post(new Runnable() {
+ @Override
+ public void run() {
+ if (disable) {
+ disable = false;
+ // 设置禁用麦克风采集
+ if (isSw) {
+ SWAuManager.get().setMicAn(true);
+ } else {
+ RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
+ }
+ ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat);
+ LiveNetManager.get(mContext).onMic(mLiveUid, new HttpCallback() {
+ @Override
+ public void onSuccess(HttpCallbackModel data) {
+
+ }
+
+ @Override
+ public void onError(String error) {
+
+ }
+ });
+ ToastUtil.show(WordUtil.isNewZh() ? "麥克風已開啟" : "Microphone turned on");
+ } else {
+ disable = true;
+ // 设置禁用麦克风采集
+ if(isSw){
+ SWAuManager.get().setMicAn(false);
+ }else{
+ RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
+ }
+ ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
+ LiveNetManager.get(mContext).offMic(mLiveUid, new HttpCallback() {
+ @Override
+ public void onSuccess(HttpCallbackModel data) {
+
+ }
+
+ @Override
+ public void onError(String error) {
+
+ }
+ });
+ ToastUtil.show(WordUtil.isNewZh() ? "麥克風已關閉" : "Microphone turned off");
+ }
+ }
+ });
+
+
+ }
+
+
+ }
+ });
+ ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_review_input), new ViewClicksAntiShake.ViewClicksCallBack() {
+ @Override
+ public void onViewClicks() {
+ new XPopup.Builder(mContext).enableDrag(false).asCustom(new SudGameInputPopupWindow(mContext, new SudGameInputPopupWindow.SudGameInputCallBack() {
+ @Override
+ public void sendMessage(String textMessage) {
+ gameMicManager.sendMessage(textMessage);
+ }
+ })).show();
+ }
+ });
+
+ gameViewModel.gameViewLiveData.observe(this, new Observer() {
+ @Override
+ public void onChanged(View view) {
+ if (view == null) { // 在关闭游戏时,把游戏View给移除
+ gameContainer.removeAllViews();
+ } else { // 把游戏View添加到容器内
+ gameContainer.addView(view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
+ }
+ }
+ });
+ // 加载游戏,参数定义可查看BaseGameViewModel.switchGame()方法注释
+ // 游戏配置
+ GameConfigModel gameConfigModel = gameViewModel.getGameConfigModel();
+ gameConfigModel.ui.ping.hide = true; // 配置不隐藏ping值
+ gameConfigModel.ui.level.hide = true; // 配置不隐藏ping值
+ gameConfigModel.ui.lobby_game_setting.hide = true; // 配置不隐藏ping值
+
+ gameConfigModel.ui.lobby_players.custom = true;
+ gameConfigModel.ui.join_btn.custom = true;
+ gameConfigModel.ui.game_settle_again_btn.custom = true;
+ gameConfigModel.ui.start_btn.custom = true;
+
+
+ // SudMGP平台64bit游戏ID
+ gameViewModel.switchGame((Activity) mContext, mLiveUid, mInteractionID);
+// gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, -1, true, 1);
+// gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfCaptain(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
+// ViewClicksAntiShake.clicksAntiShake(gameTitle, new ViewClicksAntiShake.ViewClicksCallBack() {
+// @Override
+// public void onViewClicks() {
+//
+// }
+// });
+ // 设置游戏安全操作区域
+ GameViewInfoModel.GameViewRectModel gameViewRectModel = new GameViewInfoModel.GameViewRectModel();
+ gameViewRectModel.left = 0;
+ gameViewRectModel.top = DpUtil.dp2px(155);
+ gameViewRectModel.right = 0;
+ gameViewRectModel.bottom = DpUtil.dp2px(155);
+ gameViewModel.gameViewRectModel = gameViewRectModel;
+
+
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onCheckRemainingBalanceEvent(CheckRemainingBalanceEvent event) {
+ switch (event.getSudMGPMGState()) {
+ case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN:
+ case SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN:
+
+ LiveNetManager.get(mContext).checkRemainingBalance(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() {
+ @Override
+ public void onSuccess(CheckRemainingBalance data) {
+ if (TextUtils.equals(String.valueOf(data.getGoldenBeanRemainingBalance()), "1")) {
+ gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, event.getSeatIndex(), true, 1);
+ } else {
+ if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
+ ToastUtil.show("貨幣数量不足 ");
+ } else {
+ ToastUtil.show("Insufficient number of currency");
+ }
+
+ }
+// ToastUtil.show(data.toString());
+
+ }
+
+ @Override
+ public void onError(String error) {
+ if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
+ ToastUtil.show("貨幣数量不足 ");
+ } else {
+ ToastUtil.show("Insufficient number of currency");
+ }
+
+ }
+ });
+ break;
+ case SudMGPMGState.MG_COMMON_GAME_SETTLE:
+ gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(false, event.getSeatIndex(), true, 1);
+ break;
+ case SudMGPMGState.MG_COMMON_SELF_CLICK_START_BTN:
+ LiveNetManager.get(mContext).gameStartCheckRemainingBalance(mCreateSudRoomModel.getSudGameId(), mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() {
+ @Override
+ public void onSuccess(CheckRemainingBalance data) {
+ if (data.getStatus() == 1) {
+ gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfPlaying(true);
+ } else {
+
+ }
+
+ }
+
+ @Override
+ public void onError(String error) {
+ ToastUtil.show(error);
+ }
+ });
+ break;
+ case SudMGPMGState.MG_COMMON_GAME_STATE:
+ LiveNetManager.get(mContext).deductMoney(mCreateSudRoomModel.getSudGameRoomId());
+ break;
+ }
+ }
+
+ @Override
+ public void onJoinRoomSuccess(RCRTCRoom rcrtcRoom) {
+ LiveNetManager.get(mContext).getRoomMicData(mLiveUid, new HttpCallback>() {
+ @Override
+ public void onSuccess(List data) {
+ gameMicManager.refreshStreams(data);
+ sudGameUserListAdapter.refreshSudGameUserList(data, muteUser);
+ }
+
+ @Override
+ public void onError(String error) {
+ ToastUtil.show(error);
+ }
+ });
+ // 主动订阅远端用户发布的资源
+// gameMicManager.subscribeAVStream();
+ }
+
+ @Override
+ public void onJoinRoomFailed(RTCErrorCode rtcErrorCode) {
+ ToastUtil.show("加入失败 " + rtcErrorCode.toString());
+ }
+
+ @Override
+ public void onPublishSuccess() {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_hang_up : R.mipmap.icon_game_hang_up_en, gameSeat);
+ publishDefault = true;
+ gameCloseWheat.setVisibility(View.VISIBLE);
+ disable = false;
+ // 设置禁用麦克风采集
+ RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
+ ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat);
+ }
+ });
+
+ LiveNetManager.get(mContext).joinMic(mLiveUid, new HttpCallback() {
+ @Override
+ public void onSuccess(HttpCallbackModel data) {
+
+ }
+
+ @Override
+ public void onError(String error) {
+
+ }
+ });
+ }
+
+ @Override
+ public void onPublishFailed() {
+ ToastUtil.show(WordUtil.isNewZh() ? "語音加入失敗" : "Voice joining failed");
+ }
+
+ @Override
+ public void onSubscribeSuccess(List inputStreamList) {
+// ToastUtil.show("订阅成功 ");
+ }
+
+ @Override
+ public void onSubscribeFailed() {
+ ToastUtil.show("订阅失败 ");
+ }
+
+ @Override
+ public void onSubscribeSuccess(String userID, boolean mute, int position) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ if (mute) {
+ ToastUtil.show(WordUtil.isNewZh() ? "已靜音該用戶" : "The user has been muted");
+ } else {
+ ToastUtil.show(WordUtil.isNewZh() ? "已取消該用戶靜音" : "The user has been unmuted");
+ }
+ sudGameUserListAdapter.muteUser(userID, mute, position);
+ }
+ });
+
+ }
+
+ @Override
+ public void onSubscribeFailed(String userID) {
+ ToastUtil.show("订阅失败 ");
+ }
+
+ @Override
+ public void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser) {
+
+ }
+
+ @Override
+ public void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser) {
+
+ }
+
+ @Override
+ public void insertItem(SudGameChatImModel sudGameChatImModel) {
+ mLiveChatAdapter.insertItem(sudGameChatImModel);
+ }
+
+ @Override
+ public void refreshSudGameUserList(List personList) {
+ sudGameUserListAdapter.refreshSudGameUserList(personList, muteUser);
+ }
+
+ @Override
+ public void onUnPublishStreamsSuccess() {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_seat : R.mipmap.icon_game_seat_en, gameSeat);
+ publishDefault = false;
+ gameCloseWheat.setVisibility(View.INVISIBLE);
+ }
+ });
+ LiveNetManager.get(mContext).leaveMic(mLiveUid, new HttpCallback() {
+ @Override
+ public void onSuccess(HttpCallbackModel data) {
+
+ }
+
+ @Override
+ public void onError(String error) {
+
+ }
+ });
+
+ }
+
+ @Override
+ public void onUnPublishStreamsFailed() {
+
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onSudGameSocketImEvent(SudGameSocketImEvent event) {
+ gameMicManager.processingMessage(event);
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onSudGameUserModel(SudGameUserModel model) {
+ if (model.isNullUser()) {
+ if (!publishDefault) {
+ if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
+ if (sudGameUserListAdapter.isMicMax()) {
+ ToastUtil.show(WordUtil.isNewZh() ? "上麥人數最大7人" : "The maximum number of people on the microphone is 7");
+ } else {
+ gameMicManager.publishDefaultAVStream();
+ }
+
+ } else {
+ mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
+ @Override
+ public void run() {
+
+ }
+ });
+ }
+
+ } else {
+ ToastUtil.show(WordUtil.isNewZh() ? "已經是上麥狀態" : "It is already in the wheat state");
+ }
+
+ }
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onSudGameStatus(SubGameEvent event) {
+ if (event.getType() == 0) {
+ Log.i("游戏回调", "onGameStateChange: event :" + event.toString());
+ if (event.getModel().getCode() == 1001 || event.getModel().getCode() == 1002) {
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("result", 0);
+ gameViewModel.sudFSTAPPDecorator.notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_CREATE_ORDER_RESULT, jsonObject.toString());
+ }
+ }
+ }
+}
diff --git a/live/src/main/java/com/yunbao/live/activity/WebViewActivityMedal.java b/live/src/main/java/com/yunbao/live/activity/WebViewActivityMedal.java
index 3a762d003..3d6e6e089 100644
--- a/live/src/main/java/com/yunbao/live/activity/WebViewActivityMedal.java
+++ b/live/src/main/java/com/yunbao/live/activity/WebViewActivityMedal.java
@@ -172,7 +172,7 @@ public class WebViewActivityMedal extends AbsActivity {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (liveBean == null) {
return;
}
@@ -180,7 +180,7 @@ public class WebViewActivityMedal extends AbsActivity {
MicStatusManager.getInstance().showDownMicDialog(mContext);
return;
}
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk),isSw);
finish();
}
diff --git a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java
index c55118a49..1ce6a9acd 100644
--- a/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/ZhuangBanActivity.java
@@ -409,7 +409,7 @@ public class ZhuangBanActivity extends AbsActivity {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (liveBean == null) {
return;
}
@@ -426,7 +426,7 @@ public class ZhuangBanActivity extends AbsActivity {
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)));
finish();
} else {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk),isSw);
}
finish();
}
diff --git a/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java b/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java
index 4340432d0..68d50d2f7 100644
--- a/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java
+++ b/live/src/main/java/com/yunbao/live/adapter/AnchorUserMicInfoAdapter.java
@@ -21,7 +21,7 @@ import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.BaseModel;
-import com.yunbao.common.bean.LevelBean;
+import com.yunbao.common.bean.MsgSwitchFollowlModel;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.dialog.AbsDialogFragment;
@@ -35,9 +35,11 @@ import com.yunbao.common.utils.CommonIconUtil;
import com.yunbao.common.utils.SVGAViewUtils;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
+import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.socket.SocketSendBean;
+import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.utils.LiveTextRender;
import java.net.MalformedURLException;
@@ -119,31 +121,34 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter {
gift_svga = (SVGAImageView) itemView.findViewById(R.id.gift_svga);
mBtn = itemView.findViewById(R.id.mic_btn);
mClose = itemView.findViewById(R.id.mic_exit);
- mBtn.setOnClickListener(v -> {
- if (MicedUserManager.get().getMicUserList().size() < 3) {
- if (v.getTag() != null) {
- UserBean tag = (UserBean) v.getTag();
- if (tag.getTypeMic() == TYPE_MIC_REQUEST) {
- SocketSendBean bean = createSocketSendBean().param("targetId", tag.getId());
- applyMic(tag, 1, bean);
- ToastUtil.show(mContext.getString(R.string.live_mic_invite));
- } else if (tag.getTypeMic() == TYPE_MIC_INVITE) {
- applyMic(tag, 4, createSocketSendBean());
- ToastUtil.show(mContext.getString(R.string.live_mic_request));
- for (int i = 0; i < mList.size(); i++) {
- if (TextUtils.equals(mList.get(i).getId(), tag.getId())) {
- mList.get(i).setRequest(true);
- notifyItemChanged(i);
+ ViewClicksAntiShake.clicksAntiShake(mBtn, new ViewClicksAntiShake.ViewClicksCallBack() {
+ @Override
+ public void onViewClicks() {
+ if (MicedUserManager.get().getMicUserList().size() < 3) {
+ if (mBtn.getTag() != null) {
+ UserBean tag = (UserBean) mBtn.getTag();
+ if (tag.getTypeMic() == TYPE_MIC_REQUEST) {
+ applyMic(tag, 4, createSocketSendBean());
+ ToastUtil.show(mContext.getString(R.string.live_mic_request));
+ for (int i = 0; i < mList.size(); i++) {
+ if (TextUtils.equals(mList.get(i).getId(), tag.getId())) {
+ mList.get(i).setRequest(true);
+ notifyItemChanged(i);
+ }
}
+ } else if (tag.getTypeMic() == TYPE_MIC_INVITE) {
+ SocketSendBean bean = createSocketSendBean().param("targetId", tag.getId());
+ applyMic(tag, 1, bean);
+ ToastUtil.show(mContext.getString(R.string.live_mic_invite));
}
-
}
+ }else {
+ ToastUtil.show(mContext.getString(R.string.live_mic_max));
}
-
- }else {
- ToastUtil.show(mContext.getString(R.string.live_mic_max));
}
});
+
+
mClose.setOnClickListener(v -> {
if (v.getTag() != null) {
API.get().createPDLiveApi(false)
@@ -167,14 +172,14 @@ public class AnchorUserMicInfoAdapter extends RefreshAdapter {
return new SocketSendBean()
.param("_method_", Constants.LIAN_MAI)
.param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
- .param("avatar", CommonAppConfig.getInstance().getUserBean().getAvatar())
+ .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
.param("uid", CommonAppConfig.getInstance().getUid());
}
/**
* 发送IM消息
*
- * @param action 4为同意请求,1为邀请,其余见 {@link com.yunbao.live.socket.SocketRyClient} Constants.LIAN_MAI解析
+ * @param action 4为同意请求,1为邀请,其余见 {@link SocketSwClient} Constants.LIAN_MAI解析
*/
void applyMic(UserBean bean, int action, SocketSendBean msg) {
msg.param("action", action);
diff --git a/live/src/main/java/com/yunbao/live/adapter/FreePkRecyclerAdapter.java b/live/src/main/java/com/yunbao/live/adapter/FreePkRecyclerAdapter.java
index 1cf09e983..03130178a 100644
--- a/live/src/main/java/com/yunbao/live/adapter/FreePkRecyclerAdapter.java
+++ b/live/src/main/java/com/yunbao/live/adapter/FreePkRecyclerAdapter.java
@@ -22,6 +22,7 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import java.util.Arrays;
import java.util.HashMap;
@@ -35,6 +36,7 @@ public class FreePkRecyclerAdapter extends RefreshAdapter {
private static final int ITEM = 2;
private int freePkNum;//PK次数
private int mDrPkNum = -1;//多人PK剩余次数,为-1则认为是单人PK
+ private String liveUid;
public void setFreePkNum(int freePkNum) {
this.freePkNum = freePkNum;
@@ -48,6 +50,10 @@ public class FreePkRecyclerAdapter extends RefreshAdapter {
this.mDrPkNum = mDrPkNum;
}
+ public void setLiveUid(String liveUid) {
+ this.liveUid = liveUid;
+ }
+
@NonNull
@Override
public HeadViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
@@ -126,10 +132,9 @@ public class FreePkRecyclerAdapter extends RefreshAdapter {
}
if (freePkNum == 0 && mDrPkNum == -1) {
ToastUtil.show(mContext.getString(R.string.free_pk_num_null));
- // return;
+ return;
}
-
- LiveHttpUtil.getMicList(LiveRyAnchorActivity.mLiveUid, 0, new com.yunbao.common.http.HttpCallback() {
+ LiveHttpUtil.getMicList(liveUid, 0, new com.yunbao.common.http.HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
System.out.println("code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
@@ -142,9 +147,14 @@ public class FreePkRecyclerAdapter extends RefreshAdapter {
ToastUtil.show("invite " + bean.getUserNiceName() + " successful");
}
mOnItemClickListener.onItemClick(bean, -1);
- ((LiveRyAnchorActivity) mContext).linkMicAnchorApply(bean.getId(), bean.getId(),
- ((LiveRyAnchorActivity) mContext).buildLinkMicJSON().toString()
- );
+ if(mContext instanceof LiveSwAnchorActivity){
+ ((LiveSwAnchorActivity) mContext).linkMicAnchorApply(bean.getId(), bean.getId(),
+ false);
+ }else{
+ ((LiveRyAnchorActivity) mContext).linkMicAnchorApply(bean.getId(), bean.getId(),
+ ((LiveRyAnchorActivity) mContext).buildLinkMicJSON().toString()
+ );
+ }
return;
}
if (mDrPkNum <= 0) {
@@ -157,7 +167,11 @@ public class FreePkRecyclerAdapter extends RefreshAdapter {
}
yaoqing.put(bean.getId(), bean.getId());
if (yaoqing.size() < 5) {
- ((LiveRyAnchorActivity) mContext).linkDrMicAnchorApply(bean.getId(), bean.getId());
+ if(mContext instanceof LiveSwAnchorActivity){
+ ((LiveSwAnchorActivity) mContext).linkDrMicAnchorApply(bean.getId(), bean.getId());
+ }else{
+ ((LiveRyAnchorActivity) mContext).linkDrMicAnchorApply(bean.getId(), bean.getId());
+ }
} else {
ToastUtil.show(WordUtil.isNewZh() ? "多人PK最大參與人數為4人" : "The maximum number of participants in a multiplayer PK is 4 people");
}
@@ -222,13 +236,13 @@ public class FreePkRecyclerAdapter extends RefreshAdapter {
mId.setText(bean.getId());
if (bean.isPk()) {
mStatus.setText("PK中");
- ImgLoader.display(mContext, R.mipmap.ic_random_pk_pk, mPkStatus);
+ ImgLoader.display(mContext, R.mipmap.ic_random_pk_pk_unselect, mPkStatus);
if (!WordUtil.isNewZh()) {
mStatus.setText("PK");
}
} else {
+ ImgLoader.display(mContext, R.mipmap.ic_random_pk_pk, mPkStatus);
mStatus.setText("空闲");
- ImgLoader.display(mContext, R.mipmap.ic_random_pk_pk_unselect, mPkStatus);
if (!WordUtil.isNewZh()) {
mStatus.setText("free");
}
diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
index 9d515497e..bac417ed9 100644
--- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
+++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java
@@ -210,7 +210,8 @@ public class LiveChatAdapter extends RecyclerView.Adapter {
class Vh extends RecyclerView.ViewHolder {
LinearLayout mBg, view_follow, view_action_game, view_zg, xydComplete;
- TextView mTextView, tv_chat_active_into, tv_chat_avtive_name, tv_zg_anchorname, textTxt2, automatic_chat;
+ TextView tv_chat_active_into, tv_chat_avtive_name, tv_zg_anchorname, textTxt2, automatic_chat;
+ TextView mTextView;
RoundedImageView avatar;
View v_chat_active_close;
RecyclerView rv_chat_active;
diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveFunctionAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveFunctionAdapter.java
index 338c84bb9..167dd8a0f 100644
--- a/live/src/main/java/com/yunbao/live/adapter/LiveFunctionAdapter.java
+++ b/live/src/main/java/com/yunbao/live/adapter/LiveFunctionAdapter.java
@@ -13,7 +13,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.Constants;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.live.R;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.bean.LiveFunctionBean;
import java.util.ArrayList;
@@ -38,11 +38,10 @@ public class LiveFunctionAdapter extends RecyclerView.Adapter 0 && pg == 1) {
+ for (int i = 0; i mLiveRoomHandler.postDelayed(() -> ((LiveRyAnchorActivity) (mContext)).mLiveRoomViewHolder.initAnchorSayData(), 1000)).showDialog();
+ new LiveAnchorSayPopDialog(mContext).setLiveUid(liveUid).setOnItemClickListener(new OnItemClickListener() {
+ @Override
+ public void onItemClick(LiveAnchorSayModel bean, int position) {
+ mLiveRoomHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ if (mContext instanceof LiveSwAnchorActivity) {
+ ((LiveSwAnchorActivity) (mContext)).mLiveRoomViewHolder.initAnchorSayData();
+ } else {
+ ((LiveRyAnchorActivity) (mContext)).mLiveRoomViewHolder.initAnchorSayData();
+ }
+ }
+ }, 1000);
+ }
+ }).showDialog();
} else if (id == R.id.live_tool_qa) {
new LiveAnchorCreateQADialog(mContext).setLiveUid(liveUid).showDialog();
} else if (id == R.id.live_tool_game) {
- LiveNetManager.get(mContext)
- .getCustomSidebarInfo("1", new HttpCallback>() {
- @Override
- public void onSuccess(List data) {
- for (CustomSidebarInfoModel datum : data) {
- if (datum.getType().equals("6")) {
- new XPopup.Builder(mContext)
- .enableDrag(false)
- .moveUpToKeyboard(false)
+ LiveNetManager.get(mContext).getCustomSidebarInfo("1", new HttpCallback>() {
+ @Override
+ public void onSuccess(List data) {
+ for (CustomSidebarInfoModel datum : data) {
+ if (datum.getType().equals("6")) {
+ //直播间来的
+ new XPopup.Builder(mContext).enableDrag(false).moveUpToKeyboard(false)
// .dismissOnTouchOutside(false)
// .dismissOnBackPressed(false)
- .asCustom(new SudGameListPopup(mContext, 0, datum.getChild(), liveUid))
+ .asCustom(new SudGameListPopup(mContext, 0, datum.getChild(), liveUid))
- .show();
- return;
- }
- }
+ .show();
+ return;
}
+ }
+ }
- @Override
- public void onError(String error) {
+ @Override
+ public void onError(String error) {
- }
- });
+ }
+ });
dismiss();
}
}
diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java
index af918e29c..915b38355 100644
--- a/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java
+++ b/live/src/main/java/com/yunbao/live/dialog/LiveNewGuardBuyDialogFragment.java
@@ -42,7 +42,7 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.adapter.GuardRightAdapter;
import com.yunbao.live.adapter.LiveNewGuardBuyItemsAdapter;
import com.yunbao.live.bean.GuardBuyBean;
@@ -305,7 +305,7 @@ public class LiveNewGuardBuyDialogFragment extends AbsDialogFragment implements
private void gotoBack() {
dismiss();
- ((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveRyAnchorActivity);
+ ((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveSwAnchorActivity);
}
/**
diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveNewWishListDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveNewWishListDialogFragment.java
index b1a7905d0..6f56ecd5b 100644
--- a/live/src/main/java/com/yunbao/live/dialog/LiveNewWishListDialogFragment.java
+++ b/live/src/main/java/com/yunbao/live/dialog/LiveNewWishListDialogFragment.java
@@ -25,7 +25,7 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAnchorActivity;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.adapter.LiveNewWishListAdapter;
import com.yunbao.live.bean.LiveWishlistBean;
import com.yunbao.live.event.LiveAudienceEvent;
@@ -119,7 +119,7 @@ public class LiveNewWishListDialogFragment extends AbsDialogFragment implements
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
- ToastUtil.show(WordUtil.isNewZh()?"修改成功":"Success");
+ ToastUtil.show(WordUtil.isNewZh() ? "修改成功" : "Success");
dismiss();
} else {
ToastUtil.show("修改失败" + (msg.isEmpty() ? "" : msg));
@@ -178,17 +178,16 @@ public class LiveNewWishListDialogFragment extends AbsDialogFragment implements
}
-
/**
* 心愿单打开礼物窗口
*/
public void openGiftWindow() {
LiveGiftDialogFragment4Wishlist fragment = new LiveGiftDialogFragment4Wishlist();
- Log.e("ry",getTag());
- if(getTag().equals("TX")) {
+ Log.e("ry", getTag());
+ if (mContext instanceof LiveSwAnchorActivity) {
+ fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
+ } else {
fragment.show(((LiveAnchorActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
- }else{
- fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
}
}
diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveOldUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveOldUserDialogFragment.java
index 21f31a484..a6e869833 100644
--- a/live/src/main/java/com/yunbao/live/dialog/LiveOldUserDialogFragment.java
+++ b/live/src/main/java/com/yunbao/live/dialog/LiveOldUserDialogFragment.java
@@ -47,6 +47,8 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveReportActivity;
+import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.bean.ImpressBean;
import com.yunbao.live.custom.MyTextView;
import com.yunbao.live.utils.LiveTextRender;
@@ -145,7 +147,7 @@ public class LiveOldUserDialogFragment extends AbsDialogFragment implements View
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (liveBean == null) {
return;
}
@@ -551,8 +553,7 @@ public class LiveOldUserDialogFragment extends AbsDialogFragment implements View
mFollowImage.setImageDrawable(mFollowing ? mFollowDrawable : mUnFollowDrawable);
}
if (isAttention == 1 && mLiveUid.equals(mToUid)) {//关注了主播
- ((LiveActivity) mContext).sendSystemMessage(
- CommonAppConfig.getInstance().getUserBean().getUserNiceName() + mContext.getString(R.string.live_follow_anchor));
+ ((LiveActivity) mContext).sendSystemMessage(CommonAppConfig.getInstance().getUserBean().getUserNiceName() + mContext.getString(R.string.live_follow_anchor));
}
}
};
diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java
index 4ef057898..da6d5452b 100644
--- a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java
+++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java
@@ -52,7 +52,7 @@ import com.yunbao.common.views.weight.ViewClicksAntiShake;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveReportActivity;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.live.utils.LiveTextRender;
@@ -663,7 +663,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (liveBean == null) {
return;
}
@@ -722,7 +722,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
} else if (i == R.id.btn_guard) {
if (TextUtils.equals(mLiveUid, "uid")) return;
MobclickAgent.onEvent(mContext, "anchor_avatar_guard", "守护按钮");
- ((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveRyAnchorActivity, mToUid);
+ ((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveSwAnchorActivity, mToUid);
} else if (i == R.id.btn_live) {
gotoLive(mToUid);
} else if (i == R.id.noble_icon_layout) {
diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java
index 5f68adfbb..cc589f42e 100644
--- a/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java
+++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserMoreDialogFragment.java
@@ -36,7 +36,7 @@ import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.adapter.UserMoreInfoAdapter;
import com.yunbao.live.bean.LiveGuardInfo;
import com.yunbao.common.http.LiveHttpUtil;
@@ -144,7 +144,7 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie
((LiveActivity) mContext).openLuckGiftTip();
} else if (Tips.equals("2")) {
dismiss();
- ((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveRyAnchorActivity);
+ ((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveSwAnchorActivity);
} else if (Tips.equals("3")) {
dismiss();
((LiveActivity) mContext).openFansWindow();
diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveWishListDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveWishListDialogFragment.java
index 12eb62dd7..616fdd1f0 100644
--- a/live/src/main/java/com/yunbao/live/dialog/LiveWishListDialogFragment.java
+++ b/live/src/main/java/com/yunbao/live/dialog/LiveWishListDialogFragment.java
@@ -22,6 +22,7 @@ import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.adapter.LiveWishListAdapter;
import com.yunbao.live.bean.LiveWishlistBean;
import com.yunbao.common.http.LiveHttpConsts;
@@ -192,8 +193,8 @@ public class LiveWishListDialogFragment extends AbsDialogFragment implements OnI
public void openGiftWindow() {
LiveGiftDialogFragment4Wishlist fragment = new LiveGiftDialogFragment4Wishlist();
Log.e("ry",getTag());
- if(getTag().equals("TX")) {
- fragment.show(((LiveAnchorActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
+ if(mContext instanceof LiveSwAnchorActivity){
+ fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
}else{
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveGiftDialogFragment");
}
diff --git a/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java b/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java
index ec66eb0e9..c6e6e578c 100644
--- a/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java
+++ b/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java
@@ -146,8 +146,8 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
liveBean.setParams(new HashMap<>());
new LiveRoomCheckLivePresenter(view.getContext(), liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal), isSw);
}
@Override
@@ -168,7 +168,7 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
}
}
tv.setVisibility(View.VISIBLE);
- ImgLoader.displayAvatarCircleCrop(holder.getContext(), IMLoginManager.get(holder.getContext()).getUserInfo().getAvatar(),holder.getView(R.id.rc_right_portrait));
+ ImgLoader.displayAvatarCircleCrop(holder.getContext(), IMLoginManager.get(holder.getContext()).getUserInfo().getAvatar(), holder.getView(R.id.rc_right_portrait));
/* if (messageDirection == Message.MessageDirection.RECEIVE) {
holder.setText(R.id.left_time, DateFormatUtil.formatDate(new Date(mDataList.get(position).getSentTime()), "MM-dd hh:mm:ss"));
holder.getView(R.id.left_time).setVisibility(View.VISIBLE);
diff --git a/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java
index f5c7f0666..5112dd593 100644
--- a/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java
+++ b/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java
@@ -23,6 +23,7 @@ import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.common.manager.RandomPkManager;
import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.common.http.LiveHttpUtil;
import java.util.Arrays;
@@ -36,6 +37,7 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On
private TextView mPkBtnTitle;
private TextView mPkBtnDesc;
private ImageView mRandomPkSwitch;
+ private boolean isSw ;
private final RandomPkManager.OnRandomPkTimer randomPkTimer = new RandomPkManager.OnRandomPkTimer() {
@@ -124,6 +126,7 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
+ isSw = getArguments().getBoolean("isSw");
initView();
initData();
RandomPkManager.debugUid = null;
@@ -260,14 +263,13 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On
} else {
ToastUtil.show("The random PK switch is not enabled");
}
-
return;
}
if ((mPkBtn.getTag() != null && (boolean) mPkBtn.getTag()) || RandomPkManager.getInstance().isRequestPk()) {
RandomPkManager.getInstance().exitPk();
return;
}
- LiveHttpUtil.getMicList(LiveRyAnchorActivity.mLiveUid, 0, new HttpCallback() {
+ LiveHttpUtil.getMicList(isSw?LiveSwAnchorActivity.mLiveUid: LiveRyAnchorActivity.mLiveUid, 0, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
System.out.println("code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
index 4a8c493d2..470923b0f 100644
--- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
+++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java
@@ -490,7 +490,8 @@ public class LiveAudienceEvent extends BaseModel {
SUD_GAME_CREATE_ROOM(75, "主播创建sud游戏"),
PK_RANK_START(76, "PK排位赛开始"),
GuardSpecialEffect(77, "PK排位赛开始"),
- LIVE_DIALOG_ANCHOR_TIPS(78, "主播公会赛tips");
+ LIVE_DIALOG_ANCHOR_TIPS(78, "主播公会赛tips"),
+ LIVE_REMOVE_LIVEUID(79, "主播退出多人PK");
private int type;
private String name;
diff --git a/live/src/main/java/com/yunbao/live/event/LiveOpenSuccessEvent.java b/live/src/main/java/com/yunbao/live/event/LiveOpenSuccessEvent.java
new file mode 100644
index 000000000..5d558a064
--- /dev/null
+++ b/live/src/main/java/com/yunbao/live/event/LiveOpenSuccessEvent.java
@@ -0,0 +1,9 @@
+package com.yunbao.live.event;
+
+/**
+ * Created by cxf on 2019/3/25.
+ */
+
+public class LiveOpenSuccessEvent {
+
+}
diff --git a/live/src/main/java/com/yunbao/live/event/LivePKRightUserInfoEvent.java b/live/src/main/java/com/yunbao/live/event/LivePKRightUserInfoEvent.java
new file mode 100644
index 000000000..152c895e5
--- /dev/null
+++ b/live/src/main/java/com/yunbao/live/event/LivePKRightUserInfoEvent.java
@@ -0,0 +1,44 @@
+package com.yunbao.live.event;
+
+/**
+ * Created by cxf on 2019/3/25.
+ */
+
+public class LivePKRightUserInfoEvent {
+ String uid;
+ String uHead;
+ String uName;
+
+ public LivePKRightUserInfoEvent() {
+ }
+
+ public LivePKRightUserInfoEvent(String uid, String uHead, String uName) {
+ this.uid = uid;
+ this.uHead = uHead;
+ this.uName = uName;
+ }
+
+ public String getUid() {
+ return uid;
+ }
+
+ public void setUid(String uid) {
+ this.uid = uid;
+ }
+
+ public String getuHead() {
+ return uHead;
+ }
+
+ public void setuHead(String uHead) {
+ this.uHead = uHead;
+ }
+
+ public String getuName() {
+ return uName;
+ }
+
+ public void setuName(String uName) {
+ this.uName = uName;
+ }
+}
diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java
index 7491d1629..e6e545fc4 100644
--- a/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java
+++ b/live/src/main/java/com/yunbao/live/presenter/LiveGiftAnimPresenter.java
@@ -386,7 +386,11 @@ public class LiveGiftAnimPresenter {
if (mIvLook.getTag()!=null&&mIvLook.getTag()instanceof LiveReceiveGiftBean){
changeLiveRoom((LiveReceiveGiftBean) mIvLook.getTag());
}else {
- changeLiveRoom();
+ if (mIvLook.getTag() != null && mIvLook.getTag() instanceof LiveReceiveGiftBean) {
+ changeLiveRoom((LiveReceiveGiftBean) mIvLook.getTag());
+ } else {
+ changeLiveRoom();
+ }
}
}
@@ -459,7 +463,7 @@ public class LiveGiftAnimPresenter {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) {
if (liveBean == null) {
return;
}
@@ -503,7 +507,7 @@ public class LiveGiftAnimPresenter {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (liveBean == null) {
return;
}
@@ -657,6 +661,16 @@ public class LiveGiftAnimPresenter {
});
}
+
+ /**
+ * 釋放全局通知
+ */
+ public void releaseServiceNotice() {
+ L.eSw("releaseServiceNotice 釋放全局通知");
+ mHandler.sendEmptyMessageDelayed(full_service_notice_new_1, 100);
+ full_service_notice_new.setVisibility(View.GONE);
+ }
+
private void setGitTipAnimatorBuyZuoji() {
mDp500 = DpUtil.dp2px(500);
mGifGiftTipShowAnimatorBuyZuoji = ObjectAnimator.ofFloat(mGifGiftTipGroupBuyZuoji, "translationX", mDp500, 0);
@@ -1003,8 +1017,7 @@ public class LiveGiftAnimPresenter {
}
}
} else {
- if ((bean.getGifUrl().contains("svga") || bean.getGifUrl().contains("gif")) &&
- IMLoginManager.get(mContext).isGiftEffect()) {
+ if ((bean.getGifUrl().contains("svga") || bean.getGifUrl().contains("gif")) && IMLoginManager.get(mContext).isGiftEffect()) {
//同一直播间,玩家自己送礼物,也能看到全服通知
//同一直播间,其他玩家也能看到全服通知
@@ -1159,6 +1172,7 @@ public class LiveGiftAnimPresenter {
mRoomNum = event.getLiveuid();
if (mShowAllServer) {
+ L.eSw("mGifAll != null");
if (mGifAll != null) {
LiveReceiveGiftBean bean = new LiveReceiveGiftBean();
bean.setSendtype(91);
@@ -1167,6 +1181,7 @@ public class LiveGiftAnimPresenter {
mGifAll.offer(bean);
}
} else {
+ L.eSw("mGifAll != nullnullnullnullnullnull");
notifyFFGGGDJANEvent = event;
mShowAllServer = true;
index4Guard = getFirstIndexOfValue(heightOffsetArr, 0);
@@ -1264,23 +1279,17 @@ public class LiveGiftAnimPresenter {
mGifGiftTipGroupBuyGuardNew.setVisibility(View.VISIBLE);
switch (event.getGuardType()) {
case "1":
- guardAllServerNotifyBg.setBackgroundResource(WordUtil.isNewZh() ?
- R.mipmap.background_all_server_notify_star_zh :
- R.mipmap.background_all_server_notify_star_en);
+ guardAllServerNotifyBg.setBackgroundResource(WordUtil.isNewZh() ? R.mipmap.background_all_server_notify_star_zh : R.mipmap.background_all_server_notify_star_en);
mGifGiftTipBuyGuardNew.setTextColor(Color.parseColor("#072A93"));
mIvLookBuyGuardNew.setBackgroundResource(R.mipmap.btn_star_guard_onlookers);
break;
case "2":
- guardAllServerNotifyBg.setBackgroundResource(WordUtil.isNewZh() ?
- R.mipmap.background_all_server_notify_king_zh :
- R.mipmap.background_all_server_notify_king_en);
+ guardAllServerNotifyBg.setBackgroundResource(WordUtil.isNewZh() ? R.mipmap.background_all_server_notify_king_zh : R.mipmap.background_all_server_notify_king_en);
mGifGiftTipBuyGuardNew.setTextColor(Color.parseColor("#BF0B0A"));
mIvLookBuyGuardNew.setBackgroundResource(R.mipmap.btn_king_guard_onlookers);
break;
case "3":
- guardAllServerNotifyBg.setBackgroundResource(WordUtil.isNewZh() ?
- R.mipmap.background_all_server_notify_god_zh :
- R.mipmap.background_all_server_notify_sgod_en);
+ guardAllServerNotifyBg.setBackgroundResource(WordUtil.isNewZh() ? R.mipmap.background_all_server_notify_god_zh : R.mipmap.background_all_server_notify_sgod_en);
mGifGiftTipBuyGuardNew.setTextColor(Color.parseColor("#41057E"));
mIvLookBuyGuardNew.setBackgroundResource(R.mipmap.btn_god_guard_onlookers);
break;
@@ -1333,13 +1342,7 @@ public class LiveGiftAnimPresenter {
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
if (!TextUtils.isEmpty(notifyFFGGGDJANEvent.getLink())) {
StringBuffer htmlUrl = new StringBuffer();
- htmlUrl.append(notifyFFGGGDJANEvent.getLink())
- .append(notifyFFGGGDJANEvent.getLink().contains("?") ? "&uid=" : "?uid=")
- .append(userInfo.getId())
- .append("&token=")
- .append(userInfo.getToken())
- .append("&isZh=")
- .append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
+ htmlUrl.append(notifyFFGGGDJANEvent.getLink()).append(notifyFFGGGDJANEvent.getLink().contains("?") ? "&uid=" : "?uid=").append(userInfo.getId()).append("&token=").append(userInfo.getToken()).append("&isZh=").append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
if (!TextUtils.isEmpty(notifyFFGGGDJANEvent.getH5Type())) {
if (TextUtils.equals(notifyFFGGGDJANEvent.getH5Type(), "1")) {
Bundle bundle = new Bundle();
@@ -1412,9 +1415,7 @@ public class LiveGiftAnimPresenter {
mGifGiftTipGroupBuyZuoji.setLayoutParams(params);
}
- String text = mTempGifGiftBean.getUserNiceName() + " "
- + mContext.getString(R.string.live_send_buy_zuoji_1)
- + " " + (mTempGifGiftBean.getCarName());
+ String text = mTempGifGiftBean.getUserNiceName() + " " + mContext.getString(R.string.live_send_buy_zuoji_1) + " " + (mTempGifGiftBean.getCarName());
Spanned spanned = Html.fromHtml(text, null, new HtmlTagHandler("myfont"));
mGifGiftTipBuyZuoji.setText(spanned);
mGifGiftTipBuyZuoji.setSelected(false);
@@ -1453,9 +1454,7 @@ public class LiveGiftAnimPresenter {
mGifGiftTipGroupBuyLiangName.setLayoutParams(params);
}
- String text = mTempGifGiftBean.getUserNiceName() + " "
- + mContext.getString(R.string.live_send_buy_liang_name_1)
- + " " + mTempGifGiftBean.getLiangName();
+ String text = mTempGifGiftBean.getUserNiceName() + " " + mContext.getString(R.string.live_send_buy_liang_name_1) + " " + mTempGifGiftBean.getLiangName();
Spanned spanned = Html.fromHtml(text, null, new HtmlTagHandler("myfont"));
mGifGiftTipBuyLiangName.setText(spanned);
mGifGiftTipBuyLiangName.setSelected(false);
diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java
index 356827e93..6b502f695 100644
--- a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java
+++ b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java
@@ -29,6 +29,7 @@ import com.yunbao.common.bean.UserBean;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.utils.DpUtil;
+import com.yunbao.common.utils.L;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
@@ -111,7 +112,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
mIsAnchor = isAnchor;
mRoot = root;
mPkContainer = linkMicViewHolder.getPkContainer();
- mPkTimeString2 =mContext.getString(R.string.live_pk_time_2);
+ mPkTimeString2 = mContext.getString(R.string.live_pk_time_2);
//从本地取数据
String pkTime = CommonAppConfig.getInstance().getAnchorPkTime();
@@ -357,6 +358,8 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
*/
public void onLinkDRMicPkApplyOk(UserBean u) {
+ L.eSw("public void onLinkDRMicPkApplyOk(UserBean u) {");
+
user.add(u);
Log.i("1111", "12222222a" + user.size());
mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud();
@@ -387,7 +390,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
//接受PK回调
private void pkAccept() {
- mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud();
+ /*mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud();
mTRTCParams1 = new TRTCCloudDef.TRTCParams();
mTRTCParams1.sdkAppId = GenerateTestUserSig.SDKAPPID;
mTRTCParams1.userId = CommonAppConfig.getInstance().getUid() + "pk";
@@ -396,7 +399,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
mTRTCParams1.role = TRTCCloudDef.TRTCRoleAudience;
mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE);
mTRTCCloud1.startRemoteView(mApplyUid, LivePushTxViewHolder.mPreView1);
- mTRTCCloud1.setListener(new TRTCCloudImplListener(mContext));
+ mTRTCCloud1.setListener(new TRTCCloudImplListener(mContext));*/
LivePushTxViewHolder.btn_close.setVisibility(View.VISIBLE);
SocketLinkMicPkUtil.linkMicPkAccept(mSocketClient, mApplyUid, mApplyUrl, mApplyNmae);
onLinkMicPkStart(mApplyUid, mApplyUrl, mApplyNmae);
@@ -447,7 +450,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
LivePushTxViewHolder.mPreView.setLayoutParams(params);
LivePushTxViewHolder.mPreView1.setLayoutParams(params);
-
+ L.eSw("33333333333333333333333333");
final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", Constants.SOCKET_LINK_MIC_PK)
.param("action", 4)
@@ -734,19 +737,9 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
}
if (mAcceptPk) {
-
-
LivePushTxViewHolder.btn_close.setVisibility(View.VISIBLE);
-
-
//把画面设置成九宫格
dr_pk_view.setVisibility(View.VISIBLE);
- LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mPreView.getLayoutParams();
- params.width = mPreView.getWidth() / 2;
- params.height = DpUtil.dp2px(250);
- params.topMargin = DpUtil.dp2px(130);
- mPreView.setLayoutParams(params);
-
HttpClient.getInstance().get("Livepk.changeLive", "Livepk.changeLive")
.params("uid", CommonAppConfig.getInstance().getUid())
@@ -757,7 +750,6 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
@Override
public void onSuccess(int code, String msgs, String[] info) {
if (code == 0) {
-
HttpClient.getInstance().get("live.joinDRPKroom", "live.joinDRPKroom")
.params("uid", CommonAppConfig.getInstance().getUid())
.params("roomid", u.getId())
@@ -768,15 +760,6 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
public void onSuccess(int code, String msgs, String[] info) {
if (code == 0) {
JSONObject obj = JSON.parseObject(info[0]);
-
- if (LiveLinkMicPkPresenter.mTRTCCloud1 != null && LivePushTxViewHolder.mTRTCCloud != null) {
- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mContext.getResources().getDimensionPixelOffset(R.dimen.live_view));
- params.weight = 1;
- params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
- LivePushTxViewHolder.mPreView.setLayoutParams(params);
- LivePushTxViewHolder.mPreView1.setLayoutParams(params);
- }
-
List list = JSON.parseArray(obj.getString("userlist"), DrPkbean.class);
for (int ii = 0, size = list.size(); ii < size; ii++) {
@@ -786,36 +769,12 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
}
for (int i = 0, size = list.size(); i < size; i++) {
if (!String.valueOf(list.get(i).getId()).equals(CommonAppConfig.getInstance().getUid())) {
- Log.i("tsss11", list.size() + "啊啊啊" + list.get(i).getId() + "");
- mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud();
- mTRTCParams1 = new TRTCCloudDef.TRTCParams();
- mTRTCParams1.sdkAppId = GenerateTestUserSig.SDKAPPID;
- mTRTCParams1.userId = CommonAppConfig.getInstance().getUid() + "pk";
- mTRTCParams1.roomId = list.get(i).getId();
- mTRTCParams1.userSig = GenerateTestUserSig.genTestUserSig(mTRTCParams1.userId);
- mTRTCParams1.role = TRTCCloudDef.TRTCRoleAudience;
- if (i == 1) {
- mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE);
- mTRTCCloud1.startRemoteView(list.get(i).getId() + "", LivePushTxViewHolder.dr1_preview);
- mTRTCCloud1.setListener(new LiveLinkMicPkPresenter.TRTCCloudImplListener(mContext));
- } else if (i == 2) {
- mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE);
- mTRTCCloud1.startRemoteView(list.get(i).getId() + "", LivePushTxViewHolder.dr2_preview);
- mTRTCCloud1.setListener(new LiveLinkMicPkPresenter.TRTCCloudImplListener(mContext));
- } else if (i == 3) {
- mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE);
- mTRTCCloud1.startRemoteView(list.get(i).getId() + "", LivePushTxViewHolder.dr3_preview);
- mTRTCCloud1.setListener(new LiveLinkMicPkPresenter.TRTCCloudImplListener(mContext));
- } else if (i == 4) {
- mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE);
- mTRTCCloud1.startRemoteView(list.get(i).getId() + "", LivePushTxViewHolder.dr4_preview);
- mTRTCCloud1.setListener(new LiveLinkMicPkPresenter.TRTCCloudImplListener(mContext));
- }
Log.i("ssxcs", list.get(i).getId() + "");
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_LIVE_DRPK)
.param("action", 2)
- .param("uid", CommonAppConfig.getInstance().getUid());
+ .param("uid", u.getId())
+ .param("pkuid",CommonAppConfig.getInstance().getUid());
msg.create();
V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), list.get(i).getId() + "", new V2TIMSendCallback() {
@Override
@@ -842,8 +801,6 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener {
}
});
-
-
}
}
});
diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java
index 94e948388..79ecd5f25 100644
--- a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java
+++ b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java
@@ -313,6 +313,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener {
* 所有人收到连麦观众发过来的播流地址的回调
*/
public void onAudienceSendLinkMicUrl(String uid, String uname, String playUrl) {
+ L.eSw("onAudienceSendLinkMicUrl,主播同意");
if (TextUtils.isEmpty(uid)) {
return;
}
diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java
index 4c4f563ed..b911365d6 100644
--- a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java
+++ b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java
@@ -35,6 +35,7 @@ import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
+import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.tencent.trtc.TRTCCloud;
@@ -45,6 +46,7 @@ import com.yunbao.common.event.AnchorInfoEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
+import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.IMRTCManager;
@@ -53,6 +55,7 @@ import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
+import com.yunbao.common.utils.L;
import com.yunbao.common.utils.ScreenDimenUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
@@ -791,7 +794,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
livePushRyViewHolder.camera.setLayoutParams(params);
livePushRyViewHolder.mPreView1.setLayoutParams(params);
livePushRyViewHolder.mPreView1.setVisibility(View.VISIBLE);
-
+ L.eSw("4444444444444444444444444444");
final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LINK_MIC_PK)
.param("action", 4)
@@ -1047,7 +1050,20 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
}
if (mAcceptPk) {
- isPK(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 {
if (mPkWaitCount < 0) {
rtcRoom.getLocalUser().responseJoinOtherRoom(u.getId(), u.getId(), false, false, "extra", new IRCRTCResultCallback() {
@@ -1391,7 +1407,6 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
mHandler.removeMessages(WHAT_PK_WAIT_RECEIVE);
}
if (mAcceptPk) {
-
HttpClient.getInstance().get("Livepk.changeLive", "Livepk.changeLive")
.params("uid", CommonAppConfig.getInstance().getUid())
.params("pkuid", u.getId())
@@ -1522,6 +1537,21 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener {
}
});
+ /*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 {
if (mPkWaitCount < 0) {
diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java
new file mode 100644
index 000000000..fe8d9ef64
--- /dev/null
+++ b/live/src/main/java/com/yunbao/live/presenter/LiveSwLinkMicPkPresenter.java
@@ -0,0 +1,1991 @@
+package com.yunbao.live.presenter;
+
+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.LiveSwAnchorActivity.DRPKing;
+import static com.yunbao.live.activity.LiveSwAnchorActivity.PKing;
+import static com.yunbao.live.activity.LiveSwAnchorActivity.isDRPK;
+import static com.yunbao.live.activity.LiveSwAnchorActivity.mLiveAnchorViewHolder;
+import static com.yunbao.live.views.LivePushSwViewHolder.btn_close;
+import static com.yunbao.live.views.LivePushSwViewHolder.rtcRoom;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+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;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.PopupWindow;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.tencent.imsdk.v2.V2TIMManager;
+import com.tencent.imsdk.v2.V2TIMMessage;
+import com.tencent.imsdk.v2.V2TIMSendCallback;
+import com.tencent.trtc.TRTCCloud;
+import com.yunbao.common.CommonAppConfig;
+import com.yunbao.common.Constants;
+import com.yunbao.common.bean.UserBean;
+import com.yunbao.common.event.AnchorInfoEvent;
+import com.yunbao.common.glide.ImgLoader;
+import com.yunbao.common.http.HttpCallback;
+import com.yunbao.common.http.HttpClient;
+import com.yunbao.common.http.LiveHttpUtil;
+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;
+import com.yunbao.common.utils.Bus;
+import com.yunbao.common.utils.DialogUitl;
+import com.yunbao.common.utils.DpUtil;
+import com.yunbao.common.utils.L;
+import com.yunbao.common.utils.ScreenDimenUtil;
+import com.yunbao.common.utils.StringUtil;
+import com.yunbao.common.utils.ToastUtil;
+import com.yunbao.common.utils.WordUtil;
+import com.yunbao.live.R;
+import com.yunbao.live.activity.LiveAudienceActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
+import com.yunbao.live.bean.DrPkbean;
+import com.yunbao.live.bean.LivePKUserListBean;
+import com.yunbao.live.custom.ProgressTextView;
+import com.yunbao.live.event.LiveAudienceEvent;
+import com.yunbao.live.interfaces.ILiveLinkMicViewHolder;
+import com.yunbao.live.socket.SocketSwClient;
+import com.yunbao.live.socket.SocketSwLinkMicPkUtil;
+import com.yunbao.live.socket.SocketSendBean;
+import com.yunbao.live.views.LiveLinkMicPkViewHolder;
+import com.yunbao.live.views.LivePushSwViewHolder;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import cn.rongcloud.rtc.api.RCRTCEngine;
+import cn.rongcloud.rtc.api.RCRTCMixConfig;
+import cn.rongcloud.rtc.api.RCRTCOtherRoom;
+import cn.rongcloud.rtc.api.RCRTCRemoteUser;
+import cn.rongcloud.rtc.api.callback.IRCRTCOtherRoomEventsListener;
+import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
+import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
+import cn.rongcloud.rtc.base.RTCErrorCode;
+import io.agora.beautyapi.faceunity.agora.SWManager;
+import io.rong.imlib.IRongCallback;
+import io.rong.imlib.RongIMClient;
+import io.rong.imlib.model.Conversation;
+import io.rong.message.TextMessage;
+
+//import cn.rongcloud.rtc.jni.video.RCRect;
+
+/**
+ * Created by cxf on 2018/11/16.
+ * 主播与主播PK逻辑
+ */
+
+public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
+
+ 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_TIME = 2;//pk时间变化 what
+ private static final int WHAT_PK_TIME2 = 22;//pk时间变化 what
+ private static final int LINK_MIC_COUNT_MAX = 10;
+ private static int PK_TIME_MAX = 60 * 15;//pk时间 15分钟
+ private static final int PK_TIME_MAX_2 = 60;//惩罚时间 1分钟
+ private Context mContext;
+ private View mRoot;
+ private boolean mIsAnchor;//自己是否是主播
+ private SocketSwClient mSocketSwClient;
+ private ViewGroup mPkContainer;
+ private boolean mIsApplyDialogShow;//是否显示了申请PK的弹窗
+ 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 mLiveUid;//自己主播的uid
+ private String mUrl;//主播的头像
+ public static String mPkUid;//正在Pk的对方主播的uid
+ public static String oldmPkUid;//正在Pk的对方主播的uid
+ private ProgressTextView mLinkMicWaitProgress;
+ private int mPkWaitCount;//Pk弹窗等待倒计时Live
+ private int mPkTimeCount;//pk时间
+ private PopupWindow mPkPopWindow;
+ private Handler mHandler;
+ private LiveLinkMicPkViewHolder mLiveLinkMicPkViewHolder;
+ private String mPkTimeString1;
+ private String mPkTimeString2;
+ private boolean mIsPkEnd;//pk是否结束,进入惩罚时间
+ private boolean mPkSend;//pk请求是否已经发送
+ private int mPkSendWaitCount;//发送pk请求后的等待时间
+ private String mSelfStream;
+ private int mPkTimeFromServer;
+ public static TRTCCloud mTRTCCloud1;
+ private View detailsView1, detailsView2, detailsView3, detailsView4;
+ private LinearLayout detailsLinearLayout1, detailsLinearLayout2, detailsLinearLayout3, detailsLinearLayout4;
+ private LinearLayout linearGrade1, linearGrade2, linearGrade3, linearGrade4;
+ private TextView textPkName1, textPkName2, textPkName3, textPkName4;
+ private TextView textGrade1, textGrade2, textGrade3, textGrade4;
+ private ImageView imageGrade1, imageGrade2, imageGrade3, imageGrade4;
+
+ public LivePushSwViewHolder livePushSwViewHolder;
+
+ public static List inputStreamList = new ArrayList<>();
+ public static List inputStreamList1 = new ArrayList<>();
+ private boolean DRInitiator = false;//是否是duorenPK发起人
+
+ private List drPkbeans = new ArrayList<>();
+
+ private JSONArray pkScores; //PK分数
+
+ public LiveSwLinkMicPkPresenter setDRInitiator(boolean DRInitiator) {
+ this.DRInitiator = DRInitiator;
+ return this;
+ }
+
+ public LiveSwLinkMicPkPresenter(Context context, ILiveLinkMicViewHolder linkMicViewHolder, boolean isAnchor, View root) {
+ mContext = context;
+ mIsAnchor = isAnchor;
+ mRoot = root;
+ mPkContainer = linkMicViewHolder.getPkContainer();
+ mPkTimeString1 = "";
+ mPkTimeString2 = mContext.getString(R.string.live_pk_time_2);
+ //从本地取数据
+ String pkTime = CommonAppConfig.getInstance().getAnchorPkTime();
+ if (!pkTime.isEmpty()) {
+ try {
+ int time = Integer.parseInt(pkTime) * 60;
+ if (time > 0) {
+ PK_TIME_MAX = time;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ Log.d("PK_TIME_MAX", "" + PK_TIME_MAX);
+ mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case WHAT_PK_WAIT_RECEIVE:
+ onApplyPkWait();
+ break;
+ case WHAT_PK_WAIT_SEND:
+ onSendPkWait();
+ break;
+ case WHAT_PK_TIME:
+ changePkTime();
+ break;
+
+ }
+ }
+ };
+
+ }
+
+ public LiveSwLinkMicPkPresenter(Context context, LivePushSwViewHolder linkMicViewHolder, boolean isAnchor, View root) {
+ mContext = context;
+ mIsAnchor = isAnchor;
+ mRoot = root;
+ mPkContainer = linkMicViewHolder.getPkContainer();
+ livePushSwViewHolder = linkMicViewHolder;
+ mPkTimeString1 = "";
+ mPkTimeString2 = mContext.getString(R.string.live_pk_time_2);
+ //从本地取数据
+ String pkTime = CommonAppConfig.getInstance().getAnchorPkTime();
+ if (!pkTime.isEmpty()) {
+ try {
+ int time = Integer.parseInt(pkTime) * 60;
+ if (time > 0) {
+ PK_TIME_MAX = time;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ Log.d("PK_TIME_MAX", "" + PK_TIME_MAX);
+ mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case WHAT_PK_WAIT_RECEIVE:
+ onApplyPkWait();
+ break;
+ case WHAT_PK_WAIT_SEND:
+ onSendPkWait();
+ break;
+ case WHAT_PK_TIME2:
+ pkCountdownTimer();
+ break;
+ case WHAT_PK_TIME:
+ changePkTime();
+ break;
+ }
+ }
+ };
+
+ }
+
+ public void setSocketRyClient(SocketSwClient SocketRyClient) {
+ mSocketSwClient = SocketRyClient;
+ }
+
+ public void setLiveUid(String liveUid, String url) {
+ Log.e("liveUid", liveUid);
+ mLiveUid = liveUid;
+ mUrl = url;
+ }
+
+
+ /**
+ * 申请pk弹窗倒计时
+ */
+ private void onApplyPkWait() {
+ mPkWaitCount--;
+ if (mPkWaitCount >= 0) {
+ if (mLinkMicWaitProgress != null) {
+ mLinkMicWaitProgress.setProgress(mPkWaitCount);
+ if (mHandler != null) {
+ mHandler.sendEmptyMessageAtTime(WHAT_PK_WAIT_RECEIVE, getNextSecondTime());
+ }
+ }
+ } else {
+ if (mPkPopWindow != null) {
+ mPkPopWindow.dismiss();
+ }
+ }
+ }
+
+ /**
+ * 发送pk申请后等待倒计时
+ */
+ private void onSendPkWait() {
+ mPkSendWaitCount--;
+ if (mPkSendWaitCount >= 0) {
+ nextSendPkWaitCountDown();
+ } else {
+ hideSendPkWait();
+ if (mIsAnchor) {
+ ((LiveSwAnchorActivity) mContext).setPkBtnVisible(true);
+ }
+ }
+ }
+
+ /**
+ * 进入下一次pk申请等待倒计时
+ */
+ private void nextSendPkWaitCountDown() {
+ if (mLiveLinkMicPkViewHolder != null) {
+ mLiveLinkMicPkViewHolder.setPkWaitProgress(mPkSendWaitCount);
+ }
+ if (mHandler != null) {
+ mHandler.sendEmptyMessageAtTime(WHAT_PK_WAIT_SEND, getNextSecondTime());
+ }
+ }
+
+ /**
+ * 隐藏pk申请等待
+ */
+ private void hideSendPkWait() {
+ mPkSend = false;
+ if (mHandler != null) {
+ mHandler.removeMessages(WHAT_PK_WAIT_SEND);
+ }
+ if (mLiveLinkMicPkViewHolder != null) {
+ mLiveLinkMicPkViewHolder.setPkWaitProgressVisible(false);
+ }
+ }
+
+ /**
+ * 进入下一次pk倒计时
+ */
+ int i = 0;
+
+ private void nextPkTimeCountDown(int is) {
+
+ if (mHandler != null) {
+ mHandler.sendEmptyMessageAtTime(WHAT_PK_TIME, getNextSecondTime());
+ }
+ if (mLiveLinkMicPkViewHolder != null) {
+ String s = mIsPkEnd ? mPkTimeString2 : mPkTimeString1;
+ String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
+ Log.i("tag23333", mPkTimeCount + "mPkTimeCount" + s1 + "is" + is);
+ if (i == 1 && s1.equals("00:01")) {
+ s1 = "00:00";
+ i = 0;
+ }
+ if (rtcRoom != null) {
+ ScreenDimenUtil util = ScreenDimenUtil.getInstance();
+ int mScreenWdith = util.getScreenWdith();
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
+ params.weight = 1;
+ params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ livePushSwViewHolder.camera.setLayoutParams(params);
+ livePushSwViewHolder.mPreView1.setLayoutParams(params);
+ }
+
+ Log.i("tts2", s1);
+ mLiveLinkMicPkViewHolder.setTime(s + " " + s1);
+ if (s1.equals("00:01") && mIsAnchor && !s.contains("懲罰")) {
+ HttpClient.getInstance().get("Livepk.endPK", "Livepk.endPK").params("uid", CommonAppConfig.getInstance().getUid()).params("addtime", "00:00").params("type", "0").params("sign", "1").execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0) {
+ JSONObject datas = JSONObject.parseObject(info[0]);
+ if (!datas.getString("pkuid").equals("0")) {
+ SocketSendBean seed_msg = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 9).param("msgtype", 10).param("win_uid", datas.getString("win_uid")).param("uid", CommonAppConfig.getInstance().getUid());
+ seed_msg.create();
+ String pkUid = datas.getString("pkuid");
+ Log.i("seed", seed_msg.mResult.toString());
+
+ Log.e("ry1", datas.getString("win_uid") + "VVVVVV" + datas.getString("pkuid"));
+
+ HttpClient.getInstance().post("Tx.sendmsgzs2", "Tx.sendmsgzs2").params("GroupId", "g" + pkUid).params("jsonstr", seed_msg.mResult.toString()).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ HttpClient.getInstance().post("Tx.sendmsgzs2", "Tx.sendmsgzs2").params("GroupId", "g" + CommonAppConfig.getInstance().getUid()).params("jsonstr", seed_msg.mResult.toString()).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+
+ }
+ });
+ }
+ });
+
+ }
+ }
+ }
+ });
+ }
+
+ }
+ }
+
+
+ /**
+ * pk时间倒计时
+ */
+ private void changePkTime() {
+ if (mPkTimeCount < 0) return;
+ mPkTimeCount--;
+ Log.i("vvvs", "mPkTimeCount:" + mPkTimeCount);
+ if (mPkTimeCount >= 0) {//
+ nextPkTimeCountDown(1);
+ if (mContext instanceof LiveAudienceActivity) {
+ ((LiveAudienceActivity) mContext).setPkStatus(true);
+ }
+ } else {
+ if (mIsPkEnd) {
+ onLinkMicPkClose(0);
+ if (mIsAnchor) {
+ ((LiveSwAnchorActivity) mContext).setPkBtnVisible(true);
+ }
+ if (mContext instanceof LiveAudienceActivity) {
+ ((LiveAudienceActivity) mContext).setPkStatus(false);
+ }
+ //如果PK结束Im没有发送关闭PK的消息,倒计时结束自动关闭
+// if (mLiveLinkMicPkViewHolder != null) {
+// mLiveLinkMicPkViewHolder.removeFromParent();
+// mLiveLinkMicPkViewHolder.release();
+// }
+// mLiveLinkMicPkViewHolder = null;
+ }
+ }
+ }
+
+ /**
+ * 获取下一秒钟的时间
+ */
+ private long getNextSecondTime() {
+ long now = SystemClock.uptimeMillis();
+ return now + (1000 - now % 1000);
+ }
+
+ /**
+ * 发起主播PK申请
+ */
+ public void applyLinkMicPk(String pkUid, String stream) {
+ if (mPkSend) {
+ ToastUtil.show(mContext.getString(R.string.link_mic_apply_waiting));
+ return;
+ }
+ if (mIsPk) {
+ ToastUtil.show(mContext.getString(R.string.live_link_mic_cannot_pk));
+ return;
+ }
+ mPkSend = true;
+ SocketSwLinkMicPkUtil.linkMicPkApply(mSocketSwClient, pkUid, stream);
+ ToastUtil.show(mContext.getString(R.string.link_mic_apply_pk));
+
+ if (mLiveLinkMicPkViewHolder == null) {
+ mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer);
+ mLiveLinkMicPkViewHolder.addToParent();
+ mLiveLinkMicPkViewHolder.setIsAnchor(mIsAnchor);
+
+ }
+ mLiveLinkMicPkViewHolder.setPkWaitProgressVisible(true);
+ mPkSendWaitCount = LINK_MIC_COUNT_MAX;
+ nextSendPkWaitCountDown();
+ if (mIsAnchor) {
+ ((LiveSwAnchorActivity) mContext).setPkBtnVisible(false);
+ }
+ }
+
+ /**
+ * 主播与主播PK 主播收到其他主播发过来的多人PK申请的回调
+ */
+ public void onLinkDRMicPkApply(UserBean u) {
+ Log.e("ry", "多人收到");
+ showDRApplyDialog(u);
+ }
+
+ public void onLinkDRMicPkQuit(String uid) {
+ HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", mApplyUid).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (info.length > 0) {
+ //退出所有直播間
+ livePushSwViewHolder.exitChannelDrPk(drPkbeans);
+
+ JSONObject obj = JSONObject.parseObject(info[0]);
+ drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class);
+
+ for (int i = 0; i < drPkbeans.size(); i++) {
+ if (!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) {
+ livePushSwViewHolder.setAnDrPkRtc(String.valueOf(drPkbeans.get(i).getId()), -1);
+ }
+ }
+ if (DRPKing == 1) {
+ mHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ setMyDrPkDetailsView();
+ for (int j = 0; j < drPkbeans.size(); j++) {
+ if (j == 0) {
+ L.eSw("j == 0:" + j);
+ //设置多人PK数据
+ if (detailsView2 != null) {
+ livePushSwViewHolder.dr2_preview.removeView(detailsView2);
+ }
+ detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
+ detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2);
+ linearGrade2 = detailsView2.findViewById(R.id.linear_grade2);
+ textPkName2 = detailsView2.findViewById(R.id.text_pk_name2);
+ imageGrade2 = detailsView2.findViewById(R.id.image_grade2);
+ textGrade2 = detailsView2.findViewById(R.id.text_grade2);
+ imageGrade2.setTag(String.valueOf(drPkbeans.get(0).getId()));
+ textPkName2.setText(drPkbeans.get(0).getUser_nicename());
+ livePushSwViewHolder.dr2_preview.addView(detailsView2);
+ detailsLinearLayout2.setVisibility(View.GONE);
+ linearGrade2.setVisibility(View.GONE);
+ } else if (j == 1) {
+ L.eSw("j == 1:" + j);
+ if (detailsView4 != null) {
+ livePushSwViewHolder.dr4_preview.removeView(detailsView4);
+ }
+ detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
+ detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4);
+ linearGrade4 = detailsView4.findViewById(R.id.linear_grade4);
+ textPkName4 = detailsView4.findViewById(R.id.text_pk_name4);
+ imageGrade4 = detailsView4.findViewById(R.id.image_grade4);
+ textGrade4 = detailsView4.findViewById(R.id.text_grade4);
+ imageGrade4.setTag(String.valueOf(drPkbeans.get(1).getId()));
+ textPkName4.setText(drPkbeans.get(1).getUser_nicename());
+ livePushSwViewHolder.dr4_preview.addView(detailsView4);
+ detailsLinearLayout4.setVisibility(View.GONE);
+ linearGrade4.setVisibility(View.GONE);
+ } else if (j == 2) {
+ L.eSw("j == 2:" + j);
+
+ if (detailsView4 != null) {
+ livePushSwViewHolder.dr4_preview.removeView(detailsView4);
+ }
+ detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
+ detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4);
+ linearGrade4 = detailsView4.findViewById(R.id.linear_grade4);
+ textPkName4 = detailsView4.findViewById(R.id.text_pk_name4);
+ imageGrade4 = detailsView4.findViewById(R.id.image_grade4);
+ textGrade4 = detailsView4.findViewById(R.id.text_grade4);
+ imageGrade4.setTag(String.valueOf(drPkbeans.get(2).getId()));
+ textPkName4.setText(drPkbeans.get(2).getUser_nicename());
+ livePushSwViewHolder.dr4_preview.addView(detailsView4);
+ detailsLinearLayout4.setVisibility(View.GONE);
+ linearGrade4.setVisibility(View.GONE);
+
+ if (detailsView3 != null) {
+ livePushSwViewHolder.dr3_preview.removeView(detailsView3);
+ }
+ detailsView3 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
+ detailsLinearLayout3 = detailsView3.findViewById(R.id.lin_pk3);
+ linearGrade3 = detailsView3.findViewById(R.id.linear_grade3);
+ textPkName3 = detailsView3.findViewById(R.id.text_pk_name3);
+ imageGrade3 = detailsView3.findViewById(R.id.image_grade3);
+ textGrade3 = detailsView3.findViewById(R.id.text_grade3);
+ imageGrade3.setTag(String.valueOf(drPkbeans.get(1).getId()));
+ textPkName3.setText(drPkbeans.get(1).getUser_nicename());
+ livePushSwViewHolder.dr3_preview.addView(detailsView3);
+ detailsLinearLayout3.setVisibility(View.GONE);
+ linearGrade3.setVisibility(View.GONE);
+
+
+ ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
+ }
+ }
+ int removeUid = 0;
+ for (int k = 0; k < pkScores.size(); k++) {
+ JSONObject score = pkScores.getJSONObject(k);
+ String userID = score.getString("id");
+ if(userID.equals(uid)){
+ removeUid = k;
+ }
+ }
+ pkScores.remove(removeUid);
+ upDataPkScore(pkScores,"-1",0,false);
+ }
+ }, 100);
+ }
+
+
+
+ SWManager.get().setDrPkNumClarity(drPkbeans.size());
+ if (drPkbeans.size() == 1) {
+ mLiveAnchorViewHolder.closeEndPkBt();
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ * 主播与主播PK 主播收到其他主播发过来的多人PK申请同意了的回调
+ */
+ public void onLinkDRMicPkApplyOk(UserBean u) {
+ L.eSw("onLinkDRMicPkApplyOk(UserBean u) " + u.getUserNiceName());
+ int index = 0;
+ if (livePushSwViewHolder != null) {
+ livePushSwViewHolder.setAnDrPkRtc(String.valueOf(u.getId()), -1);
+ }
+ final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK).param("action", 3).param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", CommonAppConfig.getInstance().getUid()).param("msgtype", 3).param("uid", u.getId()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
+ 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);
+
+ 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) {
+ }
+
+ @Override
+ public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
+ Log.e("tx", "aaa" + errorCode.toString());
+ ToastUtil.show(errorCode.code + ":" + errorCode.msg);
+ }
+ });
+ dRjoinOtherRoom(u);
+ //展示结束连麦按钮
+ 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主播发过来的已经接受
+ */
+ public void onLinkMicToPk(UserBean u) {
+ EventBus.getDefault().post(new AnchorInfoEvent(false, u.getId(), u.getUserNiceName(), u.getAvatar()));
+ Log.e("eve", u.getId() + "");
+ L.eSw("主播接受了主播的PK邀請");
+ RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START);
+ LivePushSwViewHolder.btn_close.setVisibility(View.VISIBLE);
+ LiveSwAnchorActivity.isDRPK = 1;
+ livePushSwViewHolder.setAnPkRtc(u);//设置对方主播视图
+ LivePushSwViewHolder.btn_close.setVisibility(View.VISIBLE);
+ }
+
+ private void isPK(UserBean bean) {
+ EventBus.getDefault().post(new AnchorInfoEvent(false, bean.getId(), bean.getUserNiceName(), bean.getAvatar()));
+ ScreenDimenUtil util = ScreenDimenUtil.getInstance();
+ int mScreenWdith = util.getScreenWdith();
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, mScreenWdith * 720 / 960);
+ params.weight = 1;
+ params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ livePushSwViewHolder.camera.setLayoutParams(params);
+ livePushSwViewHolder.mPreView1.setLayoutParams(params);
+ livePushSwViewHolder.mPreView1.setVisibility(View.VISIBLE);
+ LivePushSwViewHolder.btn_close.setVisibility(View.VISIBLE);
+ LiveSwAnchorActivity.isDRPK = 1;
+
+ /*---------------------------------------------------------------- */
+ final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 2) //回复PK申请 2
+ .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", bean.getId()).param("uid", CommonAppConfig.getInstance().getUid()).param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
+ if (bean.isRandomPk()) {
+ msg1.param("random_pk", "1");
+ }
+ if (RandomPkManager.getInstance().isRankModel()) {
+ L.eSw("排位赛");
+ msg1.param("is_ladders", "https://downs.yaoulive.com/rank_top_box.png");
+ }
+ msg1.param("is_ladders", "https://downs.yaoulive.com/rank_top_box.png");
+ msg1.create();
+ System.out.println("PK回执 = " + msg1.toString());
+ 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(bean.getId(), 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("tx", "发送成功");
+ }
+
+ @Override
+ public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
+ Log.e("tx", "发送失败" + errorCode.getMessage());
+
+ }
+ });
+
+ // TODO: 2024/4/12 视图渲染
+ livePushSwViewHolder.setAnPkRtc(bean);
+ new Handler(Looper.getMainLooper()).post(new Runnable() {
+ public void run() {
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.UN_LEAVELIVE));
+ LiveSwAnchorActivity.isDRPK = 1;
+ LivePushSwViewHolder.btn_close.setVisibility(View.VISIBLE);
+ //SocketSwLinkMicPkUtil.linkMicPkAccept(mSocketSwClient, mApplyUid, mApplyUrl, mApplyNmae);
+ EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.UP_PK_TWO).setObject(mApplyUid));
+ onLinkMicPkStart(mApplyUid, 2);
+ }
+ });
+ }
+
+ /**
+ * 显示申请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
+ public void onDismiss() {
+ 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("有人向您发起PK请求。
" + "若拒绝PK,将会10分钟内不会再收到任何随机PK请求。")).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("若拒絕PK,將會關閉你的隨機PK開關。" + "並且10分鍾不會收到任何隨機PK請求。"));
+ ((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() {
+ @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;
+ if (finalAgree) {
+ 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) {
+ L.eSw("多人PK" + "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info));
+ if (info.length == 0) {
+ return;
+ }
+ JSONObject obj = JSONObject.parseObject(info[0]);
+ drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class);
+ SWManager.get().setDrPkNumClarity(3);//加入成功后,将分别率设置为 VD_320x240
+ //将自己从多人pk列表里剔除
+ int removeIndex = -1;
+ for (int i = 0; i < drPkbeans.size(); i++) {
+ if (CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) {
+ removeIndex = i;
+ }
+ }
+ if (removeIndex != -1) {
+ drPkbeans.remove(removeIndex);
+ L.eSw("将自己从多人pk列表里剔除" + new Gson().toJson(drPkbeans));
+ }
+
+ HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", mApplyUid).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (info.length > 0) {
+ JSONObject obj = JSONObject.parseObject(info[0]);
+ drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class);
+ for (int i = 0; i < drPkbeans.size(); i++) {
+ if (!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) {
+ final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK).param("action", 2).param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", CommonAppConfig.getInstance().getUid()).param("msgtype", 2).param("uid", drPkbeans.get(i).getId()).param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
+ msg1.create();
+ L.eSw("uiduiduiduiduiduiduiduid" + drPkbeans.get(i).getId());
+ String targetId = String.valueOf(drPkbeans.get(i).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) {
+ }
+
+ @Override
+ public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
+ Log.e("tx", "aaa" + errorCode.toString());
+ ToastUtil.show(errorCode.code + ":" + errorCode.msg);
+ }
+ });
+
+ //
+ int index = livePushSwViewHolder.setAnDrPkRtc(String.valueOf(drPkbeans.get(i).getId()), -1);
+
+ L.eSw("onLinkDRMicPkApplyOk(UserBean u)-点击接收 1 " + u.getUserNiceName());
+ L.eSw("發送action = 2");
+
+ }
+
+ if (!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) {
+ final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK).param("action", 3).param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("msgtype", 3).param("uid", drPkbeans.get(i).getId()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName() );;
+ msg1.create();
+ L.eSw("發送給自己直播間" + drPkbeans.get(i).getId());
+ 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);
+
+ 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) {
+ }
+
+ @Override
+ public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
+ Log.e("tx", "aaa" + errorCode.toString());
+ ToastUtil.show(errorCode.code + ":" + errorCode.msg);
+ }
+ });
+ }
+
+
+ if (!mApplyUid.equals(String.valueOf(drPkbeans.get(i).getId())) && !CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) {
+ final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK).param("action", 3).param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", CommonAppConfig.getInstance().getUid()).param("msgtype", 3).param("uid", drPkbeans.get(i).getId()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
+ msg1.create();
+ L.eSw("發送給其他主播直播间" + drPkbeans.get(i).getId());
+ String targetId = "g" + drPkbeans.get(i).getId();
+ 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);
+
+ 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) {
+ }
+
+ @Override
+ public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
+ Log.e("tx", "aaa" + errorCode.toString());
+ ToastUtil.show(errorCode.code + ":" + errorCode.msg);
+ }
+ });
+ }
+ }
+ dRjoinOtherRoom(u);
+ //展示结束连麦按钮
+ //设置多人PK 房主ROOM UID
+ mLiveAnchorViewHolder.setDrpkRoomId(mApplyUid);
+ mLiveAnchorViewHolder.showEndPkBt();
+ }
+ }
+ });
+ }
+ });
+ }
+ } else {
+ ToastUtil.show(msg);
+ }
+ }
+
+ });
+
+
+ }
+ }
+ });
+ } else {
+ if (mPkWaitCount < 0) {
+ 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);
+
+ 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", "发送失敗" + mApplyUid);
+ }
+ });
+ }
+ });
+
+ } else {
+ 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 (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", "发送失敗");
+ }
+ });
+ }
+ });
+ }
+ 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());
+ }
+ }
+
+ public void setMyDrPkDetailsView() {
+ if (detailsView1 != null) {
+ livePushSwViewHolder.dr1_preview.removeView(detailsView1);
+ }
+ detailsView1 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
+ detailsLinearLayout1 = detailsView1.findViewById(R.id.lin_pk1);
+ linearGrade1 = detailsView1.findViewById(R.id.linear_grade1);
+ imageGrade1 = detailsView1.findViewById(R.id.image_grade1);
+ textGrade1 = detailsView1.findViewById(R.id.text_grade1);
+ textPkName1 = detailsView1.findViewById(R.id.text_pk_name1);
+ imageGrade1.setTag(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
+ livePushSwViewHolder.dr1_preview.addView(detailsView1);
+ detailsLinearLayout1.setVisibility(View.GONE);
+ linearGrade1.setVisibility(View.GONE);
+ }
+
+ //多人PK接受申请画
+ public void dRjoinOtherRoom(UserBean u) {
+ L.eSw("dRjoinOtherRoom UserBeanUserBeanUserBeanUserBeanUserBeanUserBeanUserBeanUserBean ");
+ setMyDrPkDetailsView();
+ HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", mApplyUid).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (info.length > 0) {
+ JSONObject obj = JSONObject.parseObject(info[0]);
+ drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class);
+ int removeIndex = -1;
+ for (int i = 0; i < drPkbeans.size(); i++) {
+ if (CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeans.get(i).getId()))) {
+ removeIndex = i;
+ }
+ }
+ if (removeIndex != -1) {
+ drPkbeans.remove(removeIndex);
+ }
+ SWManager.get().setDrPkNumClarity(drPkbeans.size());
+ setDrPkUserInfoView(drPkbeans);
+ }
+ }
+ });
+ }
+
+ private void setDrPkUserInfoView(List drPkbeanList) {
+ L.eSw("setDrPkUserInfoView" + new Gson().toJson(drPkbeanList));
+ for (int j = 0; j < drPkbeanList.size(); j++) {
+ if (j == 0) {
+ L.eSw("j == 0:" + j);
+ //设置多人PK数据
+ if (detailsView2 != null) {
+ livePushSwViewHolder.dr2_preview.removeView(detailsView2);
+ }
+ detailsView2 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
+ detailsLinearLayout2 = detailsView2.findViewById(R.id.lin_pk2);
+ linearGrade2 = detailsView2.findViewById(R.id.linear_grade2);
+ textPkName2 = detailsView2.findViewById(R.id.text_pk_name2);
+ imageGrade2 = detailsView2.findViewById(R.id.image_grade2);
+ textGrade2 = detailsView2.findViewById(R.id.text_grade2);
+ imageGrade2.setTag(String.valueOf(drPkbeanList.get(0).getId()));
+ textPkName2.setText(drPkbeanList.get(0).getUser_nicename());
+ livePushSwViewHolder.dr2_preview.addView(detailsView2);
+ detailsLinearLayout2.setVisibility(View.GONE);
+ linearGrade2.setVisibility(View.GONE);
+ } else if (j == 1) {
+ L.eSw("j == 1:" + j);
+ if (detailsView4 != null) {
+ livePushSwViewHolder.dr4_preview.removeView(detailsView4);
+ }
+ detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
+ detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4);
+ linearGrade4 = detailsView4.findViewById(R.id.linear_grade4);
+ textPkName4 = detailsView4.findViewById(R.id.text_pk_name4);
+ imageGrade4 = detailsView4.findViewById(R.id.image_grade4);
+ textGrade4 = detailsView4.findViewById(R.id.text_grade4);
+ imageGrade4.setTag(String.valueOf(drPkbeanList.get(1).getId()));
+ textPkName4.setText(drPkbeanList.get(1).getUser_nicename());
+ livePushSwViewHolder.dr4_preview.addView(detailsView4);
+ detailsLinearLayout4.setVisibility(View.GONE);
+ linearGrade4.setVisibility(View.GONE);
+ } else if (j == 2) {
+ L.eSw("j == 2:" + j);
+
+ if (detailsView4 != null) {
+ livePushSwViewHolder.dr4_preview.removeView(detailsView4);
+ }
+ detailsView4 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
+ detailsLinearLayout4 = detailsView4.findViewById(R.id.lin_pk4);
+ linearGrade4 = detailsView4.findViewById(R.id.linear_grade4);
+ textPkName4 = detailsView4.findViewById(R.id.text_pk_name4);
+ imageGrade4 = detailsView4.findViewById(R.id.image_grade4);
+ textGrade4 = detailsView4.findViewById(R.id.text_grade4);
+ imageGrade4.setTag(String.valueOf(drPkbeanList.get(2).getId()));
+ textPkName4.setText(drPkbeanList.get(2).getUser_nicename());
+ livePushSwViewHolder.dr4_preview.addView(detailsView4);
+ detailsLinearLayout4.setVisibility(View.GONE);
+ linearGrade4.setVisibility(View.GONE);
+
+ if (detailsView3 != null) {
+ livePushSwViewHolder.dr3_preview.removeView(detailsView3);
+ }
+ detailsView3 = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
+ detailsLinearLayout3 = detailsView3.findViewById(R.id.lin_pk3);
+ linearGrade3 = detailsView3.findViewById(R.id.linear_grade3);
+ textPkName3 = detailsView3.findViewById(R.id.text_pk_name3);
+ imageGrade3 = detailsView3.findViewById(R.id.image_grade3);
+ textGrade3 = detailsView3.findViewById(R.id.text_grade3);
+ imageGrade3.setTag(String.valueOf(drPkbeanList.get(1).getId()));
+ textPkName3.setText(drPkbeanList.get(1).getUser_nicename());
+ livePushSwViewHolder.dr3_preview.addView(detailsView3);
+ detailsLinearLayout3.setVisibility(View.GONE);
+ linearGrade3.setVisibility(View.GONE);
+
+ ToastUtil.show(WordUtil.isNewZh() ? "接受成功" : "Success");
+ }
+ }
+ L.eSw("dRjoinOtherRoom:size:" + drPkbeanList.size() + " json " + new Gson().toJson(drPkbeanList));
+
+ }
+
+ @Override
+ public void onClick(View v) {
+ int i = v.getId();
+ if (i == R.id.btn_refuse) {
+ refuseLinkMic();
+
+ } else if (i == R.id.btn_accept) {
+ acceptLinkMic();
+
+ }
+ }
+
+ /**
+ * 拒绝PK
+ */
+ private void refuseLinkMic() {
+ if (mPkPopWindow != null) {
+ mPkPopWindow.dismiss();
+ }
+ }
+
+ /**
+ * 接受PK
+ */
+ private void acceptLinkMic() {
+ mAcceptPk = true;
+ if (mPkPopWindow != null) {
+ mPkPopWindow.dismiss();
+ }
+ }
+
+ /**
+ * pk 进度发送变化
+ *
+ * @param leftGift
+ * @param rightGift
+ */
+ public void onPkProgressChanged(long leftGift, long rightGift, LivePKUserListBean bean) {
+ if (mLiveLinkMicPkViewHolder != null) {
+ mLiveLinkMicPkViewHolder.onProgressChanged(leftGift, rightGift, bean);
+ }
+ }
+
+ /**
+ * 进房间的时候PK开始
+ */
+ public void onEnterRoomPkStart(String pkUid, long leftGift, long rightGift, int pkTime, LivePKUserListBean bean) {
+ mIsPk = true;
+ mIsPkEnd = false;
+ mPkUid = pkUid;
+ mApplyUid = null;
+ mApplyStream = null;
+ if (mLiveLinkMicPkViewHolder == null) {
+ mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer);
+ mLiveLinkMicPkViewHolder.addToParent();
+ mLiveLinkMicPkViewHolder.setIsAnchor(mIsAnchor);
+
+ }
+ mLiveLinkMicPkViewHolder.showTime();
+ mLiveLinkMicPkViewHolder.onEnterRoomPkStart();
+ mLiveLinkMicPkViewHolder.onProgressChanged(leftGift, rightGift, bean);
+ mPkTimeCount = pkTime;
+ Log.d("mPkTimeCount1", "" + mPkTimeCount + ";mPkTimeFromServer=" + mPkTimeFromServer);
+ mPkTimeFromServer = pkTime;
+ nextPkTimeCountDown(2);
+ }
+
+ /**
+ * 修改最终PK数据
+ *
+ * @param leftGift 左边数据
+ * @param rightGift 右边数据
+ * @param bean 排位数据
+ */
+ public void onPkProgressEnd(long leftGift, long rightGift, LivePKUserListBean bean) {
+ if (mLiveLinkMicPkViewHolder != null) {
+ mLiveLinkMicPkViewHolder.onProgressChanged(leftGift, rightGift, bean, true);
+ }
+ }
+
+
+ /**
+ * 进房间的时候懲罰开始
+ */
+ public void onEnterRoomCFStart(String pkUid, long leftGift, long rightGift, int pkTime, LivePKUserListBean bean) {
+ mIsPk = true;
+ mIsPkEnd = true;
+ mPkUid = pkUid;
+ mApplyUid = null;
+ mApplyStream = null;
+ if (mLiveLinkMicPkViewHolder == null) {
+ mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer);
+ mLiveLinkMicPkViewHolder.addToParent();
+ mLiveLinkMicPkViewHolder.setIsAnchor(mIsAnchor);
+
+ }
+ mLiveLinkMicPkViewHolder.showTime();
+// -1自己的主播输 0平 1自己的主播赢
+ int p = 0;
+ if (leftGift < rightGift) {
+ p = -1;
+ } else if (leftGift > rightGift) {
+ p = 1;
+ } else if (leftGift == rightGift) {
+ p = 0;
+ }
+ mLiveLinkMicPkViewHolder.new_end(p);
+
+ mLiveLinkMicPkViewHolder.onProgressChanged(leftGift, rightGift, bean);
+ mPkTimeCount = pkTime;
+ Log.d("mPkTimeCount1", "" + mPkTimeCount + ";mPkTimeFromServer=" + mPkTimeFromServer);
+// mPkTimeFromServer=pkTime;
+ //恢复播放画面
+ nextPkTimeCountDown(3);
+ }
+
+
+ /**
+ * 主播与主播PK 所有人收到PK开始的回调
+ */
+ public void onLinkMicPkStart(String pkUid, int i) {
+ L.eSw("onLinkMicPkStart pkUid " + pkUid + " " + i);
+ Log.d("tag", i + "mPkTimeCount2");
+ mIsPk = true;
+ hideSendPkWait();
+ mIsPkEnd = false;
+ oldmPkUid = pkUid;
+ mPkUid = pkUid;
+ mApplyUid = null;
+ mApplyStream = null;
+ isDRPK = 1;
+ if (mLiveLinkMicPkViewHolder == null) {
+ mLiveLinkMicPkViewHolder = new LiveLinkMicPkViewHolder(mContext, mPkContainer);
+ mLiveLinkMicPkViewHolder.addToParent();
+ mLiveLinkMicPkViewHolder.setIsAnchor(mIsAnchor);
+ if (mContext instanceof LiveAudienceActivity) {
+ ((LiveAudienceActivity) mContext).getmLivePlayViewHolder().setPkview();
+ }
+ }
+ mLiveLinkMicPkViewHolder.startAnim();
+ EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TWO_START).setObject(pkUid));
+ mLiveLinkMicPkViewHolder.showTime();
+ mPkTimeCount = 100;
+ nextPkTimeCountDown(2);//时间倒计时
+ if (mIsAnchor) {
+ ((LiveSwAnchorActivity) mContext).setPkBtnVisible(false);
+ mPkTimeCount = PK_TIME_MAX;
+ } else {
+// mPkTimeCount=mPkTimeFromServer;
+ mPkTimeCount = PK_TIME_MAX;
+ }
+ Log.d("mPkTimeCount2", "" + mPkTimeCount + ";mPkTimeFromServer=" + mPkTimeFromServer);
+ }
+
+
+ /**
+ * 主播与主播PK PK结果的回调
+ */
+ int s1 = 0;
+
+ public void onLinkMicPkEnd(String winUid) {
+ Log.i("收", "9");
+
+ if (mIsPkEnd) {
+ return;
+ }
+ mIsPkEnd = true;
+ if (mHandler != null) {
+ mHandler.removeMessages(WHAT_PK_TIME);
+ }
+ if (mLiveLinkMicPkViewHolder != null) {
+ if (!TextUtils.isEmpty(winUid)) {
+ if ("0".equals(winUid)) {
+ mLiveLinkMicPkViewHolder.end(0);
+ mLiveLinkMicPkViewHolder.hideTime();
+ if (mHandler != null) {
+ mHandler.postDelayed(new Runnable() {
+ @Override
+ public void run() {
+ onLinkMicPkClose(0);
+ if (mIsAnchor) {
+ ((LiveSwAnchorActivity) mContext).setPkBtnVisible(true);
+ }
+ }
+ }, 3000);
+ }
+ } else {
+ Log.e("ry1", winUid + "result");
+ if (winUid.equals(mLiveUid)) {
+ mLiveLinkMicPkViewHolder.end(1);
+ } else {
+ mLiveLinkMicPkViewHolder.end(-1);
+ }
+ mPkTimeCount = PK_TIME_MAX_2;//进入惩罚时间
+ nextPkTimeCountDown(5);
+ }
+ }
+
+ }
+ }
+
+ /**
+ * 主播与主播PK 断开连麦PK的回调
+ */
+ public void onLinkMicPkClose(int i) {
+ Log.e("ry", mPkUid + "aaaaqwqw" + i);
+
+ PKing = false;
+ LiveSwAnchorActivity.isDRPK = 0;
+
+// //恢复播放画面
+ if (i == 1) {
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ if (btn_close != null) {
+ btn_close.setVisibility(View.GONE);
+ }
+ }
+ });
+
+ runOnUiThread(new Runnable() {
+ public void run() {
+// try {
+// Thread.sleep(4000);
+ if (mContext instanceof LiveAudienceActivity && LiveAudienceActivity.getmLivePlayViewHolder() != null) {
+ LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
+ }
+// } catch (InterruptedException e) {
+// e.printStackTrace();
+// }
+ }
+ });
+
+ }
+ if (mHandler != null) {
+ mHandler.removeCallbacksAndMessages(null);
+ }
+ if (mPkPopWindow != null) {
+ mPkPopWindow.dismiss();
+ }
+ mPkPopWindow = null;
+ mIsPk = false;
+ mIsPkEnd = false;
+ hideSendPkWait();
+ mPkUid = null;
+ mApplyUid = null;
+ mApplyStream = null;
+ if (mLiveLinkMicPkViewHolder != null) {
+ mLiveLinkMicPkViewHolder.removeFromParent();
+ mLiveLinkMicPkViewHolder.release();
+ }
+ mLiveLinkMicPkViewHolder = null;
+ }
+
+ /**
+ * 主播与主播Pk 对方主播拒绝Pk的回调
+ */
+ public void onLinkMicPkRefuse() {
+ hideSendPkWait();
+ if (mIsAnchor) {
+ ((LiveSwAnchorActivity) mContext).setPkBtnVisible(true);
+ }
+ ToastUtil.show(mContext.getString(R.string.link_mic_refuse_pk));
+ }
+
+ /**
+ * 主播与主播Pk 对方主播无响应的回调
+ */
+ public void onLinkMicPkNotResponse() {
+ hideSendPkWait();
+ if (mIsAnchor) {
+ ((LiveSwAnchorActivity) mContext).setPkBtnVisible(true);
+ }
+ ToastUtil.show(mContext.getString(R.string.link_mic_anchor_not_response_2));
+ }
+
+ /**
+ * 主播与主播Pk 对方主播正在忙的回调
+ */
+ public void onLinkMicPkBusy() {
+ hideSendPkWait();
+ if (mIsAnchor) {
+ ((LiveSwAnchorActivity) mContext).setPkBtnVisible(true);
+ }
+ ToastUtil.show(mContext.getString(R.string.link_mic_anchor_busy_2));
+ }
+
+
+ public void release() {
+ if (mHandler != null) {
+ mHandler.removeCallbacksAndMessages(null);
+ }
+ mHandler = null;
+ mSocketSwClient = null;
+ if (mLiveLinkMicPkViewHolder != null) {
+ mLiveLinkMicPkViewHolder.release();
+ }
+ mLiveLinkMicPkViewHolder = null;
+ }
+
+ public void clearData() {
+ mIsApplyDialogShow = false;
+ mAcceptPk = false;
+ mIsPk = false;
+ mApplyUid = null;
+ mApplyStream = null;
+ mLiveUid = null;
+ mPkUid = null;
+ mPkWaitCount = 0;
+ mPkTimeCount = 0;
+ mIsPkEnd = false;
+ mPkSend = false;
+ mPkSendWaitCount = 0;
+ if (mHandler != null) {
+ mHandler.removeCallbacksAndMessages(null);
+ }
+ if (mLiveLinkMicPkViewHolder != null) {
+ mLiveLinkMicPkViewHolder.release();
+ mLiveLinkMicPkViewHolder.removeFromParent();
+ }
+ mLiveLinkMicPkViewHolder = null;
+ }
+
+ public void setSelfStream(String selfStream) {
+ mSelfStream = selfStream;
+ }
+
+ public void closeButtonGone() {
+ mLiveAnchorViewHolder.closeEndPkBt();
+ }
+
+ /**
+ * 更新Pk分数
+ */
+ public void upDataPkScore(JSONArray pkScores, String uid, int time,boolean isShowTimeTitle) {
+ this.pkScores = pkScores;
+
+ L.eSw("更新Pk分数 upDataPkScore time:" + time + " " + pkScores);
+ String userID1 = (String) imageGrade1.getTag();
+ String userID2 = (String) imageGrade2.getTag();
+ String userID4 = (String) imageGrade4.getTag();
+ if (livePushSwViewHolder.timeTitle.getVisibility() == View.GONE &&isShowTimeTitle) {
+ mHandler.removeMessages(WHAT_PK_TIME2);
+ RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) livePushSwViewHolder.timeTitle.getLayoutParams();
+ layoutParams.topMargin = DpUtil.dp2px(123);
+ livePushSwViewHolder.timeTitle.setLayoutParams(layoutParams);
+ livePushSwViewHolder.timeTitle.setVisibility(View.VISIBLE);
+ String pkTime = StringUtil.getDurationText(time * 1000);
+ livePushSwViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), pkTime));
+ mPkTimeCount = time;
+ if (time > 0) {
+ String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
+ livePushSwViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
+ mHandler.sendEmptyMessage(WHAT_PK_TIME2);
+ }
+ }
+ int pkScoreSize = pkScores.size();
+ if (pkScoreSize == 3) {
+ detailsLinearLayout1.setVisibility(View.VISIBLE);
+ detailsLinearLayout2.setVisibility(View.VISIBLE);
+ detailsLinearLayout4.setVisibility(View.VISIBLE);
+
+ linearGrade1.setVisibility(View.VISIBLE);
+ linearGrade2.setVisibility(View.VISIBLE);
+ linearGrade4.setVisibility(View.VISIBLE);
+ //拿到原始数据
+ for (int i = 0; i < pkScores.size(); i++) {
+ JSONObject score = pkScores.getJSONObject(i);
+ String userID = score.getString("id");
+ long userScore = score.getLong("score");
+ if (TextUtils.equals(userID, userID1)) {
+ textGrade1.setText(String.valueOf(userScore));
+ if (!score.containsKey("paiming")) {
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no1);
+ } else {
+ int ranking = score.getIntValue("paiming");
+ switch (ranking) {
+ case 1:
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no1);
+ break;
+ case 2:
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no2);
+ break;
+ case 3:
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no3);
+ break;
+ case 4:
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no4);
+ break;
+ }
+ }
+ } else if (TextUtils.equals(userID, userID2)) {
+ textGrade2.setText(String.valueOf(userScore));
+ if (!score.containsKey("paiming")) {
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no1);
+ } else {
+ int ranking = score.getIntValue("paiming");
+ switch (ranking) {
+ case 1:
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no1);
+ break;
+ case 2:
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no2);
+ break;
+ case 3:
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no3);
+ break;
+ case 4:
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no4);
+ break;
+ }
+ }
+ } else if (TextUtils.equals(userID, userID4)) {
+ textGrade4.setText(String.valueOf(userScore));
+ if (!score.containsKey("paiming")) {
+ imageGrade4.setImageResource(R.mipmap.icon_livepk_no1);
+ } else {
+ int ranking = score.getIntValue("paiming");
+ switch (ranking) {
+ case 1:
+ imageGrade4.setImageResource(R.mipmap.icon_livepk_no1);
+ break;
+ case 2:
+ imageGrade4.setImageResource(R.mipmap.icon_livepk_no2);
+ break;
+ case 3:
+ imageGrade4.setImageResource(R.mipmap.icon_livepk_no3);
+ break;
+ case 4:
+ imageGrade4.setImageResource(R.mipmap.icon_livepk_no4);
+ break;
+ }
+ }
+ }
+ }
+ } else if(pkScoreSize == 4){
+ String userID3 = (String) imageGrade3.getTag();
+
+ detailsLinearLayout1.setVisibility(View.VISIBLE);
+ detailsLinearLayout2.setVisibility(View.VISIBLE);
+ detailsLinearLayout3.setVisibility(View.VISIBLE);
+ detailsLinearLayout4.setVisibility(View.VISIBLE);
+
+ linearGrade1.setVisibility(View.VISIBLE);
+ linearGrade2.setVisibility(View.VISIBLE);
+ linearGrade3.setVisibility(View.VISIBLE);
+ linearGrade4.setVisibility(View.VISIBLE);
+ //拿到原始数据
+ for (int i = 0; i < pkScores.size(); i++) {
+ JSONObject score = pkScores.getJSONObject(i);
+ String userID = score.getString("id");
+ long userScore = score.getLong("score");
+ if (TextUtils.equals(userID, userID1)) {
+ textGrade1.setText(String.valueOf(userScore));
+ if (!score.containsKey("paiming")) {
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no1);
+ } else {
+ int ranking = score.getIntValue("paiming");
+ switch (ranking) {
+ case 1:
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no1);
+ break;
+ case 2:
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no2);
+ break;
+ case 3:
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no3);
+ break;
+ case 4:
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no4);
+ break;
+ }
+ }
+ } else if (TextUtils.equals(userID, userID2)) {
+ textGrade2.setText(String.valueOf(userScore));
+ if (!score.containsKey("paiming")) {
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no1);
+ } else {
+ int ranking = score.getIntValue("paiming");
+ switch (ranking) {
+ case 1:
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no1);
+ break;
+ case 2:
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no2);
+ break;
+ case 3:
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no3);
+ break;
+ case 4:
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no4);
+ break;
+ }
+ }
+ } else if (TextUtils.equals(userID, userID4)) {
+ textGrade4.setText(String.valueOf(userScore));
+ if (!score.containsKey("paiming")) {
+ imageGrade4.setImageResource(R.mipmap.icon_livepk_no1);
+ } else {
+ int ranking = score.getIntValue("paiming");
+ switch (ranking) {
+ case 1:
+ imageGrade4.setImageResource(R.mipmap.icon_livepk_no1);
+ break;
+ case 2:
+ imageGrade4.setImageResource(R.mipmap.icon_livepk_no2);
+ break;
+ case 3:
+ imageGrade4.setImageResource(R.mipmap.icon_livepk_no3);
+ break;
+ case 4:
+ imageGrade4.setImageResource(R.mipmap.icon_livepk_no4);
+ break;
+ }
+ }
+ } else if (TextUtils.equals(userID, userID3)) {
+ textGrade3.setText(String.valueOf(userScore));
+ if (!score.containsKey("paiming")) {
+ imageGrade3.setImageResource(R.mipmap.icon_livepk_no1);
+ } else {
+ int ranking = score.getIntValue("paiming");
+ switch (ranking) {
+ case 1:
+ imageGrade3.setImageResource(R.mipmap.icon_livepk_no1);
+ break;
+ case 2:
+ imageGrade3.setImageResource(R.mipmap.icon_livepk_no2);
+ break;
+ case 3:
+ imageGrade3.setImageResource(R.mipmap.icon_livepk_no3);
+ break;
+ case 4:
+ imageGrade3.setImageResource(R.mipmap.icon_livepk_no4);
+ break;
+ }
+ }
+ }
+
+ }
+ }else{
+ detailsLinearLayout1.setVisibility(View.VISIBLE);
+ detailsLinearLayout2.setVisibility(View.VISIBLE);
+
+ linearGrade1.setVisibility(View.VISIBLE);
+ linearGrade2.setVisibility(View.VISIBLE);
+ //拿到原始数据
+ for (int i = 0; i < pkScores.size(); i++) {
+ JSONObject score = pkScores.getJSONObject(i);
+ String userID = score.getString("id");
+ long userScore = score.getLong("score");
+ if (TextUtils.equals(userID, userID1)) {
+ textGrade1.setText(String.valueOf(userScore));
+ if (!score.containsKey("paiming")) {
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no1);
+ } else {
+ int ranking = score.getIntValue("paiming");
+ switch (ranking) {
+ case 1:
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no1);
+ break;
+ case 2:
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no2);
+ break;
+ case 3:
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no3);
+ break;
+ case 4:
+ imageGrade1.setImageResource(R.mipmap.icon_livepk_no4);
+ break;
+ }
+ }
+ } else if (TextUtils.equals(userID, userID2)) {
+ textGrade2.setText(String.valueOf(userScore));
+ if (!score.containsKey("paiming")) {
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no1);
+ } else {
+ int ranking = score.getIntValue("paiming");
+ switch (ranking) {
+ case 1:
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no1);
+ break;
+ case 2:
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no2);
+ break;
+ case 3:
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no3);
+ break;
+ case 4:
+ imageGrade2.setImageResource(R.mipmap.icon_livepk_no4);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+
+ /**
+ * PK倒计时
+ */
+ private void pkCountdownTimer() {
+
+ mPkTimeCount--;
+ if (mPkTimeCount > 0) {//
+ if (mHandler != null) {
+ String s1 = StringUtil.getDurationText(mPkTimeCount * 1000);
+ livePushSwViewHolder.textTime.setText(String.format(mContext.getString(R.string.pk_time), s1));
+ mHandler.sendEmptyMessageAtTime(WHAT_PK_TIME2, getNextSecondTime());
+ }
+ } else {
+ if(DRPKing!=-1){
+ mLiveAnchorViewHolder.showEndPkBt();
+ }
+ livePushSwViewHolder.timeTitle.setVisibility(View.GONE);
+ if (mHandler != null) {
+ mHandler.removeCallbacksAndMessages(null);
+ }
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT));
+// endDRGif();
+ if (DRInitiator) {
+ LiveNetManager.get(mContext).jieshuDRPK("" + IMLoginManager.get(mContext).getUserInfo().getId());
+ }
+ }
+ }
+
+
+}
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketClient.java b/live/src/main/java/com/yunbao/live/socket/SocketClient.java
index 4647f45d1..852ae096e 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketClient.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketClient.java
@@ -10,6 +10,7 @@ import android.widget.LinearLayout;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
import com.tencent.imsdk.v2.V2TIMCallback;
import com.tencent.imsdk.v2.V2TIMManager;
import com.yunbao.common.CommonAppConfig;
@@ -760,6 +761,7 @@ public class SocketClient {
*/
private static void processAnchorLinkMicPk(JSONObject map) {
int action = map.getIntValue("action");
+ L.eSw(new Gson().toJson(map));
switch (action) {
case 1://收到对方主播发起PK回调
UserBean u = new UserBean();
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketLinkMicPkUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketLinkMicPkUtil.java
index 8ec8ae0ca..867e0c7c1 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketLinkMicPkUtil.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketLinkMicPkUtil.java
@@ -66,7 +66,8 @@ public class SocketLinkMicPkUtil {
.param("uid", CommonAppConfig.getInstance().getUid())
.param("pkuid", CommonAppConfig.getInstance().getUid())
.param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
- .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
+ .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
+ .param("name", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
msg.create();
V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), pkUid, new V2TIMSendCallback() {
@Override
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketMessageListener.java b/live/src/main/java/com/yunbao/live/socket/SocketMessageListener.java
index e8cdb4451..98e54cd41 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketMessageListener.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketMessageListener.java
@@ -242,9 +242,13 @@ public interface SocketMessageListener {
//多人PK
void onLinkDRMicPkApply(UserBean u);
+ void onLinkDRMicPKToUser(UserBean u);
+
//接受多人PK
void onLinkDRMicPkApplyOk(UserBean u);
+ void onLinkDRMicPkQuit(String uid);
+
/**
* 主播与主播PK 所有人收到PK开始的回调
*/
@@ -255,6 +259,7 @@ public interface SocketMessageListener {
*/
void onLinkMicPkClose(int i);
+
/**
* 主播与主播PK 对方主播拒绝pk的回调
*/
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java
index 9e619c162..43d7438ef 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketRyChatUtil.java
@@ -35,7 +35,7 @@ import io.rong.message.TextMessage;
public class SocketRyChatUtil {
//关闭直播
- public static void closeLive(final String votes, final String length, final String nums, final String mLiveUid, SocketRyClient client) {
+ public static void closeLive(final String votes, final String length, final String nums, final String mLiveUid) {
UserBean u = CommonAppConfig.getInstance().getUserBean();
final SocketSendBean msg = new SocketSendBean()
.param("_method_", Constants.SOCKET_LIVE_END)
@@ -215,7 +215,6 @@ public class SocketRyChatUtil {
if (code == 0) {
EventBus.getDefault().post("stop_svga_new_user_double1");
}
-
}
});
if (SocketRyClient.mSocketHandler != null)
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
index 6237cff21..f6b19583b 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
@@ -95,12 +95,12 @@ public class SocketRyClient {
private final String TAG = "socket";
private String mLiveUid;
private String mStream;
- public static SocketRyClient.SocketHandler mSocketHandler;
+ public static SocketHandler mSocketHandler;
private Context mContext;
public SocketRyClient(String mLiveUid, SocketMessageListener listener, Activity mContext) {
this.mContext = mContext;
- mSocketHandler = new SocketRyClient.SocketHandler(listener);
+ mSocketHandler = new SocketHandler(listener);
mSocketHandler.setLiveUid(mLiveUid);
RongChatRoomClient.getInstance().joinChatRoom("g" + mLiveUid, -1, new IRongCoreCallback.OperationCallback() {
@Override
@@ -1395,7 +1395,7 @@ public class SocketRyClient {
private void processAnchorLinkMicPk(JSONObject map) {
int action = map.getIntValue("action");
Log.i("Socket", "action = " + action + " json = " + map.toString());
-
+ L.eSw("RY RY RY RY "+map.toString());
switch (action) {
case 1://收到对方主播PK回调
UserBean u = new UserBean();
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyLinkMicPkUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketRyLinkMicPkUtil.java
index 2e392ad05..c2a675d6c 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketRyLinkMicPkUtil.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketRyLinkMicPkUtil.java
@@ -8,7 +8,7 @@ import com.yunbao.common.bean.UserBean;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient;
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketSwChatUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketSwChatUtil.java
new file mode 100644
index 000000000..0efeb8a44
--- /dev/null
+++ b/live/src/main/java/com/yunbao/live/socket/SocketSwChatUtil.java
@@ -0,0 +1,793 @@
+package com.yunbao.live.socket;
+
+
+import android.util.Log;
+
+import com.yunbao.common.CommonAppConfig;
+import com.yunbao.common.CommonAppContext;
+import com.yunbao.common.Constants;
+import com.yunbao.common.bean.HttpCallbackModel;
+import com.yunbao.common.bean.IMLoginModel;
+import com.yunbao.common.bean.UserBean;
+import com.yunbao.common.http.HttpCallback;
+import com.yunbao.common.http.LiveHttpUtil;
+import com.yunbao.common.http.live.LiveNetManager;
+import com.yunbao.common.manager.IMLoginManager;
+import com.yunbao.common.utils.ToastUtil;
+import com.yunbao.common.utils.WordUtil;
+import com.yunbao.live.R;
+import com.yunbao.live.activity.LiveActivity;
+
+import org.greenrobot.eventbus.EventBus;
+
+import io.rong.imlib.IRongCallback;
+import io.rong.imlib.RongIMClient;
+import io.rong.imlib.model.Conversation;
+import io.rong.imlib.model.Message;
+import io.rong.message.TextMessage;
+
+/**
+ * Created by cxf on 2018/10/9.
+ * 直播间发言
+ */
+
+public class SocketSwChatUtil {
+
+ //关闭直播
+ public static void closeLive(final String votes, final String length, final String nums, final String mLiveUid) {
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_LIVE_END)
+ .param("action", 18)
+ .param("msgtype", 1)
+ .param("equipment", "app")
+ .param("uname", u.getUserNiceName())
+ .param("uid", u.getId())
+ .param("length", length)
+ .param("votes", votes)
+ .param("nums", nums)
+ .param("roomnum", u.getId())
+ .param("ct", "直播关闭");
+ 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) {
+ Log.i("tx", "发送成功");
+ if (SocketSwClient.mSocketHandler != null)
+ SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+
+ }
+
+ /**
+ * 发言
+ */
+ public static void sendChatMessage(String mLiveUid, String content, boolean isAnchor, int userType, int guardType, String atUserID, String atUserName) {
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ IMLoginModel model = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo();
+ if (u == null) {
+ return;
+ }
+
+ final SocketSendBean msg =
+ new SocketSendBean()
+ .param("_method_", Constants.SOCKET_SEND_MSG)
+ .param("action", 0)
+ .param("msgtype", 2)
+ .param("usertype", userType)
+ .param("isAnchor", isAnchor ? 1 : 0)
+ .param("level", u.getLevel())
+ .param("uname", u.getUserNiceName())
+ .param("bubble", u.getDress().getBubble())
+ .param("medal_honor", u.getMedal_no_display_src())
+ .param("medal", u.getDress().getMedal())
+ .param("medal_new", u.getDress().getMedal_new())
+ .param("uid", u.getId())
+ .param("liangname", u.getGoodName())
+ .param("vip_type", u.getVip().getType())
+ .param("guard_type", IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getGuardType())
+ .param("medal_name", u.getMedalName())
+ .param("medal_level", u.getMedalLevel())
+ .param("good_num", u.getGoodnum())
+ .param("ct", content)
+ .param("noble_id", String.valueOf(model.getNobleId()))
+ .param("contentColor", String.valueOf(model.getContentColor()))
+ .param("startColor", String.valueOf(model.getStartColor()))
+ .param("endColor", String.valueOf(model.getEndColor()))
+ .param("atUserName", String.valueOf(atUserName))
+ .param("atUserID", String.valueOf(atUserID));
+ 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 (SocketSwClient.mSocketHandler != null) {
+ SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ }
+ LiveNetManager.get(CommonAppContext.sInstance)
+ .addChatCount(LiveActivity.mStream, new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(HttpCallbackModel data) {
+
+ }
+
+ @Override
+ public void onError(String error) {
+
+ }
+ });
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+ Log.e("tx", "aaa" + errorCode.toString());
+ if (errorCode.code == 23408) {
+ ToastUtil.show(WordUtil.isNewZh() ? "您已被禁言" : "You have been banned");
+ } else {
+ ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" + errorCode.code : "I'm sorry! An error occurred:" + errorCode.code);
+ }
+ }
+ });
+
+ }
+
+ /**
+ * 点亮
+ */
+ public static void sendLightMessage(final String mLiveUid, int heart, int guardType) {
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_SEND_MSG)
+ .param("action", 0)
+ .param("msgtype", 2)
+ .param("level", u.getLevel())
+ .param("uname", u.getUserNiceName())
+ .param("uid", u.getId())
+ .param("liangname", u.getGoodName())
+ .param("vip_type", u.getVip().getType())
+ .param("medal_honor", u.getMedal_no_display_src())
+ .param("heart", heart)
+ .param("bubble", u.getDress().getBubble())
+ .param("medal", u.getDress().getMedal())
+ .param("medal_new", u.getDress().getMedal_new())
+ .param("guard_type", IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getGuardType())
+ .param("medal_name", u.getMedalName())
+ .param("medal_level", u.getMedalLevel())
+ .param("good_num", u.getGoodnum())
+ .param("ct", WordUtil.getNewString(R.string.live_lighted));
+ 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) {
+ Log.i("tx", "发送成功");
+ LiveHttpUtil.sendZAN(mLiveUid + "", new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ EventBus.getDefault().post("stop_svga_new_user_double");
+ }
+ });
+
+ LiveHttpUtil.setFrontTask("illumine", new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0) {
+ EventBus.getDefault().post("stop_svga_new_user_double1");
+ }
+ }
+ });
+ if (SocketSwClient.mSocketHandler != null)
+ SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+ }
+
+
+ /**
+ * 发送弹幕消息
+ */
+ public static void sendDanmuMessage(String mLiveUid, String danmuToken) {
+ sendDanmuMessage(mLiveUid, danmuToken, 0);
+ }
+
+ public static void sendDanmuMessage(String mLiveUid, String danmuToken, int fansLevel) {
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_SEND_BARRAGE)
+ .param("action", 7)
+ .param("msgtype", 1)
+ .param("level", u.getLevel())
+ .param("uname", u.getUserNiceName())
+ .param("uid", u.getId())
+ .param("uhead", u.getAvatar())
+ .param("fansLevel", fansLevel)
+ .param("ct", danmuToken);
+ 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) {
+ Log.i("tx", "发送成功");
+ if (SocketSwClient.mSocketHandler != null) {
+ SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ }
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+ Log.e("tx", "aaa" + errorCode.toString());
+ if (errorCode.code == 23408) {
+ ToastUtil.show(WordUtil.isNewZh() ? "您已被禁言" : "You have been banned");
+ } else {
+ ToastUtil.show(errorCode.code + ":" + errorCode.msg);
+ }
+ }
+ });
+
+ }
+
+
+ /**
+ * 发送礼物消息
+ */
+ public static void sendGiftMessage(int giftType, String giftToken, String liveUid, int guard_type, String by) {
+
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_SEND_GIFT)
+ .param("action", 0)
+ .param("msgtype", 1)
+ .param("level", u.getLevel())
+ .param("uname", u.getUserNiceName())
+ .param("uid", u.getId())
+ .param("uhead", u.getAvatar())
+ .param("evensend", giftType)
+ .param("liangname", u.getGoodName())
+ .param("vip_type", u.getVip().getType())
+ .param("ct", giftToken)
+ .param("bubble", u.getDress().getBubble())
+ .param("medal", u.getDress().getMedal())
+ .param("medal_new", u.getDress().getMedal_new())
+ .param("medal_name", u.getMedalName())
+ .param("medal_level", u.getMedalLevel())
+ .param("guard_type", guard_type + "")
+ .param("medal_honor", u.getMedal_no_display_src())
+ .param("good_num", u.getGoodnum())
+ .param("roomnum", liveUid);
+
+ msg.create();
+ LiveHttpUtil.sendGiftMsg(by, liveUid, msg.mResult.toString(), new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ Log.i("tag", "禮物im");
+ }
+ });
+
+ }
+
+ /**
+ * 发送礼物消息 增加主播名字
+ */
+ public static void sendGiftMessage(int giftType, String giftToken, String liveUid, String ancherName, int guard_type, String by) {
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_SEND_GIFT)
+ .param("action", 0)
+ .param("msgtype", 1)
+ .param("level", u.getLevel())
+ .param("uname", u.getUserNiceName())
+ .param("uid", u.getId())
+ .param("uhead", u.getAvatar())
+ .param("evensend", giftType)
+ .param("liangname", u.getGoodName())
+ .param("vip_type", u.getVip().getType())
+ .param("bubble", u.getDress().getBubble())
+ .param("medal", u.getDress().getMedal())
+ .param("medal_new", u.getDress().getMedal_new())
+ .param("ct", giftToken)
+ .param("ancherName", ancherName)
+ .param("medal_name", u.getMedalName())
+ .param("medal_level", u.getMedalLevel())
+ .param("guard_type", guard_type + "")
+ .param("medal_honor", u.getMedal_no_display_src())
+ .param("good_num", u.getGoodnum())
+ .param("roomnum", liveUid);
+
+ msg.create();
+
+ LiveHttpUtil.sendGiftMsg(by, liveUid, msg.mResult.toString(), new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ Log.i("tag", "禮物im");
+ }
+ });
+
+ }
+
+ /**
+ * 主播或管理员 踢人
+ */
+ public static void sendKickMessage(String mLiveUid, String toUid, String toName) {
+
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_KICK)
+ .param("action", 2)
+ .param("msgtype", 4)
+ .param("level", u.getLevel())
+ .param("uname", u.getUserNiceName())
+ .param("uid", u.getId())
+ .param("touid", toUid)
+ .param("toname", toName)
+ .param("ct", toName + "被踢出房間(Kicked out of the room)");
+ 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) {
+ Log.i("tx", "发送成功");
+ if (SocketSwClient.mSocketHandler != null) {
+ SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ }
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+ }
+
+
+ /**
+ * 主播或管理员 禁言
+ */
+ public static void sendShutUpMessage(String mLiveUid, String toUid, String toName, int type) {
+ sendShutUpMessage(mLiveUid, toUid, toName, type, 0);
+ }
+
+ /**
+ * 主播或管理员 禁言
+ *
+ * @param time 禁言时间 1~60
+ */
+ public static void sendShutUpMessage(String mLiveUid, String toUid, String toName, int type, int time) {
+
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+ String ct = "";
+ switch (type) {
+ case 0:
+ ct = "被永久禁言(Forbidden forever)";
+ break;
+ case 1:
+ ct = "被本場禁言(Forbidden by this scene)";
+ break;
+ case 2:
+ ct = String.format("被禁言%s分鐘", time + "") + "(" + String.format("Forbidden by %s min", time + "") + ")";
+ break;
+ }
+
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_SHUT_UP)
+ .param("action", 1)
+ .param("msgtype", 4)
+ .param("level", u.getLevel())
+ .param("uname", u.getUserNiceName())
+ .param("uid", u.getId())
+ .param("touid", toUid)
+ .param("toname", toName)
+ .param("time", time)
+ .param("ct", toName + ct);
+ 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) {
+ Log.i("tx", "发送成功");
+ if (SocketSwClient.mSocketHandler != null) {
+ SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ }
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+
+ }
+
+ /**
+ * 设置或取消管理员消息
+ */
+ public static void sendSetAdminMessage(String mLiveUid, int action, String toUid, String toName) {
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+ String s = action == 1 ? "被設為管理員(Set as Administrator)" : "被取消管理員(Cancelled administrator)";
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_SET_ADMIN)
+ .param("action", action)
+ .param("msgtype", 1)
+ .param("uname", u.getUserNiceName())
+ .param("uid", u.getId())
+ .param("touid", toUid)
+ .param("toname", toName)
+ .param("ct", toName + " " + s);
+
+ 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) {
+ Log.i("tx", "发送成功");
+ if (SocketSwClient.mSocketHandler != null) {
+ SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ }
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+
+ }
+
+ /**
+ * 超管关闭直播间
+ */
+ public static void superCloseRoom(String mLiveUid) {
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_STOP_LIVE)
+ .param("action", 19)
+ .param("msgtype", 1)
+ .param("ct", "");
+ 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) {
+ Log.i("tx", "发送成功");
+ if (SocketSwClient.mSocketHandler != null) {
+ SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ }
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+ }
+
+ /**
+ * 发系统消息
+ */
+ public static void sendSystemMessage(String mLiveUid, String content) {
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_SYSTEM)
+ .param("action", 13)
+ .param("msgtype", 4)
+ .param("level", u.getLevel())
+ .param("uname", u.getUserNiceName())
+ .param("uid", u.getId())
+ .param("ct", content);
+ 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) {
+ Log.i("tx", "发送成功");
+ if (SocketSwClient.mSocketHandler != null)
+ SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+ }
+
+
+ /**
+ * 获取僵尸粉
+ */
+ public static void getFakeFans(String mLiveUid) {
+
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_FAKE_FANS)
+ .param("action", "")
+ .param("msgtype", "");
+
+ 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) {
+ Log.i("tx", "发送成功");
+ if (SocketSwClient.mSocketHandler != null) {
+ SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ }
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+ }
+
+
+ /**
+ * 更新主播映票数
+ */
+ public static void sendUpdateVotesMessage(String mLiveUid, int votes, int first) {
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_UPDATE_VOTES)
+ .param("action", 1)
+ .param("msgtype", 26)
+ .param("votes", votes)
+ .param("uid", CommonAppConfig.getInstance().getUid())
+ .param("isfirst", first)
+ .param("ct", "");
+ 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) {
+ Log.i("tx", "发送成功");
+ if (SocketSwClient.mSocketHandler != null) {
+ SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ }
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+
+ }
+
+ /**
+ * 更新主播映票数
+ */
+ public static void sendUpdateVotesMessage(String mLiveUid, int votes) {
+ sendUpdateVotesMessage(mLiveUid, votes, 0);
+ }
+
+ /**
+ * 发送购买守护成功消息
+ */
+ public static void sendBuyGuardMessage(String mLiveUid, String votes, int guardNum, int guardType) {
+
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_BUY_GUARD)
+ .param("action", 0)
+ .param("msgtype", 0)
+ .param("uid", u.getId())
+ .param("bubble", u.getDress().getBubble())
+ .param("medal", u.getDress().getMedal())
+ .param("medal_new", u.getDress().getMedal_new())
+ .param("uname", u.getUserNiceName())
+ .param("uhead", u.getAvatar())
+ .param("votestotal", votes)
+ .param("guard_nums", guardNum)
+ .param("guard_type", IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getGuardType());
+ msg.create();
+
+ }
+
+ public static void sendBuyGuardMessage2(String mLiveUid, String votes, int guardNum,
+ int guardType, String ancherName, String liveId) {
+
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_BUY_GUARD)
+ .param("action", 0)
+ .param("msgtype", 0)
+ .param("uid", u.getId())
+ .param("uname", u.getUserNiceName())
+ .param("uhead", u.getAvatar())
+ .param("votestotal", votes)
+ .param("guard_nums", guardNum)
+ .param("ancherName", ancherName)
+ .param("liveuid", liveId)
+ .param("bubble", u.getDress().getBubble())
+ .param("medal", u.getDress().getMedal())
+ .param("medal_new", u.getDress().getMedal_new())
+ .param("guard_type", IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getGuardType());
+ msg.create();
+
+ }
+
+ /**
+ * 发送发红包成功消息
+ */
+ public static void sendRedPackMessage(String mLiveUid) {
+
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_RED_PACK)
+ .param("action", 0)
+ .param("msgtype", 0)
+ .param("uid", u.getId())
+ .param("uname", u.getUserNiceName())
+ .param("ct", CommonAppContext.sInstance.getBaseContext().getString(R.string.red_pack_22)
+ );
+ 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) {
+ Log.i("tx", "发送成功");
+ if (SocketSwClient.mSocketHandler != null) {
+ SocketSwClient.mSocketHandler.processBroadcast(msg.mResult.toString() + "");
+ }
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+ }
+
+}
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java
new file mode 100644
index 000000000..16f6c2eb1
--- /dev/null
+++ b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java
@@ -0,0 +1,1410 @@
+package com.yunbao.live.socket;
+
+import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK;
+import static com.yunbao.common.Constants.SOCKET_LIVE_MSG_TO_USER;
+import static com.yunbao.live.activity.LiveSwAnchorActivity.isDRPK;
+import static com.yunbao.live.activity.LiveSwAnchorActivity.DRPKing;
+import static com.yunbao.live.views.LiveRoomViewHolder.getIsHot;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.View;
+import android.widget.LinearLayout;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.blankj.utilcode.util.GsonUtils;
+import com.google.gson.Gson;
+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.FansModel;
+import com.yunbao.common.bean.GuardMaturityDateRemindModel;
+import com.yunbao.common.bean.LinkMicUserBean;
+import com.yunbao.common.bean.LiveInfoModel;
+import com.yunbao.common.bean.LiveUserGiftBean;
+import com.yunbao.common.bean.MsgModel;
+import com.yunbao.common.bean.PkRankBean;
+import com.yunbao.common.bean.RedPacketInfoModel;
+import com.yunbao.common.bean.RedPacketModel;
+import com.yunbao.common.bean.SendMoneyLongModel;
+import com.yunbao.common.bean.SocketModel;
+import com.yunbao.common.bean.SudGameDateModel;
+import com.yunbao.common.bean.UserBean;
+import com.yunbao.common.bean.WishModel;
+import com.yunbao.common.bean.XydCompleteModel;
+import com.yunbao.common.event.AllServerNotifyEvent;
+import com.yunbao.common.event.AllServerNotifyFFGGGDJANEvent;
+import com.yunbao.common.event.CustomFullServiceNotifyEvent;
+import com.yunbao.common.event.GiftWallIlluminateEvent;
+import com.yunbao.common.event.QuickGiftingEvent;
+import com.yunbao.common.event.SendBlindGiftEvent;
+import com.yunbao.common.event.SendMoneyLongEndEvent;
+import com.yunbao.common.http.HttpCallback;
+import com.yunbao.common.http.HttpClient;
+import com.yunbao.common.http.live.LiveNetManager;
+import com.yunbao.common.manager.MicUserManager;
+import com.yunbao.common.manager.MicedUserManager;
+import com.yunbao.common.manager.NewLevelManager;
+import com.yunbao.common.manager.RandomPkManager;
+import com.yunbao.common.utils.Bus;
+import com.yunbao.common.utils.L;
+import com.yunbao.common.utils.StringUtil;
+import com.yunbao.common.utils.ToastUtil;
+import com.yunbao.common.utils.WordUtil;
+import com.yunbao.live.R;
+import com.yunbao.live.activity.LiveAudienceActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
+import com.yunbao.live.adapter.LiveChatAdapter;
+import com.yunbao.live.bean.LiveBuyGuardMsgBean;
+import com.yunbao.live.bean.LiveChatBean;
+import com.yunbao.live.bean.LiveDanMuBean;
+import com.yunbao.live.bean.LiveEnterRoomBean;
+import com.yunbao.live.bean.LiveGiftPrizePoolWinBean;
+import com.yunbao.live.bean.LiveLuckGiftWinBean;
+import com.yunbao.live.bean.LivePKUserListBean;
+import com.yunbao.live.bean.LiveReceiveGiftBean;
+import com.yunbao.live.bean.NewAllServerNotifyGuardEvent;
+import com.yunbao.live.bean.SendQuickGiftModel;
+import com.yunbao.live.event.LiveAnchorEvent;
+import com.yunbao.live.event.LiveAudienceEvent;
+import com.yunbao.live.views.LiveEndViewHolder;
+import com.yunbao.live.views.LivePlayKsyViewHolder;
+import com.yunbao.live.views.LivePlaySwViewHolder;
+import com.yunbao.live.views.LivePushSwViewHolder;
+import com.yunbao.live.views.LiveRoomViewHolder;
+
+import org.greenrobot.eventbus.EventBus;
+
+import java.lang.ref.WeakReference;
+import java.util.List;
+
+import io.agora.beautyapi.faceunity.agora.SWManager;
+import io.rong.imlib.IRongCallback;
+import io.rong.imlib.IRongCoreCallback;
+import io.rong.imlib.IRongCoreEnum;
+import io.rong.imlib.RongIMClient;
+import io.rong.imlib.chatroom.base.RongChatRoomClient;
+import io.rong.imlib.model.Conversation;
+import io.rong.message.TextMessage;
+
+public class SocketSwClient {
+
+ private final String TAG = "socket";
+ private String mLiveUid;
+ private String mStream;
+ public static SocketSwClient.SocketHandler mSocketHandler;
+ private Context mContext;
+
+ public SocketSwClient(String mLiveUid, SocketMessageListener listener, Activity mContext) {
+ this.mContext = mContext;
+ mSocketHandler = new SocketSwClient.SocketHandler(listener);
+ mSocketHandler.setLiveUid(mLiveUid);
+ RongChatRoomClient.getInstance().joinChatRoom("g" + mLiveUid, -1, new IRongCoreCallback.OperationCallback() {
+ @Override
+ public void onSuccess() {
+ Log.i("tx", "加入成功");
+
+ }
+
+ @Override
+ public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
+ Log.i("tx", "加入" + "失败" + coreErrorCode);
+ if (WordUtil.isNewZh()) {
+ ToastUtil.show("網絡不佳無法連接,請重新進入");
+ } else {
+ ToastUtil.show("The network is not connected, please re-enter");
+ }
+ }
+ });
+ }
+
+ public void setLivePushSwViewHolder(LivePushSwViewHolder livePushSwViewHolder) {
+ if (mSocketHandler != null) {
+ mSocketHandler.setLivePushSwViewHolder(livePushSwViewHolder);
+ }
+ }
+
+ public void disConnect() {
+// V2TIMManager.getInstance().
+ mLiveUid = null;
+ mStream = null;
+ mSocketHandler = null;
+ }
+
+ public class SocketHandler extends Handler {
+
+ private SocketMessageListener mListener;
+ private LivePushSwViewHolder livePushSwViewHolder;
+ private String mLiveUid;
+
+ public SocketHandler(SocketMessageListener listener) {
+ mListener = new WeakReference<>(listener).get();
+ }
+
+ public void setLiveUid(String liveUid) {
+ mLiveUid = liveUid;
+ }
+
+ public void setLivePushSwViewHolder(LivePushSwViewHolder livePushSwViewHolder) {
+ this.livePushSwViewHolder = livePushSwViewHolder;
+ }
+
+ @Override
+ public void handleMessage(Message msg) {
+ if (mListener == null) {
+ return;
+ }
+ try {
+ switch (msg.what) {
+ case Constants.SOCKET_WHAT_CONN:
+ mListener.onConnect((Boolean) msg.obj);
+ break;
+ case Constants.SOCKET_WHAT_BROADCAST:
+ processBroadcast((String) msg.obj);
+ break;
+ case Constants.SOCKET_WHAT_DISCONN:
+ mListener.onDisConnect();
+ break;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+
+ public void processBroadcast(String socketMsg) {
+ L.e("收到socket--->" + socketMsg);
+
+ Log.i("SocketRyClient", "socketMsg" + socketMsg);
+
+ if (Constants.SOCKET_STOP_PLAY.equals(socketMsg)) {
+ mListener.onSuperCloseLive();//超管关闭房间
+ return;
+ }
+ if (socketMsg.contains("LivePK_UnreadCount")) {
+ return;
+ }
+ SocketReceiveBean received = JSON.parseObject(socketMsg, SocketReceiveBean.class);
+
+ JSONObject map = received.getMsg().getJSONObject(0);
+
+ switch (map.getString("_method_")) {
+ //用户连麦
+ case Constants.LIAN_MAI:
+ int actions = map.getIntValue("action");
+ L.eSw("用户连麦:actions" + actions);
+ //主播邀请用户连麦消息
+ if (actions == 1) {
+ EventBus.getDefault().post("inviteMic");
+ //主播同意用户连麦申请
+ } else if (actions == 4) {
+ EventBus.getDefault().post("UsertoRY");
+ } else if (actions == 5) {
+ JSONObject mic_data = map.getJSONObject("ct");
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_MIC_LIST).setObject(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class)));
+ MicedUserManager.get().upDataMicUserList(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class));
+ } else if (actions == 6) {
+ if (WordUtil.isNewZh()) {
+ ToastUtil.show("主播已關閉當前語音連麥功能");
+ } else {
+ ToastUtil.show("The host has disabled the voice connection function");
+ }
+ EventBus.getDefault().post("endMic");
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CLOSE).setObject(map.toJavaObject(LinkMicUserBean.class)));
+ } else if (actions == 8) {
+ //提下買,退出
+ if (WordUtil.isNewZh()) {
+ ToastUtil.show("您已被移出多人語音連麥");
+ } else {
+ ToastUtil.show("You have been removed from Multi-Voice Connection");
+ }
+ EventBus.getDefault().post("endMic");
+ } else if (actions == 3) {
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC).setObject(map.toJavaObject(LinkMicUserBean.class)));
+ MicUserManager.get().upDataMicUser(map);
+ } else if (actions == 7) {//取消连麦
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CANCEL));
+ MicUserManager.get().removeMiscUser(map);
+ }
+ break;
+ case Constants.UP_USER_LIST:
+ mListener.onUpUserList(map.getJSONObject("ct"));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_UPDATE_AUDIENCE_LIST).setObject(JSON.parseArray(map.getJSONObject("ct").getString("userlist"), LiveUserGiftBean.class)));
+ break;
+ case Constants.CARD:
+// LiveLinkMicPresenter.setHD(map.getString("ct"));
+ break;
+ case Constants.SOCKET_SYSTEM://系统消息
+ if (map.getString("ct").contains("甜蜜不停")) {
+ break;
+ }
+ UserBean us = CommonAppConfig.getInstance().getUserBean();
+ if (map.getString("uid") != null && us != null && map.getString("uid").equals(us.getId())) {
+ int num = LiveAudienceActivity.fansNum + 1;
+ LiveRoomViewHolder.setFansNum(num);
+ }
+ if (map.getString("ct").contains("堅決維護青少年群體精神文明健康") || map.getString("ct").contains("click to register if you like. pdlive conducts")) {
+ systemChatMessage(map.getString("ct"));
+ } else {
+ if (!WordUtil.isNewZh() && map.getString("ct").contains("退出比賽") && map.getString("ct").contains("獲得勝利")) {
+ String ctTmp = map.getString("ct");
+ ctTmp = ctTmp.replace("由於", "Due to").replace("退出比賽", "withdrawing from the competition").replace("獲得勝利", "won");
+ map.put("ct", ctTmp);
+ }
+ systemChatMessage2(map.getString("ct"));
+ }
+
+ int action21 = map.getIntValue("action");
+ //主播離開
+ if (action21 == 13 && map.getString("ct").contains("離開")) {
+ if (LivePlayKsyViewHolder.leave != null) {
+ LivePlayKsyViewHolder.leave.setVisibility(View.VISIBLE);
+ }
+ if (LivePlaySwViewHolder.leave != null) {
+ LivePlaySwViewHolder.leave.setVisibility(View.VISIBLE);
+ }
+ } else if (action21 == 13 && map.getString("ct").contains("回來")) {
+ if (LivePlayKsyViewHolder.leave != null) {
+ LivePlayKsyViewHolder.leave.setVisibility(View.GONE);
+ }
+ if (LivePlaySwViewHolder.leave != null) {
+ LivePlaySwViewHolder.leave.setVisibility(View.GONE);
+ }
+ }
+ break;
+ case Constants.SOCKET_KICK://踢人
+ systemChatMessage2(map.getString("ct"));
+ mListener.onKick(map.getString("touid"));
+ break;
+ case Constants.SOCKET_SHUT_UP://禁言
+ String ct = map.getString("ct");
+ systemChatMessage2(ct);
+ mListener.onShutUp(map.getString("touid"), ct);
+ break;
+ case Constants.SOCKET_SEND_MSG://文字消息,点亮,用户进房间,这种混乱的设计是因为服务器端逻辑就是这样设计的,客户端无法自行修改
+ wordLightEnterRoom(map, received);
+ L.e("收到socket---> 文字消息" + socketMsg);
+ break;
+ case Constants.SOCKET_LIGHT://飘心
+ mListener.onLight();
+ break;
+ case Constants.SOCKET_SEND_GIFT://送礼物
+ sendGiftInSameRoom(map);
+ break;
+
+// case Constants.SOCKET_SEND_GIFT://送礼物
+// ////////pk
+// break;
+ case Constants.SOCKET_LIVE_DRPK_RANDOM:
+ case Constants.SOCKET_LIVE_DRPK://多人PK
+ L.eSw("map" + new Gson().toJson(map));
+ int action3 = map.getIntValue("action");
+ //收到多人PK邀请
+ if (action3 == 1) {
+ UserBean u = new UserBean();
+ u.setUserNiceName(map.getString("uname"));
+ u.setId(map.getString("uid"));
+ mListener.onLinkDRMicPkApply(u);
+ } else if (action3 == 2) {
+ //收到对方同意多人PK邀请
+ UserBean u = new UserBean();
+// u.setUserNiceName(map.getString("uname"));
+ u.setId(map.getString("pkuid"));
+ L.eSw("action3 == 2:" + u.getId());
+ L.eSw("收到对方同意多人PK邀请");
+ DRPKing = 0;
+ mListener.onLinkDRMicPkApplyOk(u);
+ } else if (action3 == 6) {//开始Pk
+ if (LiveRoomViewHolder.mHandler != null) {
+ LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
+ }
+// LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, map.getIntValue("drpk_time"));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LEAVE_PK_SCORE).setPkScores(map.getJSONArray("userlist")).setUid(mLiveUid).setTime(map.getIntValue("drpk_time")));
+ if (livePushSwViewHolder == null) {
+ // LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW));
+ }
+ DRPKing = 1;
+ } else if (action3 == 5) {//结束PK
+// endDRGif();
+ LiveRoomViewHolder.d_pk_view.setVisibility(View.GONE);
+ if (LiveSwAnchorActivity.mLiveAnchorViewHolder != null) {
+ LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
+ params.topMargin = 0;
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LEAVE_DR_ROOM));
+ isDRPK = 0;
+ } else {
+ // LiveAudienceActivity.getmLivePlayViewHolder().setPkEndview();
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_END_VIEW));
+ }
+ SWManager.get().setDrPkNumClarity(1);//退出直播间,将分别率设置为 VD_840x480
+ //創建了多人房間
+ } else if (action3 == 3) {
+ L.eSw("創建了多人房間action3 == 3");
+ /* if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
+ LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
+ }*/
+ isDRPK = 1;
+ DRPKing = 0;
+ if (livePushSwViewHolder == null) {
+ if ("4".equals(map.getString("msgtype"))) {
+ return;
+ }
+ UserBean u = new UserBean();
+// u.setUserNiceName(map.getString("uname"));
+ u.setId(map.getString("uid"));
+ if (StringUtil.isEmpty(u.getId())) {
+ return;
+ }
+ L.eSw("通知用户 action3 == 3:" + u.getId());
+ mListener.onLinkDRMicPKToUser(u);
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW));
+ }
+ } else if (action3 == 10) {
+ //显示pk分数
+ if (!map.getString("uid").equals(CommonAppConfig.getInstance().getUid())) {
+ // LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SOCKET_LIVE_DRPK_SET_PK_VIEW));
+ }
+ } else if (action3 == 7) {
+ L.eSw("主播退出直播間:"+map.getString("uid"));
+ mListener.onLinkDRMicPkQuit(map.getString("uid"));
+ //清除已邀请人数
+ if(LiveSwAnchorActivity.mLiveAnchorViewHolder!=null){
+ LiveSwAnchorActivity.mLiveAnchorViewHolder.removeYaoqing(map.getString("uid"));
+ }
+ }
+
+ break;
+ case Constants.SOCKET_ALL_SERVER_NOTIFY://全服通知
+ int action2 = map.getIntValue("action");
+ if (action2 == 71) {
+ LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
+ receiveGiftBean.setVipName(map.getString("ct"));
+ receiveGiftBean.setSendtype(map.getIntValue("action"));
+ receiveGiftBean.setAllServerNotify(true);
+ mListener.onSys(receiveGiftBean);
+ } else if (action2 == 61) {//赠送礼物
+ sendGiftByNotify(map);
+ } else if (action2 == 62) {//购买守护
+// buyGuardByNotify(map);
+// }else if (action2 == 63){
+ } else if (action2 == 63) {//购买vip
+ buyVipByNotify(map);
+ } else if (action2 == 64) {//购买靓号
+ buyLiangNameByNotify(map);
+ } else if (action2 == 65) {//购买坐骑
+ buyZuoJiByNotify(map);
+ } else if (action2 == 66) {//购买贵族
+ buyVipByNotify(map);
+ } else if (action2 == 88) {
+ JSONObject mCt = map.getJSONObject("ct");
+ String boxType = map.getString("box_type");
+ String boxTypeName = "";
+ if (TextUtils.equals(boxType, "1")) {
+ boxTypeName = WordUtil.isNewZh() ? "迷你盲盒" : "Mini blind box";
+ } else if (TextUtils.equals(boxType, "2")) {
+ boxTypeName = WordUtil.isNewZh() ? "典藏盲盒" : "Collection blind box";
+ } else {
+ boxTypeName = WordUtil.isNewZh() ? "PD盲盒" : "PD blind box";
+ }
+ AllServerNotifyEvent allServerNotifyEvent = new AllServerNotifyEvent().setBlindBoxId(map.getString("blind_box_id")).setBoxType(boxType).setBoxTypeName(boxTypeName).setDressName(WordUtil.isNewZh() ? map.getString("dress_name") : TextUtils.isEmpty(map.getString("dress_nameen")) ? map.getString("dress_name") : map.getString("dress_nameen")).setGiftNotification(map.getString("gift_notification")).setGiftName(WordUtil.isNewZh() ? mCt.getString("giftname") : mCt.getString("giftnameen")).setUserNiceName(map.getString("uname")).setGiftIcon(map.getString("gifticon")).setAnchorName(map.getString("ancherName")).setDisplaySrc(map.getString("display_src"));
+ Log.e("AllServerNotifyEvent", allServerNotifyEvent.toString());
+ Log.e("AllServerNotifyEvent", map.toJSONString());
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.BLIND_BOX).setAllServerNotifyEvent(allServerNotifyEvent));
+ } else if (action2 == 89) {//红包
+ JSONObject mCt = map.getJSONObject("ct");
+ AllServerNotifyEvent allServerNotifyEvent = new AllServerNotifyEvent().setUserNiceName(mCt.getString("user_nicename")).setGiftName(WordUtil.isNewZh() ? map.getString("giftname") : map.getString("giftname_en")).setGiftIcon(mCt.getString("gifticon")).setRedPacket(true);
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.BLIND_BOX).setAllServerNotifyEvent(allServerNotifyEvent));
+ } else if (action2 == 90) {
+ NewAllServerNotifyGuardEvent notifyGuardEvent = GsonUtils.fromJson(map.toString(), NewAllServerNotifyGuardEvent.class);
+ Bus.get().post(notifyGuardEvent);
+ buyGuardInSameRoom(map);
+ } else if (action2 == 91) {
+ AllServerNotifyFFGGGDJANEvent notifyFFGGGDJANEvent = GsonUtils.fromJson(map.toString(), AllServerNotifyFFGGGDJANEvent.class);
+ Bus.get().post(notifyFFGGGDJANEvent);
+ }
+ break;
+ case Constants.SOCKET_SEND_BARRAGE://发弹幕
+ LiveDanMuBean liveDanMuBean2 = new LiveDanMuBean();
+ liveDanMuBean2.setAvatar(map.getString("uhead"));
+ liveDanMuBean2.setUserNiceName(map.getString("uname"));
+ liveDanMuBean2.setContent(map.getString("ct"));
+ if (map.containsKey("fansLevel")) {
+ liveDanMuBean2.setFensLevel(map.getInteger("fansLevel"));
+ }
+ mListener.onSendDanMu(liveDanMuBean2);
+ break;
+ case Constants.SOCKET_LEAVE_ROOM://离开房间
+ UserBean u = JSON.parseObject(map.getString("ct"), UserBean.class);
+ mListener.onLeaveRoom(u);
+ break;
+ case Constants.SOCKET_LIVE_END://主播关闭直播
+ int action = map.getIntValue("action");
+ if (action == 18) {
+ mListener.onLiveEnd();
+ LiveEndViewHolder.upData(map.getString("votes"), map.getString("length"), map.getIntValue("nums"), map.getString("uname"));
+ } else if (action == 19) {
+ mListener.onAnchorInvalid();
+ }
+ //主播强制下播
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIVE_END).setVotes(map.getString("votes")).setLength(map.getString("length")).setNums(map.getIntValue("nums")).setUname(map.getString("uname")));
+ break;
+ case Constants.SOCKET_CHANGE_LIVE://主播切换计时收费类型
+ mListener.onChangeTimeCharge(map.getIntValue("type_val"));
+ break;
+ case Constants.SOCKET_UPDATE_VOTES:
+ mListener.onUpdateVotes(map.getString("uid"), map.getString("votes"), map.getIntValue("isfirst"));
+ break;
+ case Constants.SOCKET_FAKE_FANS:
+ JSONObject obj = map.getJSONObject("ct");
+ String s = obj.getJSONObject("data").getJSONArray("info").getJSONObject(0).getString("list");
+ L.e("僵尸粉--->" + s);
+ List list = JSON.parseArray(s, LiveUserGiftBean.class);
+ mListener.addFakeFans(list);
+ break;
+ case Constants.SOCKET_SET_ADMIN://设置或取消管理员
+ systemChatMessage2(map.getString("ct"));
+ mListener.onSetAdmin(map.getString("touid"), map.getIntValue("action"));
+ break;
+ case Constants.SUPER_VISION://设置或取消管理员
+ systemChatMessage2(map.getString("ct"));
+ break;
+ case Constants.SOCKET_BUY_GUARD://购买守护
+ buyGuardInSameRoom(map);
+ break;
+ case Constants.SOCKET_LINK_MIC://连麦-old
+ processLinkMic(map);
+ break;
+ case Constants.SOCKET_LINK_MIC_ANCHOR://主播连麦
+ processLinkMicAnchor(map);
+ break;
+ case Constants.SOCKET_LINK_MIC_PK://主播PK
+ processAnchorLinkMicPk(map);
+ break;
+ case Constants.SOCKET_RED_PACK://红包消息
+ String uid = map.getString("uid");
+ if (TextUtils.isEmpty(uid)) {
+ return;
+ }
+ LiveChatBean liveChatBean = new LiveChatBean();
+ liveChatBean.setType(LiveChatBean.RED_PACK);
+ liveChatBean.setId(uid);
+ String name = uid.equals(mLiveUid) ? mContext.getString(R.string.live_anchor) : map.getString("uname");
+ liveChatBean.setContent(name + map.getString("ct"));
+ mListener.onRedPack(liveChatBean);
+ break;
+
+ case Constants.SOCKET_LUCK_WIN://幸运礼物中奖
+ mListener.onLuckGiftWin(map.toJavaObject(LiveLuckGiftWinBean.class));
+ break;
+
+ case Constants.SOCKET_PRIZE_POOL_WIN://奖池中奖
+ mListener.onPrizePoolWin(map.toJavaObject(LiveGiftPrizePoolWinBean.class));
+ break;
+ case Constants.SOCKET_PRIZE_POOL_UP://奖池升级
+ mListener.onPrizePoolUp(map.getString("uplevel"));
+ break;
+ case Constants.SOCKET_HOUR://小时榜
+ liveChatBean = new LiveChatBean();
+ liveChatBean.setId("-1");
+ liveChatBean.setType(LiveChatAdapter.MSG_HOUR_RANK_CHANGE);
+ liveChatBean.setContent(map.getJSONObject("ct").getString("text"));
+ mListener.onHourRank(liveChatBean, map.getJSONObject("ct").getJSONObject("new_rank"));
+ break;
+ //游戏socket
+ case Constants.SOCKET_GAME_ZJH://游戏 智勇三张
+ if (CommonAppConfig.GAME_ENABLE) {
+ mListener.onGameZjh(map);
+ }
+ break;
+ case Constants.SOCKET_GAME_HD://游戏 海盗船长
+ if (CommonAppConfig.GAME_ENABLE) {
+ mListener.onGameHd(map);
+ }
+ break;
+ case Constants.SOCKET_GAME_ZP://游戏 幸运转盘
+ if (CommonAppConfig.GAME_ENABLE) {
+ mListener.onGameZp(map);
+ }
+ break;
+ case Constants.SOCKET_GAME_NZ://游戏 开心牛仔
+ if (CommonAppConfig.GAME_ENABLE) {
+ mListener.onGameNz(map);
+ }
+ break;
+ case Constants.SOCKET_GAME_EBB://游戏 二八贝
+ if (CommonAppConfig.GAME_ENABLE) {
+ mListener.onGameEbb(map);
+ }
+ break;
+ case Constants.SOCKET_SEND_ACTIVE_MSG://新增,活动聊天显示
+ sendActiveMsg(map, received);
+ break;
+ case Constants.SOCKET_PRANKTURNTABLE://新增,整蛊消息
+ mListener.prankTurntable(map.getString("msgtype"), map.getIntValue("time"), JSON.parseObject(map.getString("ct")));
+ String msgtype = map.getString("msgtype");
+ JSONObject jsonObject = JSON.parseObject(map.getString("ct"));
+// if ("1".equals(msgtype)) {//新年大作战活动
+ LiveChatBean chatBean = new LiveChatBean();
+ chatBean.setId(jsonObject.getString("uid"));
+ chatBean.setUserNiceName(jsonObject.getString("user_nicename"));
+ if ("1".equals(map.getString("msgtype"))) {
+ chatBean.setType(-3);
+ } else {
+ chatBean.setType(-4);
+ }
+ chatBean.setContent(jsonObject.getString("content"));
+ chatBean.setBubble(jsonObject.getString("display_src"));
+ chatBean.setMedal(jsonObject.getString("hope_nicename"));//做为拯救人名字
+ chatBean.setAnchorName(jsonObject.getString("anchor_nicename"));
+ mListener.onChat(chatBean, 1);
+// }
+ break;
+ case Constants.SOCKET_USEHOTCARD://新增,热度卡消息
+// mListener.prankTurntable(map.getString("msgtype"), map.getIntValue("time"), JSON.parseObject(map.getString("ct")));
+ JSONObject jsonObject2 = JSON.parseObject(map.getString("ct"));
+ LiveChatBean chatBean2 = new LiveChatBean();
+ chatBean2.setType(-6);
+ chatBean2.setBubble(jsonObject2.getString("system_bubble"));
+ chatBean2.setId(jsonObject2.getString("user_id"));
+ chatBean2.setUserNiceName(jsonObject2.getString("user_name"));
+ chatBean2.setHot_num(jsonObject2.getString("hot_num"));
+ chatBean2.setHot_card(jsonObject2.getString("hot_card"));
+ getIsHot();
+ mListener.onChat(chatBean2, 1);
+ break;
+ case Constants.LOVE_CHECK://甜蜜
+ JSONObject jsonObject3 = JSON.parseObject(map.getString("ct"));
+ LiveChatBean chatBean3 = new LiveChatBean();
+ chatBean3.setType(-7);
+ chatBean3.setBubble(jsonObject3.getString("system_bubble"));
+ chatBean3.setId(jsonObject3.getString("user_id"));
+ chatBean3.setUserNiceName(jsonObject3.getString("user_name"));
+ chatBean3.setHot_num(jsonObject3.getString("gift_name"));
+ mListener.onChat(chatBean3, 1);
+ break;
+ case Constants.TRUMPET_NOTIFY://全站喇叭
+ SocketModel model = GsonUtils.fromJson(socketMsg, SocketModel.class);
+ List msg = model.getMsg();
+ if (msg.size() > 0) {
+// EventBus.getDefault().post(msg.get(0));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.TRUMPET_NOTIFY).setMsgModel(msg.get(0)));
+ }
+ break;
+ case Constants.RECOMMEND_CARD_NOTIFY://推荐卡消息通知
+ SocketModel recommendCardNotifyModel = GsonUtils.fromJson(socketMsg, SocketModel.class);
+ List recommendCardNotifyMsg = recommendCardNotifyModel.getMsg();
+ if (recommendCardNotifyMsg.size() > 0) {
+
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.RECOMMEND_CARD_NOTIFY).setMsgModel(recommendCardNotifyMsg.get(0)));
+ }
+ break;
+ case Constants.STAR_CHALLENGE_UPDATE://星级助力
+// SocketModel starChallengeModel = GsonUtils.fromJson(socketMsg, SocketModel.class);
+// List starChallengeMsg = starChallengeModel.getMsg();
+// if (starChallengeMsg.size() > 0) {
+//
+// Bus.get().post(new LiveAudienceEvent()
+// .setType(LiveAudienceEvent.LiveAudienceType.START_MESSAGE)
+// .setMsgModel(starChallengeMsg.get(0)));
+// }
+ 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().setType(LiveAudienceEvent.LiveAudienceType.AI_AUTOMATIC_SPEECH).setAiAutomaticSpeechModel(aiAutomaticSpeechModel));
+ break;
+ case Constants.STAR_CHALLENGE_UPGRADE_NOTIFY:
+ SocketModel starChallengeUpgradeNotify = GsonUtils.fromJson(socketMsg, SocketModel.class);
+ List starChallengeUpgradeNotifyMsg = starChallengeUpgradeNotify.getMsg();
+ if (starChallengeUpgradeNotifyMsg.size() > 0) {
+
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.STAR_CHALLENGE_UPGRADE_NOTIFY).setMsgModel(starChallengeUpgradeNotifyMsg.get(0)));
+ }
+ break;
+ case Constants.LuckyAngel:
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LUCKY_ANGEL).setMsgModel(GsonUtils.fromJson(map.getJSONObject("ct").toString(), MsgModel.class)));
+ break;
+ case Constants.Lucky100Check:
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LUCKY_100_CHECK).setMsgModel(GsonUtils.fromJson(map.getJSONObject("ct").toString(), MsgModel.class)));
+ break;
+ case Constants.PK_RANK_UPDATE:
+ Log.i("PK排位", map.toString());
+ JSONObject item = map.getJSONObject("ct");
+ PkRankBean pkRankBean = new PkRankBean();
+ pkRankBean.setId(Integer.parseInt(item.getString("new_rank_id")));
+ pkRankBean.setName(item.getString("new_rank_name"));
+ pkRankBean.setImg(item.getString("new_rank_img"));
+ pkRankBean.setNewRankNameEn(item.getString("new_rank_name_en"));
+ EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_RANK_UPDATE).setObject(pkRankBean));
+ break;
+ case Constants.CUSTOM_FULL_SERVICE_NOTIFY:
+ Log.e("全服通知", map.toString());
+ CustomFullServiceNotifyEvent customFullServiceNotifyEvent = GsonUtils.fromJson(map.toString(), CustomFullServiceNotifyEvent.class);
+ EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.CUSTOM_FULL_SERVICE_NOTIFY).setCustomFullServiceNotifyEvent(customFullServiceNotifyEvent));
+ break;
+ case Constants.XYD_COMPLETE:
+
+// xydComplete(map);
+ XydCompleteModel xydCompleteModel = GsonUtils.fromJson(map.toString(), XydCompleteModel.class);
+ EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.XYD_COMPLETE).setXydCompleteModel(xydCompleteModel).setLiveReceiveGiftBean(JSON.parseObject(map.toString(), LiveReceiveGiftBean.class)));
+ break;
+ case "GuardSpecialEffect":
+ LiveReceiveGiftBean giftBean = JSON.parseObject(map.toString(), LiveReceiveGiftBean.class);
+ giftBean.setMedal_name(map.getString("medal_name"));
+ EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.GuardSpecialEffect).setLiveReceiveGiftBean(giftBean));
+ break;
+ case Constants.WISH_LIST_PROGRESS:
+ StringBuffer conString = new StringBuffer();
+ conString.append(WordUtil.isNewZh() ? map.getString("msg") : map.getString("msg_en"));
+ EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.WISH_LIST_PROGRESS).setWishListProgress(new WishModel().setWishlistProgress(map.getString("wishlist_progress")).setWishlistIcon(map.getString("wishlist_icon")).setWishlistName(map.getString("wishlist_name")).setWishlistNum(map.getString("wishlist_num")).setGiftType(map.getInteger("giftId")).setLuid(conString.toString())).setUname(map.getString("userName")).setLiveType(Integer.parseInt(map.getString("level"))));
+ break;
+ case Constants.LIVE_VOTE_CREATE:
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.VOTE_CREATE).setObject(map));
+ break;
+ case Constants.LIVE_VOTE_END:
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.VOTE_END).setObject(map));
+ EventBus.getDefault().post(new LiveAnchorEvent().setType(LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_END).setObject(map));
+ break;
+ case Constants.LIVE_VOTE_UPDATE:
+ //通知给观众
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.VOTE_UPDATE).setObject(map));
+ //通知给主播
+ EventBus.getDefault().post(new LiveAnchorEvent().setType(LiveAnchorEvent.LiveAnchorType.VOTE_ANCHOR_UPDATE).setObject(map));
+ break;
+ case Constants.LIVE_PK_END:
+
+ mListener.onEndPk(map.getLong("uid"), map.getLong("pkuid"), map.getLong("uid_score"), map.getLong("pkuid_score"), JSONObject.parseObject(map.getJSONObject("ct").getJSONObject("pk_top_users").toJSONString(), LivePKUserListBean.class));
+ break;
+ case Constants.RED_PACKET:
+ RedPacketModel redPacketModel = GsonUtils.fromJson(map.toString(), RedPacketModel.class);
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.RED_PACKET).setRedPacketModel(redPacketModel));
+ break;
+ case Constants.RED_PACKET_SUPER_JACKPOT:
+ RedPacketInfoModel redPacketInfoModel = GsonUtils.fromJson(map.toString(), RedPacketInfoModel.class);
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.RED_PACKET_SUPER_JACKPOT).setRedPacketInfoModel(redPacketInfoModel));
+ break;
+ case "GiftWallIlluminate":
+ Log.e("GiftWallIlluminate", map.toString());
+ Bus.get().post(new GiftWallIlluminateEvent().setNewNumber(map.getInteger("new_number")).setMaxNumber(map.getInteger("max_number")));
+ break;
+ case SOCKET_LIVE_MSG_TO_USER:
+ sendToUserMsg(map);
+ break;
+ case "SudGameCreateRoom":
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SUD_GAME_CREATE_ROOM).setAvatar(WordUtil.isNewZh() ? map.getString("sud_game_name") : map.getString("sud_game_name_en")).setCreateSudRoomModel(GsonUtils.fromJson(map.toString(), SudGameDateModel.class)));
+ break;
+ case "sendQuickGift":
+ SendQuickGiftModel sendQuickGiftModel = GsonUtils.fromJson(map.toString(), SendQuickGiftModel.class);
+ StringBuffer stringBuffer = new StringBuffer();
+ stringBuffer.append(sendQuickGiftModel.getUserNicename()).append(WordUtil.isNewZh() ? " 送出了 " : " sent ").append(sendQuickGiftModel.getQuickGiftNumber()).append(WordUtil.isNewZh() ? " 個小PD " : " small pandas ");
+ systemChatMessage2(stringBuffer.toString());
+ Bus.get().post(new QuickGiftingEvent().setHotNum(sendQuickGiftModel.getHotNum()));
+ break;
+ case Constants.LIVE_PK_RANDOM_START:
+ item = map.getJSONObject("ct");
+ item.getString("text");
+ item.getString("pktt_img");
+ item.getString("uid_win_continuity");
+ item.getString("pkuid_win_continuity");
+ pkRankBean = new PkRankBean();
+ pkRankBean.setBlueVal(item.getString("pkuid_win_continuity"));
+ pkRankBean.setRedVal(item.getString("uid_win_continuity"));
+ pkRankBean.setPkTopImgUrl(item.getString("pktt_img"));
+
+ EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_RANK_START).setObject(pkRankBean));
+ break;
+ case "guardMaturityDateRemind":
+ GuardMaturityDateRemindModel maturityDateRemindModel = GsonUtils.fromJson(map.toString(), GuardMaturityDateRemindModel.class);
+ Bus.get().post(maturityDateRemindModel);
+ break;
+ case "SendMoneyLong":
+ SendMoneyLongModel sendMoneyLongModel = GsonUtils.fromJson(map.toString(), SendMoneyLongModel.class);
+ Bus.get().post(sendMoneyLongModel);
+ break;
+ case "SendMoneyLongEnd":
+ Bus.get().post(new SendMoneyLongEndEvent());
+ break;
+
+ }
+ }
+
+ private void buyGuardInSameRoom(JSONObject map) {
+ if (TextUtils.isEmpty(map.getString("ancherName")) || TextUtils.isEmpty(map.getString("uname")))
+ return;
+ String guardName = WordUtil.isNewZh() ? "星之守護" : "Star Guardian";
+ switch (map.getIntValue("guard_type")) {
+ case 1:
+ guardName = WordUtil.isNewZh() ? "星之守護" : "Star Guardian";
+ break;
+ case 2:
+ guardName = WordUtil.isNewZh() ? "王之守護" : "King Guardian";
+ break;
+ case 3:
+ guardName = WordUtil.isNewZh() ? "神之守護" : "God Guardian";
+ break;
+ }
+ String content = WordUtil.isNewZh() ? "%s在%s的直播間開通了%s" : "%s has been opened in %s live broadcast room %s";
+ content = String.format(content, map.getString("uname"), map.getString("ancherName"), guardName);
+ LiveBuyGuardMsgBean buyGuardMsgBean = new LiveBuyGuardMsgBean();
+ buyGuardMsgBean.setUid(map.getString("uid"));
+ buyGuardMsgBean.setUserName(content);
+ buyGuardMsgBean.setVotes(map.getString("votestotal"));
+ buyGuardMsgBean.setGuardNum(map.getIntValue("guard_nums"));
+ buyGuardMsgBean.setGuardType(map.getIntValue("guard_type"));
+ mListener.onBuyGuard(buyGuardMsgBean);
+ }
+
+ private void buyGuardByNotify(JSONObject map) {
+ if (mLiveUid.equals(map.getString("liveuid"))) {
+// buyGuardInSameRoom(map);
+ //同一直播间,玩家自己开通,也能看到全服通知
+ String userId = CommonAppConfig.getInstance().getUid();
+ String uid = map.getString("uid");
+ if (userId.equals(uid)) {
+ LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
+ receiveGiftBean.setUserNiceName(map.getString("uname"));
+ receiveGiftBean.setAncherName(map.getString("ancherName"));
+ receiveGiftBean.setmLiveUId(mLiveUid);
+ receiveGiftBean.setRoomnum(map.getString("liveuid"));
+ receiveGiftBean.setmTypeBuyGuard(true);
+ receiveGiftBean.setUid(uid);
+ receiveGiftBean.setGuardType(map.getString("guard_type"));
+ receiveGiftBean.setSendtype(map.getIntValue("action"));
+ mListener.onSendGift(receiveGiftBean, null);
+ }
+ } else {
+ LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
+ receiveGiftBean.setUserNiceName(map.getString("uname"));
+ receiveGiftBean.setAncherName(map.getString("ancherName"));
+ receiveGiftBean.setmLiveUId(mLiveUid);
+ receiveGiftBean.setRoomnum(map.getString("liveuid"));
+ receiveGiftBean.setmTypeBuyGuard(true);
+ receiveGiftBean.setUid(map.getString("uid"));
+ receiveGiftBean.setGuardType(map.getString("guard_type"));
+ receiveGiftBean.setSendtype(map.getIntValue("action"));
+ mListener.onSendGift(receiveGiftBean, null);
+ }
+ }
+
+
+ private void buyZuoJiByNotify(JSONObject map) {
+ LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
+ receiveGiftBean.setUserNiceName(map.getString("nickname"));
+ receiveGiftBean.setCarName(map.getString("carname"));
+ receiveGiftBean.setSendtype(map.getIntValue("action"));
+ mListener.onBuyZuoji(receiveGiftBean);
+ }
+
+
+ private void buyLiangNameByNotify(JSONObject map) {
+ LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
+ receiveGiftBean.setUserNiceName(map.getString("nickname"));
+ receiveGiftBean.setLiangName(map.getString("liangname"));
+ receiveGiftBean.setSendtype(map.getIntValue("action"));
+ mListener.onBuyLiangName(receiveGiftBean);
+ }
+
+ private void buyVipByNotify(JSONObject map) {
+ LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
+ receiveGiftBean.setUserNiceName(map.getString("nicename"));
+ receiveGiftBean.setVipName(map.getString("ct"));
+ receiveGiftBean.setAvatar(map.getString("notice"));
+ receiveGiftBean.setAllServerNotify(true);
+ receiveGiftBean.setmLiveUId(map.getString("anchorUid"));
+ receiveGiftBean.setGifUrl(map.getString("special_src"));
+ receiveGiftBean.setVipTime(map.getString("viplength"));
+ receiveGiftBean.setRoomnum(map.getString("anchorUid"));
+ receiveGiftBean.setAncherName(map.getString("ancherName"));
+ receiveGiftBean.setNobilityid(map.getString("nobilityid"));
+ receiveGiftBean.setNobilityname(map.getString("nobilityname"));
+ receiveGiftBean.setOpentype(map.getString("opentype"));
+ receiveGiftBean.setSendtype(map.getIntValue("action"));
+ receiveGiftBean.setSendtype(map.getIntValue("action"));
+ receiveGiftBean.setUname(map.getString("uname"));
+ receiveGiftBean.setUhead(map.getString("uhead"));
+ if (map.getString("notice").equals("1")) {
+ LiveRoomViewHolder.paygzGif(map.getString("special_src"), map.getString("anchorUid"));
+ }
+ mListener.onBuyVip(receiveGiftBean);
+ }
+
+ private void sendActiveMsg(JSONObject map, SocketReceiveBean received) {
+ String msgtype = map.getString("msgtype");
+ if ("1".equals(msgtype)) {//新年大作战活动
+ LiveChatBean chatBean = new LiveChatBean();
+ chatBean.setId(map.getString("uid"));
+ chatBean.setMedalLevelImageUrl(map.getString("monster_str"));//昵称暂时做为活动图片地址
+ chatBean.setContent(map.getString("url"));//暂时做为活动链接地址
+ chatBean.setUserNiceName(map.getString("activename"));
+ chatBean.setType(6);
+ mListener.onChat(chatBean, 0);
+ }
+ }
+
+ /**
+ * 七日留存新用户主播端弹幕显示接口
+ */
+ private void sendToUserMsg(JSONObject map) {
+ LiveChatBean bean = new LiveChatBean();
+ bean.setId(map.getString("uid"));
+ bean.setAtUserID(map.getString("toUserID"));
+ bean.setContent(map.getString("ct"));
+ bean.setType(LiveChatBean.TYPE_TO_USER_MSG);
+ bean.setUserNiceName(map.getString("user_nicename"));
+ bean.setToUid(CommonAppConfig.getInstance().getUid());
+ mListener.onChat(bean, 1);
+ }
+
+ private void wordLightEnterRoom(JSONObject map, SocketReceiveBean received) {
+ String msgtype = map.getString("msgtype");
+ if ("2".equals(msgtype)) {//发言,点亮
+ if ("409002".equals(received.getRetcode())) {
+ ToastUtil.show(WordUtil.isNewZh() ? "你已經被禁言" : "You\'ve been banned");
+ return;
+ }
+
+ //禁言别人,自己发言只能自己看到
+ if ("409100".equals(received.getRetcode())) {
+ String uid = map.getString("uid");
+ if (uid == null || !uid.equals(CommonAppConfig.getInstance().getUid())) {
+ return;
+ }
+ }
+ LiveChatBean chatBean = new LiveChatBean();
+ chatBean.setId(map.getString("uid"));
+ chatBean.setUserNiceName(map.getString("uname"));
+ chatBean.setLevel(map.getIntValue("level"));
+ chatBean.setAnchor(map.getIntValue("isAnchor") == 1);
+ chatBean.setManager(map.getIntValue("usertype") == Constants.SOCKET_USER_TYPE_ADMIN);
+ chatBean.setContent(map.getString("ct"));
+ int heart = map.getIntValue("heart");
+ chatBean.setHeart(heart);
+ if (heart > 0) {
+ chatBean.setType(LiveChatBean.LIGHT);
+ }
+ chatBean.setLiangName(map.getString("liangname"));
+ chatBean.setBubble(map.getString("bubble"));
+ chatBean.setMedal(map.getString("medal"));
+ chatBean.setMedal_new(map.getString("medal_new"));
+ chatBean.setVipType(map.getIntValue("vip_type"));
+ chatBean.setVipType(map.getIntValue("vip_type"));
+ chatBean.setMedal_honor(map.getString("medal_honor"));
+ chatBean.setGood_nub(map.getString("good_num"));
+ chatBean.setNobleId(map.getString("noble_id"));//貴族ID
+ chatBean.setStartColor(map.getString("startColor"));//昵称开始颜色
+ chatBean.setEndColor(map.getString("endColor"));//昵称结束颜色
+ chatBean.setContentColor(map.getString("contentColor"));//文字内容颜色
+ chatBean.setAtUserName(map.getString("atUserName"));//@名字
+ chatBean.setAtUserID(map.getString("atUserID"));//@ID
+ if (map.containsKey("guard_type") && !map.getString("guard_type").equals("undefined")) {
+ chatBean.setGuardType(map.getIntValue("guard_type"));
+ }
+ try {
+ //增加粉丝徽章信息
+ chatBean.setMedalNmae(map.getString("medal_name"));
+ FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level"));
+ if (fansMedalBean != null)
+ chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ if (!"".equals(map.getString("prankIcon")) && map.getString("prankIcon") != null) {
+ chatBean.setPrankIcon(map.getString("prankIcon"));
+ chatBean.setType(-5);
+ }
+ mListener.onChat(chatBean, 1);
+ } else if ("0".equals(msgtype)) {//用户进入房间
+ JSONObject obj = JSON.parseObject(map.getString("ct"));
+ LiveUserGiftBean u = GsonUtils.fromJson(obj.toJSONString(), LiveUserGiftBean.class);
+ UserBean.Vip vip = new UserBean.Vip();
+ int vipType = obj.getIntValue("vip_type");
+ vip.setType(vipType);
+ u.setVip(vip);
+ UserBean.Car car = new UserBean.Car();
+ car.setId(obj.getIntValue("car_id"));
+ car.setSwf(obj.getString("car_swf"));
+ car.setSwftime(obj.getFloatValue("car_swftime"));
+ car.setWords(obj.getString("car_words"));
+ u.setCar(car);
+ UserBean.Liang liang = new UserBean.Liang();
+ String liangName = obj.getString("liangname");
+ liang.setName(liangName);
+ u.setLiang(liang);
+ LiveChatBean chatBean = new LiveChatBean();
+ chatBean.setType(LiveChatBean.ENTER_ROOM);
+ chatBean.setId(u.getId());
+ chatBean.setMedal_honor(map.getString("medal_honor"));
+ chatBean.setGood_nub(map.getString("good_num"));
+ chatBean.setUserNiceName(u.getUserNiceName());
+ chatBean.setLevel(u.getLevel());
+ chatBean.setVipType(vipType);
+ chatBean.setLiangName(liangName);
+ chatBean.setBubble(obj.getString("bubble"));
+ chatBean.setMedal(obj.getString("medal"));
+ chatBean.setMedal_new(obj.getString("medal_new"));
+ chatBean.setHot_num(obj.getString("hot_num"));
+ UserBean.DressBean dressBean = new UserBean.DressBean();
+ dressBean.setAvatar_frame(obj.getString("avatar_frame"));
+ u.setDress(dressBean);
+
+ chatBean.setManager(obj.getIntValue("usertype") == Constants.SOCKET_USER_TYPE_ADMIN);
+ chatBean.setContent(mContext.getString(R.string.live_enter_room));
+ chatBean.setGuardType(obj.getIntValue("guard_type"));
+ chatBean.setNobleId(obj.getString("noble_id"));//貴族ID
+ chatBean.setStartColor(obj.getString("startColor"));//昵称开始颜色
+ chatBean.setEndColor(obj.getString("endColor"));//昵称结束颜色
+ chatBean.setContentColor(obj.getString("contentColor"));//文字内容颜色
+ chatBean.setNobleIcon(obj.getString("noble_icon"));//貴族圖標
+ chatBean.setBubbleSrc(obj.getString("bubbleSrc"));//氣泡
+ //增加粉丝徽章信息
+ chatBean.setMedalNmae(obj.getString("medal_name"));
+ chatBean.setUserNiceName(obj.getString("user_nicename"));//名字
+ FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level"));
+ u.setFansLevel(obj.getIntValue("medal_level"));
+ u.setFansEnterRoomUrl(obj.getString("medal_backgroup_thumb"));
+ if (fansMedalBean != null) chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
+ mListener.onEnterRoom(new LiveEnterRoomBean(u, chatBean));
+ }
+ }
+
+ //送礼物 全服通知
+ private void sendGiftByNotify(JSONObject map) {
+ LiveReceiveGiftBean receiveGiftBean = JSON.parseObject(map.getString("ct"), LiveReceiveGiftBean.class);
+ receiveGiftBean.setAvatar(map.getString("uhead"));
+ receiveGiftBean.setUserNiceName(map.getString("uname"));
+ receiveGiftBean.setRoomnum(map.getString("roomnum"));
+ receiveGiftBean.setAncherName(map.getString("ancherName"));
+ receiveGiftBean.setHot_num(map.getString("hot_num"));
+ receiveGiftBean.setSendtype(map.getIntValue("action"));
+ receiveGiftBean.setmLiveUId(mLiveUid);
+ receiveGiftBean.setmTypeBuyGuard(false);
+ //全服通知时,不通知主播
+ receiveGiftBean.setAllServerNotify(true);
+ LiveChatBean chatBean = new LiveChatBean();
+ chatBean.setUserNiceName(receiveGiftBean.getUserNiceName());
+ chatBean.setLevel(receiveGiftBean.getLevel());
+ chatBean.setBubble(map.getString("bubble"));
+ chatBean.setMedal(map.getString("medal"));
+ chatBean.setId(map.getString("uid"));
+ chatBean.setMedal_honor(map.getString("medal_honor"));
+ chatBean.setGood_nub(map.getString("good_num"));
+ chatBean.setLiangName(map.getString("liangname"));
+ chatBean.setVipType(map.getIntValue("vip_type"));
+ chatBean.setType(LiveChatBean.GIFT);
+ //增加粉丝徽章信息
+ chatBean.setMedalNmae(map.getString("medal_name"));
+ FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level"));
+ if (fansMedalBean != null) chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
+ //聊天列表显示 玩家名 送 1 个 礼物名
+
+ if (CommonAppContext.lang.equals("chinese")) {
+ chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + receiveGiftBean.getGiftCount() + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftName());
+ } else {
+ chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + " " + +receiveGiftBean.getGiftCount() + " " + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftnameen());
+ }
+
+ receiveGiftBean.setLiveChatBean(chatBean);
+ if (map.getIntValue("ifpk") == 1) {
+ if (!TextUtils.isEmpty(mLiveUid)) {
+ //获取PK排名数据
+ LivePKUserListBean livePKUserListBean = JSON.parseObject(receiveGiftBean.getPkTopUsers(), LivePKUserListBean.class);
+ if (mLiveUid.equals(map.getString("roomnum"))) {
+ if (!mLiveUid.equals(map.getString("roomnum"))) {
+ mListener.onSendGift(receiveGiftBean, null);
+ }
+ //同一个直播间时才刷新pk
+ mListener.onSendGiftPk(map.getLongValue("pktotal1"), map.getLongValue("pktotal2"), livePKUserListBean);
+ } else {
+ if (!mLiveUid.equals(map.getString("roomnum"))) {
+ mListener.onSendGift(receiveGiftBean, null);
+ }
+ //同一个直播间时才刷新pk
+ if (mLiveUid.equals(map.getString("pkuid1")) || mLiveUid.equals(map.getString("pkuid2"))) {
+ mListener.onSendGiftPk(map.getLongValue("pktotal2"), map.getLongValue("pktotal1"), livePKUserListBean);
+ }
+ }
+ }
+ } else {
+ if (!mLiveUid.equals(map.getString("roomnum"))) {
+ mListener.onSendGift(receiveGiftBean, null);
+ }
+ }
+ }
+
+ private void xydComplete(JSONObject map) {
+ LiveReceiveGiftBean receiveGiftBean = new LiveReceiveGiftBean();
+ receiveGiftBean.setAvatar(map.getString("uhead") + "");
+ receiveGiftBean.setUserNiceName(map.getString("uname"));
+ receiveGiftBean.setRoomnum(map.getString("roomnum"));
+ receiveGiftBean.setAncherName(map.getString("ancherName"));
+ receiveGiftBean.setHot_num(map.getString("hot_num"));
+ receiveGiftBean.setDrpk_status(map.getString("drpk_status"));
+ receiveGiftBean.setGitType(map.getInteger("swftype "));
+ receiveGiftBean.setmLiveUId(mLiveUid);
+ receiveGiftBean.setmTypeBuyGuard(false);
+ receiveGiftBean.setAllServerNotify(false);
+ receiveGiftBean.setGifUrl(map.getString("svg"));
+ LiveChatBean chatBean = new LiveChatBean();
+ chatBean.setUserNiceName(receiveGiftBean.getUserNiceName());
+ chatBean.setLevel(receiveGiftBean.getLevel());
+ chatBean.setMedal_honor(map.getString("medal_honor"));
+ chatBean.setId(map.getString("uid"));
+ chatBean.setLiangName(map.getString("liangname"));
+ chatBean.setVipType(map.getIntValue("vip_type"));
+ chatBean.setBubble(map.getString("bubble"));
+ chatBean.setMedal(map.getString("medal"));
+ chatBean.setMedal_new(map.getString("medal_new"));
+ chatBean.setGood_nub(map.getString("good_num"));
+ chatBean.setType(LiveChatBean.GIFT);
+ if (map.get("guard_type") != null && !"".equals(map.get("guard_type")) && !"null".equals(map.get("guard_type"))) {
+ chatBean.setGuardType(map.getInteger("guard_type"));
+ }
+ if (CommonAppContext.lang.equals("chinese")) {
+ chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + receiveGiftBean.getGiftCount() + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftName());
+ } else {
+ chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + " " + +receiveGiftBean.getGiftCount() + " " + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftnameen());
+
+ }
+ mListener.onSendGift(receiveGiftBean, null);
+ }
+
+ // 玩家自己送礼物
+ private void sendGiftInSameRoom(JSONObject map) {
+ String ctJson = map.getString("ct");
+ SendBlindGiftEvent sendBlindGiftEvent = JSON.parseObject(ctJson, SendBlindGiftEvent.class);
+ LiveReceiveGiftBean receiveGiftBean = JSON.parseObject(map.getString("ct"), LiveReceiveGiftBean.class);
+ sendBlindGiftEvent.setUserNiceName(map.getString("uname"));
+ receiveGiftBean.setAvatar(map.getString("uhead") + "");
+ receiveGiftBean.setUserNiceName(map.getString("uname"));
+ receiveGiftBean.setRoomnum(map.getString("roomnum"));
+ receiveGiftBean.setAncherName(map.getString("ancherName"));
+ receiveGiftBean.setHot_num(map.getString("hot_num"));
+ receiveGiftBean.setDrpk_status(map.getString("drpk_status"));
+ receiveGiftBean.setNamingCoin(map.getString("naming_live_name"));
+ receiveGiftBean.setNamingLiveName(map.getString("naming_live_name"));
+ receiveGiftBean.setNamingUid(map.getString("naming_uid"));
+ receiveGiftBean.setNamingLiveuid(map.getString("naming_liveuid"));
+ receiveGiftBean.setmLiveUId(mLiveUid);
+ receiveGiftBean.setmTypeBuyGuard(false);
+ receiveGiftBean.setAllServerNotify(false);
+ sendBlindGiftEvent.setGiftname_en(map.getString("giftname_en"));
+ //获取PK排名数据
+ LivePKUserListBean livePKUserListBean = JSON.parseObject(receiveGiftBean.getPkTopUsers(), LivePKUserListBean.class);
+
+ LiveChatBean chatBean = new LiveChatBean();
+ chatBean.setUserNiceName(receiveGiftBean.getUserNiceName());
+ chatBean.setLevel(receiveGiftBean.getLevel());
+ chatBean.setMedal_honor(map.getString("medal_honor"));
+ chatBean.setId(map.getString("uid"));
+ chatBean.setLiangName(map.getString("liangname"));
+ chatBean.setVipType(map.getIntValue("vip_type"));
+ chatBean.setBubble(map.getString("bubble"));
+ chatBean.setMedal(map.getString("medal"));
+ chatBean.setMedal_new(map.getString("medal_new"));
+ chatBean.setGood_nub(map.getString("good_num"));
+ chatBean.setType(LiveChatBean.GIFT);
+ if (map.get("guard_type") != null && !"".equals(map.get("guard_type")) && !"null".equals(map.get("guard_type"))) {
+ chatBean.setGuardType(map.getInteger("guard_type"));
+ }
+
+ if (WordUtil.isNewZh()) {
+ chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + receiveGiftBean.getGiftCount() + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftName());
+ } else {
+ chatBean.setContent(mContext.getString(R.string.live_send_gift_1) + " " + +receiveGiftBean.getGiftCount() + " " + mContext.getString(R.string.live_send_gift_2) + receiveGiftBean.getGiftnameen());
+ }
+ //增加粉丝徽章信息
+ chatBean.setMedalNmae(map.getString("medal_name"));
+ FansModel fansMedalBean = new NewLevelManager(mContext).getFansModel(map.getIntValue("medal_level"));
+ if (fansMedalBean != null) chatBean.setMedalLevelImageUrl(fansMedalBean.getThumb());
+
+ receiveGiftBean.setLiveChatBean(chatBean);
+
+ if (map.getIntValue("ifpk") == 1) {
+ try {
+ if (!TextUtils.isEmpty(mLiveUid)) {
+ if (mLiveUid.equals(map.getString("roomnum"))) {
+ mListener.onSendGift(receiveGiftBean, sendBlindGiftEvent);
+ mListener.onSendGiftPk(map.getLongValue("pktotal1"), map.getLongValue("pktotal2"), livePKUserListBean);
+ } else {
+ mListener.onSendGiftPk(map.getLongValue("pktotal2"), map.getLongValue("pktotal1"), livePKUserListBean);
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ } else {
+ Log.i("tvvs", receiveGiftBean.getLiveChatBean().getContent());
+ if (!TextUtils.isEmpty(sendBlindGiftEvent.getAction()) && TextUtils.equals("blind_box", sendBlindGiftEvent.getAction())) {
+ mListener.onSendGift(receiveGiftBean, sendBlindGiftEvent);
+ } else {
+ mListener.onSendGift(receiveGiftBean, null);
+ }
+
+ }
+ if (map.getIntValue("drpk_status") == 1) {
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LEAVE_PK_SCORE).setPkScores(map.getJSONArray("userlist")).setUid(mLiveUid).setTime(0));
+// LiveRoomViewHolder.UpPkBar(map.getJSONArray("userlist"), mLiveUid, 0);
+ }
+
+ }
+
+ /**
+ * 接收到系统消息,显示在聊天栏中
+ */
+ private void systemChatMessage(String content) {
+ LiveChatBean bean = new LiveChatBean();
+ bean.setContent(content);
+ bean.setType(LiveChatBean.SYSTEM);
+ mListener.onChat(bean, 1);
+ }
+
+ /**
+ * 接收到系统消息,显示在聊天栏中
+ */
+ private void systemChatMessage2(String content) {
+ LiveChatBean bean = new LiveChatBean();
+ bean.setContent(content);
+ bean.setType(LiveChatBean.SYSTEM2);
+ mListener.onChat(bean, 1);
+ }
+
+ /**
+ * 处理观众与主播连麦逻辑
+ */
+ private void processLinkMic(JSONObject map) {
+ int action = map.getIntValue("action");
+ switch (action) {
+ case 1://主播收到观众连麦的申请
+ UserBean u = new UserBean();
+ u.setId(map.getString("uid"));
+ u.setUserNiceName(map.getString("uname"));
+ u.setAvatar(map.getString("uhead"));
+ u.setSex(map.getIntValue("sex"));
+ u.setLevel(map.getIntValue("level"));
+ mListener.onAudienceApplyLinkMic(u);
+ break;
+ case 2://观众收到主播同意连麦的消息
+ if (map.getString("touid").equals(CommonAppConfig.getInstance().getUid())) {
+ mListener.onAnchorAcceptLinkMic();
+ }
+ break;
+ case 3://观众收到主播拒绝连麦的消息
+ if (map.getString("touid").equals(CommonAppConfig.getInstance().getUid())) {
+ mListener.onAnchorRefuseLinkMic();
+ }
+ break;
+ case 4://所有人收到连麦观众发过来的流地址
+ String uid = map.getString("uid");
+ if (!TextUtils.isEmpty(uid) && !uid.equals(CommonAppConfig.getInstance().getUid())) {
+ mListener.onAudienceSendLinkMicUrl(uid, map.getString("uname"), map.getString("playurl"));
+ }
+ break;
+ case 5://连麦观众自己断开连麦
+ mListener.onAudienceCloseLinkMic(map.getString("uid"), map.getString("uname"));
+ break;
+ case 6://主播断开已连麦观众的连麦
+ mListener.onAnchorCloseLinkMic(map.getString("touid"), map.getString("uname"));
+ break;
+ case 7://已申请连麦的观众收到主播繁忙的消息
+ if (map.getString("touid").equals(CommonAppConfig.getInstance().getUid())) {
+ mListener.onAnchorBusy();
+ }
+ break;
+ case 8://已申请连麦的观众收到主播无响应的消息
+ if (map.getString("touid").equals(CommonAppConfig.getInstance().getUid())) {
+ mListener.onAnchorNotResponse();
+ }
+ break;
+ case 9://所有人收到已连麦的观众退出直播间消息
+ mListener.onAudienceLinkMicExitRoom(map.getString("touid"));
+ break;
+ }
+ }
+
+ /**
+ * 处理主播与主播连麦逻辑
+ *
+ * @param map
+ */
+ private void processLinkMicAnchor(JSONObject map) {
+ int action = map.getIntValue("action");
+ switch (action) {
+ case 1://收到其他主播连麦的邀请的回调
+ UserBean u = new UserBean();
+ u.setId(map.getString("uid"));
+ u.setUserNiceName(map.getString("uname"));
+ u.setAvatar(map.getString("uhead"));
+ u.setSex(map.getIntValue("sex"));
+ u.setLevel(map.getIntValue("level"));
+ u.setLevelAnchor(map.getIntValue("level_anchor"));
+ mListener.onLinkMicAnchorApply(u, map.getString("stream"));
+ break;
+ case 3://对方主播拒绝连麦的回调
+ mListener.onLinkMicAnchorRefuse();
+ break;
+ case 4://所有人收到对方主播的播流地址的回调
+ mListener.onLinkMicAnchorPlayUrl(map.getString("pkuid"), map.getString("pkpull"));
+ break;
+ case 5://断开连麦的回调
+ mListener.onLinkMicAnchorClose();
+ break;
+ case 7://对方主播正在忙的回调
+ mListener.onLinkMicAnchorBusy();
+ break;
+ case 8://对方主播无响应的回调
+ mListener.onLinkMicAnchorNotResponse();
+ break;
+ case 9://对方主播正在游戏
+ mListener.onlinkMicPlayGaming();
+ break;
+ }
+ }
+
+ /**
+ * 处理主播与主播PK逻辑
+ *
+ * @param map
+ */
+ private void processAnchorLinkMicPk(JSONObject map) {
+ int action = map.getIntValue("action");
+ Log.i("Socket", "action = " + action + " json = " + map.toString());
+ L.eSw("处理主播与主播PK逻辑action = " + action + " json = " + map.toString());
+ switch (action) {
+ case 1://收到对方主播PK回调
+ UserBean u = new UserBean();
+ u.setId(map.getString("uid"));
+ u.setUserNiceName(map.getString("uname"));
+ u.setAvatar(map.getString("uhead"));
+ u.setRandomPk("11".equals(map.getString("msgtype")));
+ mListener.onLinkMicPkApply(u, map.getString("stream"), "11".equals(map.getString("msgtype")) ? 2 : 1);
+ break;
+ case 2://收到对方主播PK回调
+ L.eSw("收到对方主播PK回调");
+ /*if("1".equals(map.getString("random_pk"))){
+
+ }*/
+ RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START);
+ mListener.onLinkMicToPk(map.getString("uid"), map.getString("uhead"), map.getString("uhead"));
+ mListener.onLinkMicPkStart(map.getString("uid"), map.getString("uhead"), map.getString("uname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid"));
+ if (livePushSwViewHolder != null) {
+ UserBean userBean = new UserBean();
+ userBean.setId(map.getString("uid"));
+ userBean.setAvatar(map.getString("uhead"));
+ userBean.setUserNiceName(map.getString("uname"));
+ livePushSwViewHolder.setAnPkRtc(userBean);
+ }
+ break;
+ case 3://对方主播拒绝PK的回调
+ RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_REFUSE);
+ mListener.onLinkMicPkRefuse();
+ break;
+ case 4://所有人收到PK开始址的回调
+ L.eSw("所有人收到PK开始址的回调");
+ // RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START);
+ EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TWO_START).setObject(map.getString("pkuid")));
+ mListener.onLinkMicPkStart(map.getString("pkuid"), map.getString("pkhead"), map.getString("pkname"), map.getString("is_ladders"));
+ break;
+ case 5://PK时候断开连麦的回调
+// if (rtcRoom != null) {
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.DISCONNEXT_PK_TIME));
+ //断开连麦
+ HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout").execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+
+ }
+ });
+// }
+ if (livePushSwViewHolder != null) {
+ livePushSwViewHolder.onLinkMicAnchorClose();
+ }
+ mListener.onLinkMicPkClose(1);
+ if (RandomPkManager.getInstance().isRandomModel()) {
+ RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_DEFAULT);
+ }
+ break;
+ case 7://对方主播正在忙的回调
+ mListener.onLinkMicPkBusy();
+ break;
+ case 8://对方主播无响应的回调
+ mListener.onLinkMicPkNotResponse();
+ break;
+ case 9://pk结束的回调
+ mListener.onLinkMicPkEnd(map.getString("win_uid"));
+ EventBus.getDefault().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIVE_PK_END).setObject(map.getString("uid")));
+ if (livePushSwViewHolder != null) {
+ livePushSwViewHolder.onLinkMicAnchorClose();
+ }
+ break;
+ case 10://系统发起PK回调
+ if (livePushSwViewHolder != null) {
+ final SocketSendBean msg1 = new SocketSendBean()
+ .param("_method_", SOCKET_LINK_MIC_PK).param("action", 2)
+ .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", CommonAppConfig.getInstance().getUid())
+ .param("msgtype", 2).param("uid", CommonAppConfig.getInstance().getUid())
+ .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
+ .param("is_auto", "1")
+ .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar())
+ .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName());
+ msg1.create();
+ 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(map.getString("uid"), 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) {
+ }
+
+ @Override
+ public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
+ Log.e("tx", "aaa" + errorCode.toString());
+ ToastUtil.show(errorCode.code + ":" + errorCode.msg);
+ }
+ });
+
+ RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START);
+
+ LiveNetManager.get(mContext).getLiveInfo(map.getString("uid"), new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(LiveInfoModel data) {
+ mListener.onLinkMicToPk(map.getString("uid"), data.getAvatar(), map.getString("uhead"));
+ mListener.onLinkMicPkStart(map.getString("uid"), data.getAvatar(), map.getString("uname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid"));
+ if (livePushSwViewHolder != null) {
+ UserBean userBean = new UserBean();
+ userBean.setId(map.getString("uid"));
+ userBean.setAvatar(data.getAvatar());
+ userBean.setUserNiceName(map.getString("uname"));
+ livePushSwViewHolder.setAnPkRtc(userBean);
+ }
+ }
+
+ @Override
+ public void onError(String error) {
+
+ }
+ });
+ }
+ break;
+ }
+ }
+ }
+}
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketSwLinkMicPkUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketSwLinkMicPkUtil.java
new file mode 100644
index 000000000..34cc7bb6f
--- /dev/null
+++ b/live/src/main/java/com/yunbao/live/socket/SocketSwLinkMicPkUtil.java
@@ -0,0 +1,213 @@
+package com.yunbao.live.socket;
+
+import android.util.Log;
+
+import com.yunbao.common.CommonAppConfig;
+import com.yunbao.common.Constants;
+import com.yunbao.common.bean.UserBean;
+import com.yunbao.common.http.HttpCallback;
+import com.yunbao.common.http.HttpClient;
+import com.yunbao.common.utils.L;
+
+import io.rong.imlib.IRongCallback;
+import io.rong.imlib.RongIMClient;
+import io.rong.imlib.model.Conversation;
+import io.rong.imlib.model.Message;
+import io.rong.message.TextMessage;
+
+public class SocketSwLinkMicPkUtil {
+ /**
+ * 发起PK申请
+ *
+ * @param pkUid 对方主播的uid
+ * @param stream 自己直播间的stream
+ */
+ public static void linkMicPkApply(SocketSwClient client, String pkUid, String stream) {
+ if (client == null) {
+ return;
+ }
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+ }
+
+
+ /**
+ * 主播接受对方主播的Pk请求
+ *
+ * @param pkUid 对方主播的uid
+ */
+ public static void linkMicPkAccept(SocketSwClient client, String pkUid, String url, String name) {
+ HttpClient.getInstance().get("Livepk.changeLive", "Livepk.changeLive")
+ .params("uid", CommonAppConfig.getInstance().getUid())
+ .params("pkuid", pkUid)
+ .params("type", "1")
+ .params("sign", "1")
+ .execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msgs, String[] info) {
+ if (code == 0) {
+ L.eSw("1111111111111111111111111111");
+ HttpClient.getInstance().get("Livepk.setPK", "Livepk.setPK")
+ .params("uid", CommonAppConfig.getInstance().getUid())
+ .params("pkuid", pkUid)
+ .params("type", "1")
+ .params("sign", "1")
+ .execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msgs, String[] info) {
+ if (code == 0) {
+ Log.e("ry",name+"啊啊"+url);
+ L.eSw("2222222222222222222222");
+ final SocketSendBean msg1 = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_LINK_MIC_PK)
+ .param("action", 4)
+ .param("uname", url)
+ .param("uhead", name)
+ .param("pkuid", pkUid)
+ .param("uid", CommonAppConfig.getInstance().getUid())
+ .param("pkhead", url)
+ .param("pkname", name);
+ msg1.create();
+
+ Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
+ TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
+ Message message1 = Message.obtain("g" + CommonAppConfig.getInstance().getUid(), conversationType, messageContent);
+
+ RongIMClient.getInstance().sendMessage(message1, null, null, new IRongCallback.ISendMessageCallback() {
+ @Override
+ public void onAttached(Message message) {
+
+ }
+
+ @Override
+ public void onSuccess(Message message) {
+ Log.i("tx", "发送成功");
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+ }
+
+ }
+ });
+ }
+ }
+ });
+
+
+ }
+
+ /**
+ * 主播接受对方主播的Pk请求
+ *
+ * @param pkUid 对方主播的uid
+ */
+ public static void linkMicDRPkAccept(String pkUid) {
+
+
+ }
+
+ /**
+ * 主播拒绝其他主播的连麦请求
+ */
+ public static void linkMicPkRefuse(SocketSwClient client, String pkUid) {
+ if (client == null) {
+ return;
+ }
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+ final SocketSendBean msg = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_LINK_MIC_PK)
+ .param("action", 3)
+ .param("msgtype", 0)
+ .param("uid", u.getId())
+ .param("uname", u.getUserNiceName())
+ .param("pkuid", pkUid)
+ .param("ct", "");
+
+ msg.create();
+
+ Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
+ TextMessage messageContent = TextMessage.obtain(msg.mResult.toString());
+ Message message = Message.obtain(pkUid, conversationType, messageContent);
+
+ RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
+ @Override
+ public void onAttached(Message message) {
+
+ }
+
+ @Override
+ public void onSuccess(Message message) {
+ Log.i("tx", "发送成功");
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+
+ }
+
+
+ /**
+ * 主播断开连麦
+ */
+ public static void linkMicAnchorClose(SocketSwClient client, String pkUid) {
+ if (client == null) {
+ return;
+ }
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ if (u == null) {
+ return;
+ }
+// client.send(new SocketSendBean()
+// .param("_method_", Constants.SOCKET_LINK_MIC_PK)
+// .param("action", 5)
+// .param("msgtype", 0)
+// .param("uid", u.getId())
+// .param("ct", "")
+// .param("pkuid", pkUid)
+// .param("uname", u.getUserNiceName()));
+
+
+ }
+
+ /**
+ * 当收到主播连麦的请求时候主播正在忙
+ */
+ public static void linkMicPkBusy(SocketClient client, String pkUid) {
+ if (client == null) {
+ return;
+ }
+// client.send(new SocketSendBean()
+// .param("_method_", Constants.SOCKET_LINK_MIC_PK)
+// .param("action", 7)
+// .param("msgtype", 10)
+// .param("pkuid", pkUid));
+ }
+
+ /**
+ * 当收到主播连麦的请求时候主播无响应
+ */
+ public static void linkMicPkNotResponse(SocketSwClient client, String pkUid) {
+ if (client == null) {
+ return;
+ }
+// client.send(new SocketSendBean()
+// .param("_method_", Constants.SOCKET_LINK_MIC_PK)
+// .param("action", 8)
+// .param("msgtype", 10)
+// .param("pkuid", pkUid));
+ }
+
+
+}
diff --git a/live/src/main/java/com/yunbao/live/utils/LiveRoomVoteManager.java b/live/src/main/java/com/yunbao/live/utils/LiveRoomVoteManager.java
index 8407e8dca..297ce9e17 100644
--- a/live/src/main/java/com/yunbao/live/utils/LiveRoomVoteManager.java
+++ b/live/src/main/java/com/yunbao/live/utils/LiveRoomVoteManager.java
@@ -19,10 +19,8 @@ import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
-import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
@@ -60,7 +58,7 @@ public class LiveRoomVoteManager {
mAnchorVoteHide.setOnClickListener(v -> hideAnchorVote());
mVoteShow.setOnClickListener(v -> hideAnchorVote());
mClose.setOnClickListener(v -> close());
- if (mContext instanceof LiveRyAnchorActivity) {
+ if (mContext instanceof LiveSwAnchorActivity) {
isAnchor = true;
} else {
isAnchor = false;
diff --git a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
index b220d8f07..11c1b5c7b 100644
--- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
+++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
@@ -6,6 +6,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
+import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
@@ -21,7 +22,9 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.MeasureSpec;
+import android.view.ViewGroup;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
@@ -31,13 +34,16 @@ import androidx.core.content.ContextCompat;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
+import com.lzf.easyfloat.enums.ShowPattern;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.bean.AiAutomaticSpeechModel;
import com.yunbao.common.bean.MsgModel;
import com.yunbao.common.bean.NewGuardLevelModel;
import com.yunbao.common.bean.NewLevelModel;
import com.yunbao.common.custom.VerticalImageSpan;
+import com.yunbao.common.dialog.DebugDialog;
import com.yunbao.common.glide.ImgLoader;
+import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.NewLevelManager;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.StringUtil;
@@ -83,6 +89,10 @@ public class LiveTextRender {
sFontSizeSpan = new AbsoluteSizeSpan(17, true);
sFontSizeSpan2 = new AbsoluteSizeSpan(12, true);
sFontSizeSpan3 = new AbsoluteSizeSpan(14, true);
+ if (!isInit) {
+ isInit = true;
+
+ }
}
public void blindBox(Context context, TextView textView, LiveChatBean bean) {
@@ -263,7 +273,7 @@ public class LiveTextRender {
}
public interface CreatePrefixCallback {
- void onPrefixCallback(SpannableStringBuilder builder);
+ void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth);
}
/**
@@ -284,38 +294,38 @@ public class LiveTextRender {
getGuardImage(CommonAppContext.sInstance, bean.getGuardType(), new ImgLoader.DrawableCallback() {
@Override
public void onLoadSuccess(Drawable drawable) {
- SpannableStringBuilder builder = new SpannableStringBuilder();
+ /*SpannableStringBuilder builder = new SpannableStringBuilder();
int index = 0;
if (levelDrawable != null) {
- builder.append(" ");
+ builder.append("\uFFFC ");
levelDrawable.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(17));
builder.setSpan(new VerticalImageSpan(levelDrawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
}
if (gzDrawablesMap.containsKey(bean)) {//贵族
- builder.append(" ");
+ builder.append("\uFFFC ");
gzDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(35), DpUtil.dp2px(20));
builder.setSpan(new VerticalImageSpan(gzDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
}
if (ryxzDrawablesMap.containsKey(bean)) {//荣誉勋章
- builder.append(" ");
+ builder.append("\uFFFC ");
ryxzDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(18), DpUtil.dp2px(18));
builder.setSpan(new VerticalImageSpan(ryxzDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
}
if (nhDrawablesMap.containsKey(bean)) {//靓号
- builder.append(" ");
+ builder.append("\uFFFC ");
nhDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(17));
builder.setSpan(new VerticalImageSpan(nhDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
}
if (drawable != null) {
- builder.append(" ");
+ builder.append("\uFFFC ");
drawable.setBounds(0, 0, DpUtil.dp2px(34), DpUtil.dp2px(17));
builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
@@ -325,7 +335,7 @@ public class LiveTextRender {
&& !bean.getMedalNmae().equals("null") && !bean.getMedalNmae().equals("(null)") && !bean.getMedalNmae().equals("")) {//粉丝徽章图标
Drawable drawable2 = getMedalImage(bean);
if (drawable2 != null) {
- builder.append(" ");
+ builder.append("\uFFFC ");
drawable2.setBounds(0, 0, DpUtil.dp2px(44), DpUtil.dp2px(17));
builder.setSpan(new VerticalImageSpan(drawable2), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
@@ -336,7 +346,7 @@ public class LiveTextRender {
if (bean.isManager()) {//直播间管理员图标
Drawable drawable3 = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_m);
if (drawable3 != null) {
- builder.append(" ");
+ builder.append("\uFFFC ");
drawable3.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(14));
builder.setSpan(new VerticalImageSpan(drawable3), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
@@ -346,82 +356,101 @@ public class LiveTextRender {
if (!TextUtils.isEmpty(bean.getLiangName())) {//靓号图标
Drawable drawable4 = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_liang);
if (drawable4 != null) {
- builder.append(" ");
+ builder.append("\uFFFC ");
drawable4.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(14));
builder.setSpan(new VerticalImageSpan(drawable4), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// new add
index = builder.length();
}
}
- createPrefixCallback.onPrefixCallback(builder);
+ createPrefixCallback.onPrefixCallback(builder, 0);*/
+ show(drawable);
}
@Override
public void onLoadFailed() {
+ show(null);
+ }
+
+ void show(Drawable drawable) {
SpannableStringBuilder builder = new SpannableStringBuilder();
int index = 0;
-
+ int prefixWidth = 0;
if (levelDrawable != null) {
- builder.append(" ");
+ builder.append("\uFFFC ");
levelDrawable.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(17));
builder.setSpan(new VerticalImageSpan(levelDrawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
+ prefixWidth += levelDrawable.getBounds().width();
}
if (gzDrawablesMap.containsKey(bean)) {//贵族
- builder.append(" ");
+ builder.append("\uFFFC ");
gzDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(35), DpUtil.dp2px(20));
builder.setSpan(new VerticalImageSpan(gzDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
+ prefixWidth += gzDrawablesMap.get(bean).getBounds().width();
}
if (ryxzDrawablesMap.containsKey(bean)) {//荣誉勋章
- builder.append(" ");
+ builder.append("\uFFFC ");
ryxzDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(18), DpUtil.dp2px(18));
builder.setSpan(new VerticalImageSpan(ryxzDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
+ prefixWidth += ryxzDrawablesMap.get(bean).getBounds().width();
}
if (nhDrawablesMap.containsKey(bean)) {//靓号
- builder.append(" ");
+ builder.append("\uFFFC ");
nhDrawablesMap.get(bean).setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(17));
builder.setSpan(new VerticalImageSpan(nhDrawablesMap.get(bean)), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
+ prefixWidth += nhDrawablesMap.get(bean).getBounds().width();
+ }
+ if (drawable != null) {
+ builder.append("\uFFFC ");
+ drawable.setBounds(0, 0, DpUtil.dp2px(34), DpUtil.dp2px(17));
+ builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
+ index = builder.length();
+ prefixWidth += drawable.getBounds().width();
}
//在这里添加粉丝徽章的图片
if (!TextUtils.isEmpty(bean.getMedalNmae()) && !TextUtils.isEmpty(bean.getMedalLevelImageUrl())
&& !bean.getMedalNmae().equals("null") && !bean.getMedalNmae().equals("(null)") && !bean.getMedalNmae().equals("")) {//粉丝徽章图标
- Drawable drawable = getMedalImage(bean);
+ drawable = getMedalImage(bean);
if (drawable != null) {
- builder.append(" ");
+ builder.append("\uFFFC ");
drawable.setBounds(0, 0, DpUtil.dp2px(44), DpUtil.dp2px(17));
builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
+ prefixWidth += drawable.getBounds().width();
}
}
if (bean.isManager()) {//直播间管理员图标
- Drawable drawable = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_m);
+ drawable = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_m);
if (drawable != null) {
- builder.append(" ");
+ builder.append("\uFFFC ");
drawable.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(14));
builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index = builder.length();
+ prefixWidth += drawable.getBounds().width();
}
}
if (!TextUtils.isEmpty(bean.getLiangName())) {//靓号图标
- Drawable drawable = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_liang);
+ drawable = ContextCompat.getDrawable(CommonAppContext.sInstance, R.mipmap.icon_live_chat_liang);
if (drawable != null) {
- builder.append(" ");
+ builder.append("\uFFFC ");
drawable.setBounds(0, 0, DpUtil.dp2px(17), DpUtil.dp2px(14));
builder.setSpan(new VerticalImageSpan(drawable), index, index + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
// new add
index = builder.length();
+ prefixWidth += drawable.getBounds().width();
}
}
- createPrefixCallback.onPrefixCallback(builder);
+ createPrefixCallback.onPrefixCallback(builder, prefixWidth);
}
});
@@ -515,9 +544,9 @@ public class LiveTextRender {
}
public void getGuardImage(Context mContext, int guardType, ImgLoader.DrawableCallback callback) {
- if (guardType==0){
+ if (guardType == 0) {
callback.onLoadFailed();
- }else {
+ } else {
if (mContext instanceof Activity) {
if (((Activity) mContext).isDestroyed()) {
mContext = CommonAppContext.getTopActivity();
@@ -684,7 +713,7 @@ public class LiveTextRender {
createPrefix(drawable, bean, new CreatePrefixCallback() {
@Override
- public void onPrefixCallback(SpannableStringBuilder builder) {
+ public void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth) {
int color = Color.parseColor("#68F1F4");
if (bean.isAnchor()) {
color = Color.parseColor("#FBEABF");
@@ -696,20 +725,20 @@ public class LiveTextRender {
builder = renderGift(color, builder, bean);
break;
default:
- builder = renderChat(color, builder, bean);
+ builder = renderChat(textView, color, builder, bean, prefixWidth);
break;
}
textView.setText(builder);
}
});
- }
+ }// 123123123123123123123123
@Override
public void onLoadFailed() {
createPrefix(null, bean, new CreatePrefixCallback() {
@Override
- public void onPrefixCallback(SpannableStringBuilder builder) {
+ public void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth) {
int color = 0;
if (bean.isAnchor()) {
color = 0xffffdd00;
@@ -721,7 +750,7 @@ public class LiveTextRender {
builder = renderGift(color, builder, bean);
break;
default:
- builder = renderChat(color, builder, bean);
+ builder = renderChat(textView, color, builder, bean, prefixWidth);
break;
}
textView.setText(builder);
@@ -805,16 +834,64 @@ public class LiveTextRender {
return mNewBitmap;
}
+ public static OnItemClickListener onItemClickListener = new OnItemClickListener() {
+ @Override
+ public void onItemClick(String bean, int position) {
+
+ }
+ };
+ private static boolean isInit = false;
+ public static int textTemp = 0;
+ public static String userName = "";
+
/**
* 渲染普通聊天消息
*/
- private SpannableStringBuilder renderChat(int color, SpannableStringBuilder builder, LiveChatBean bean) {
+ private SpannableStringBuilder renderChat(TextView textView, int color, SpannableStringBuilder builder, LiveChatBean bean, int prefixWidth) {
int length = builder.length();
String name = bean.getUserNiceName();
+ float prefixEmpty = textView.getPaint().measureText(builder, 0, builder.length()) / 2;
+ if (!StringUtil.isEmpty(userName)) {
+ // name = userName;
+ }
if (bean.getType() != LiveChatBean.ENTER_ROOM) {//产品规定,进场消息不允许加冒号
name += ":";
}
+ SpannableStringBuilder sb = new SpannableStringBuilder();
+ sb.append(name);
+ float measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
+ Rect mRect = new Rect();
+ textView.getPaint().getTextBounds(sb.toString(), 0, sb.length(), mRect);
+ int width = (int) (((ViewGroup) textView.getParent()).getMeasuredWidth() - prefixEmpty);
+ String TAG = "文字渲染";
+ Log.i(TAG, "测算|" + measuredText + "|" + mRect.width() + "|" + sb.toString());
+ //|810|810|810|786|786
+ Log.i(TAG, "控件宽度|" + width + "|" + ((ViewGroup) textView.getParent()).getWidth() + "|" + ((ViewGroup) textView.getParent()).getMeasuredWidth() + "|" + textView.getWidth() + "|" + textView.getMeasuredWidth());
+ Log.i(TAG, "前缀预留宽度|" + prefixWidth + "|" + prefixEmpty);
+ Log.i(TAG, "renderChat: " + textView.getCompoundPaddingLeft() + "|" + textView.getCompoundPaddingRight() + "|");
+ //检测渲染后图标+名字是否超过父布局宽度,超过了就做换行处理
+ String prefixName = "";
+ if (measuredText > width) {
+ sb.clear();
+ for (int i = 0; i < name.length(); i++) {
+ sb.append(name.charAt(i));
+ measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
+ Log.i(TAG, i + "逐测算|" + measuredText + "|" + textTemp);
+ if (measuredText > width) {
+ prefixName = name.substring(0, i + textTemp);
+ name = prefixName + "\n" + name.substring(i + textTemp);
+ break;
+ }
+ }
+ sb.clear();
+ } else {
+ prefixName = name;
+ }
+ sb.clear();
+ sb.append(prefixName);
+ // name=name.substring(0,7)+"\n"+name.substring(7);
builder.append(name);
+ Log.i(TAG, "再测算|" + (textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth) + "|" + textTemp + "|" + sb.toString());
//超皇设置渐变色展示昵称
if (TextUtils.equals("7", bean.getNobleId()) && !TextUtils.isEmpty(bean.getStartColor())) {
@@ -823,9 +900,57 @@ public class LiveTextRender {
builder.setSpan(new ForegroundColorSpan(color), length, length + name.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
int lengthContent = builder.length();
+ //这一段先别删,万一后面要改内容换行呢
+ // TODO 试试 “空Unicode”
+ /*sb.clear();
+ TAG = "文字渲染2";
+ String content = bean.getContent();
+ Log.i(TAG, "renderChat: " + content);
+ sb.append(name).append(content);
+ SpannableStringBuilder csb = null;
+ measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
+ sb.clear();
+ sb.append(prefixName);
+ prefixEmpty = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
+ StringBuilder stringBuilder = new StringBuilder();
+ if (measuredText > width) {
+ sb.clear();
+ sb.append(name);
+ float lineWidth = 0;
+ for (int i = 0; i < content.length(); i++) {
+ char charAt = content.charAt(i);
+ sb.append(charAt);
+ lineWidth += textView.getPaint().measureText(String.valueOf(charAt)) + prefixEmpty;
+ prefixEmpty = 0;
+ textView.setText(sb);
+ Log.i(TAG, "renderChat: TextView是否换行:" + textView.getText().toString().split("\n").length);
+ Log.i(TAG, "逐测算|" + lineWidth + " width|" + width + "|" + sb.toString());
+ if (lineWidth > width) {
+ Log.i(TAG, "renderChat: 换行:" + charAt);
+ if (!stringBuilder.toString().endsWith("\n")) {
+ stringBuilder.append("\n");
+ }
+ lineWidth = 0;
+ --i;
+ } else {
+ Log.i(TAG, "renderChat: 直接加入:" + charAt);
+ stringBuilder.append(content.charAt(i));
+ }
+
+ }
+ if (stringBuilder.toString().endsWith("\n")) {
+ Log.i(TAG, "需要删除回车");
+ stringBuilder.deleteCharAt(stringBuilder.length() - 1);
+ }
+ Log.i(TAG, "分行后内容:" + stringBuilder.toString());
+ bean.setContent(stringBuilder.toString());
+ }
+*/
+
builder.append(bean.getContent());
//超皇设置渐变色展示昵称
if (TextUtils.equals("7", bean.getNobleId()) && !TextUtils.isEmpty(bean.getContentColor())) {
+ Log.i(TAG, "lengthContent: " + lengthContent + "|content: " + bean.getContent().length() + "|max: " + (lengthContent + bean.getContent().length()));
builder.setSpan(new ForegroundColorSpan(Color.parseColor(bean.getContentColor())), lengthContent, lengthContent + bean.getContent().length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
if (bean.getType() == LiveChatBean.LIGHT) {
@@ -837,6 +962,7 @@ public class LiveTextRender {
builder.setSpan(new VerticalImageSpan(heartDrawable), length - 1, length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
+ //textView.setText("");
return builder;
}
@@ -889,7 +1015,7 @@ public class LiveTextRender {
if (textView != null) {
createPrefix(drawable, bean, new CreatePrefixCallback() {
@Override
- public void onPrefixCallback(SpannableStringBuilder builder) {
+ public void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth) {
int start = builder.length();
String name = bean.getUserNiceName() + " ";
builder.append(name);
@@ -904,15 +1030,15 @@ public class LiveTextRender {
@Override
public void onLoadFailed() {
if (textView != null) {
- createPrefix(null, bean, new CreatePrefixCallback() {
- @Override
- public void onPrefixCallback(SpannableStringBuilder builder) {
- int start = builder.length();
- String name = bean.getUserNiceName() + " ";
- builder.append(name);
- textView.setText(builder);
- }
- });
+ createPrefix(null, bean, new CreatePrefixCallback() {
+ @Override
+ public void onPrefixCallback(SpannableStringBuilder builder, int prefixWidth) {
+ int start = builder.length();
+ String name = bean.getUserNiceName() + " ";
+ builder.append(name);
+ textView.setText(builder);
+ }
+ });
}
}
diff --git a/live/src/main/java/com/yunbao/live/views/AbsRyLivePushViewHolder.java b/live/src/main/java/com/yunbao/live/views/AbsRyLivePushViewHolder.java
index 2b1c7e4f2..ca097bcf6 100644
--- a/live/src/main/java/com/yunbao/live/views/AbsRyLivePushViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/AbsRyLivePushViewHolder.java
@@ -11,6 +11,8 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.fragment.app.Fragment;
+
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.utils.L;
import com.yunbao.common.views.AbsViewHolder;
@@ -30,7 +32,7 @@ public class AbsRyLivePushViewHolder extends AbsViewHolder implements ILivePushV
protected ViewGroup mBigContainer;
protected ViewGroup mSmallContainer;
protected ViewGroup mLeftContainer;
- protected ViewGroup mRightContainer;
+ protected FrameLayout mRightContainer;
protected ViewGroup mPkContainer;
public FrameLayout mPreView, mPreView1, cameraPreview3, dr1_preview, dr2_preview, dr3_preview, dr4_preview;
public ImageView leave;
@@ -59,7 +61,7 @@ public class AbsRyLivePushViewHolder extends AbsViewHolder implements ILivePushV
mBigContainer = (ViewGroup) findViewById(R.id.big_container);
mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
- mRightContainer = (ViewGroup) findViewById(R.id.right_container);
+ mRightContainer = (FrameLayout) findViewById(R.id.right_container);
mPkContainer = (ViewGroup) findViewById(R.id.pk_container);
mCameraFront = true;
String mBeautySdkType = CommonAppConfig.getInstance().getBeautySdkType();
diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java
index 2fe06d5bf..fdf3883ba 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java
@@ -68,6 +68,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Random;
+import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
@@ -103,7 +104,6 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
initLittlePanda();
}
-
@Override
protected int getLayoutId() {
return R.layout.view_live_audience;
@@ -791,6 +791,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
* 退出直播间
*/
private void close() {
+ SWAuManager.get().exitChannelAll();
handler.removeCallbacks(runnable);
handler1.removeCallbacks(runnable1);
((LiveAudienceActivity) mContext).onBackPressed();
diff --git a/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java
index 727b38003..fd8598955 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveEndViewHolder.java
@@ -37,6 +37,7 @@ import com.yunbao.live.R;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.adapter.SearchRecommendBodyAdapter;
import com.yunbao.live.event.JumpUserHomeEvent;
import com.yunbao.common.event.LiveRoomChangeEvent;
@@ -230,13 +231,12 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
goHomeUser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (mContext instanceof LiveAnchorActivity) {
- ((LiveAnchorActivity) mContext).superBackPressed();
+ if (mContext instanceof LiveRyAnchorActivity) {
+ ((LiveRyAnchorActivity) mContext).superBackPressed();
} else if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).exitLiveRoom();
- } else if (mContext instanceof LiveRyAnchorActivity) {
- ((LiveRyAnchorActivity) mContext).superBackPressed();
-
+ } else if (mContext instanceof LiveSwAnchorActivity) {
+ ((LiveSwAnchorActivity) mContext).superBackPressed();
}
Bus.get().post(new CloseEvent());
}
@@ -262,13 +262,12 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (mContext instanceof LiveAnchorActivity) {
- ((LiveAnchorActivity) mContext).superBackPressed();
+ if (mContext instanceof LiveRyAnchorActivity) {
+ ((LiveRyAnchorActivity) mContext).superBackPressed();
} else if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).exitLiveRoom();
- } else if (mContext instanceof LiveRyAnchorActivity) {
- ((LiveRyAnchorActivity) mContext).superBackPressed();
-
+ } else if (mContext instanceof LiveSwAnchorActivity) {
+ ((LiveSwAnchorActivity) mContext).superBackPressed();
}
Bus.get().post(new CloseEvent());
}
@@ -365,9 +364,10 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
((LiveAnchorActivity) mContext).superBackPressed();
} else if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).exitLiveRoom();
- } else if (mContext instanceof LiveRyAnchorActivity) {
+ } else if (mContext instanceof LiveSwAnchorActivity) {
+ ((LiveSwAnchorActivity) mContext).superBackPressed();
+ }else if(mContext instanceof LiveRyAnchorActivity){
((LiveRyAnchorActivity) mContext).superBackPressed();
-
}
Bus.get().post(new CloseEvent());
}
@@ -424,7 +424,7 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (liveBean == null) {
return;
}
@@ -448,7 +448,9 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
((LiveAnchorActivity) mContext).superBackPressed();
} else if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).exitLiveRoom();
- } else if (mContext instanceof LiveRyAnchorActivity) {
+ } else if (mContext instanceof LiveSwAnchorActivity) {
+ ((LiveSwAnchorActivity) mContext).superBackPressed();
+ }else if(mContext instanceof LiveRyAnchorActivity){
((LiveRyAnchorActivity) mContext).superBackPressed();
}
}
diff --git a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java
index c40b07bf1..3d25e452b 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveNewReadyRyViewHolder.java
@@ -941,7 +941,7 @@ public class LiveNewReadyRyViewHolder extends AbsViewHolder implements View.OnCl
return;
}
String title = mEditTitle.getText().toString().trim();
- LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, IMLoginManager.get(mContext).getSelectClarity() + 1, new HttpCallback() {
+ LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, IMLoginManager.get(mContext).getSelectClarity() + 1, false,new HttpCallback() {
@Override
public void onSuccess(int code, String msg, final String[] info) {
if (code == 0 && info.length > 0) {
diff --git a/live/src/main/java/com/yunbao/live/views/LiveNewReadySwViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveNewReadySwViewHolder.java
new file mode 100644
index 000000000..44a9a4d5d
--- /dev/null
+++ b/live/src/main/java/com/yunbao/live/views/LiveNewReadySwViewHolder.java
@@ -0,0 +1,963 @@
+package com.yunbao.live.views;
+
+import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.WISH_LIST_UPDATE;
+
+import android.app.Dialog;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.text.Html;
+import android.text.TextUtils;
+import android.util.Log;
+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.IMLoginModel;
+import com.yunbao.common.bean.LiveAnchorCallMeModel;
+import com.yunbao.common.bean.LiveAnchorSayModel;
+import com.yunbao.common.bean.LiveClassBean;
+import com.yunbao.common.bean.LiveRoomTypeBean;
+import com.yunbao.common.bean.UserBean;
+import com.yunbao.common.event.LivePushRyEvent;
+import com.yunbao.common.glide.ImgLoader;
+import com.yunbao.common.http.HttpCallback;
+import com.yunbao.common.http.LiveHttpConsts;
+import com.yunbao.common.http.LiveHttpUtil;
+import com.yunbao.common.interfaces.CommonCallback;
+import com.yunbao.common.interfaces.ImageResultCallback;
+import com.yunbao.common.interfaces.OnItemClickListener;
+import com.yunbao.common.manager.IMLoginManager;
+import com.yunbao.common.utils.Bus;
+import com.yunbao.common.utils.DialogUitl;
+import com.yunbao.common.utils.L;
+import com.yunbao.common.utils.ProcessImageUtil;
+import com.yunbao.common.utils.RouteUtil;
+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.LiveNewWishListPopup;
+import com.yunbao.common.views.LiveOpenCustomPopup;
+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;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
+import com.yunbao.live.dialog.LiveAnchorEditCallMeDialog;
+import com.yunbao.live.dialog.LiveAnchorSayPopDialog;
+import com.yunbao.live.dialog.LiveFaceUnityDialogFragment;
+import com.yunbao.live.dialog.LiveFaceUnityDialogNewFragment;
+import com.yunbao.live.dialog.LiveNewRoomClassDialogFragment;
+import com.yunbao.live.dialog.LiveNewRoomTypeDialogFragment;
+import com.yunbao.live.dialog.LiveTimeDialogFragment;
+import com.yunbao.live.event.LiveAudienceEvent;
+
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.io.File;
+import java.util.Locale;
+
+import io.agora.beautyapi.faceunity.agora.SWManager;
+
+public class LiveNewReadySwViewHolder extends AbsViewHolder implements View.OnClickListener {
+
+ private ConstraintLayout mAvatar, mRootView;
+ private TextView mCoverText;
+ private EditText mEditTitle;
+ private ProcessImageUtil mImageUtil;
+ private File mAvatarFile;
+ private TextView mLiveClass, anchorAgreement;
+ private TextView mLiveTypeTextView, liveClarity;//房间类型TextView
+ private TextView mLiveWishListTextView;//心愿单TextView
+ private int mLiveClassID;//直播频道id
+ private int mLiveType;//房间类型
+ private int mLiveTypeVal;//房间密码,门票收费金额
+ private int mLiveTimeCoin;//计时收费金额
+ private boolean mOpenLocation = true;
+ private int mLiveSdk;
+ private LiveClassBean classBean;
+ private FaceManager manager;
+ private TextView faceTextView;//提示人脸未检测到的TextView
+ private ImageView imgClarity, selectorProtocol;
+ private int selectClarity = 1;
+ private LiveOpenCustomPopup liveOpenCustomPopup;
+ private boolean selector = true;
+ private String mLiveUid;
+
+ public LiveNewReadySwViewHolder(Context context, ViewGroup parentView, int liveSdk) {
+ super(context, parentView, liveSdk);
+ }
+
+ @Override
+ protected void processArguments(Object... args) {
+ if (args.length > 0) {
+ mLiveSdk = (int) args[0];
+ }
+ }
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.view_new_live_ready;
+ }
+
+ @Override
+ public void init() {
+ mRootView = (ConstraintLayout) findViewById(R.id.traceroute_rootview);
+ imgClarity = (ImageView) findViewById(R.id.img_clarity);
+ selectorProtocol = (ImageView) findViewById(R.id.selector_protocol);
+ liveClarity = (TextView) findViewById(R.id.live_clarity);
+ anchorAgreement = (TextView) findViewById(R.id.anchor_agreement);
+ mRootView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ InputMethodManager imm = (InputMethodManager)
+ mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
+ }
+ });
+
+ mAvatar = (ConstraintLayout) findViewById(R.id.avatar);
+ mAvatar.setOnClickListener(this);
+ UserBean u = CommonAppConfig.getInstance().getUserBean();
+ ImgLoader.displayDrawable(mContext, u.getAvatar(), new ImgLoader.DrawableCallback() {
+ @Override
+ public void onLoadSuccess(Drawable drawable) {
+ mAvatar.setBackground(drawable);
+ }
+
+ @Override
+ public void onLoadFailed() {
+
+ }
+ });
+ mCoverText = (TextView) findViewById(R.id.cover_text);
+ mEditTitle = (EditText) findViewById(R.id.edit_title);
+ findViewById(R.id.btn_room_type).setOnClickListener(this);
+ mOpenLocation = true;
+ mLiveClass = (TextView) findViewById(R.id.live_class);
+ mLiveTypeTextView = (TextView) findViewById(R.id.text_room_type);
+ mLiveWishListTextView = (TextView) findViewById(R.id.text_wishlist);
+ faceTextView = (TextView) findViewById(R.id.faceTextView);
+
+ mImageUtil = ((LiveActivity) mContext).getProcessImageUtil();
+ mImageUtil.setImageResultCallback(new ImageResultCallback() {
+
+ @Override
+ public void beforeCamera() {
+ ((LiveSwAnchorActivity) mContext).beforeCamera();
+ }
+
+ @Override
+ public void onSuccess(File file) {
+ if (file != null) {
+ ImgLoader.displayFileDrawable(mContext, file, new ImgLoader.DrawableCallback() {
+ @Override
+ public void onLoadSuccess(Drawable drawable) {
+ mAvatar.setBackground(drawable);
+ }
+
+ @Override
+ public void onLoadFailed() {
+
+ }
+ });
+ if (mAvatarFile == null) {
+ mCoverText.setText(mContext.getString(R.string.live_cover_2));
+ mCoverText.setBackground(ContextCompat.getDrawable(mContext, R.drawable.bg_live_cover));
+ }
+ mAvatarFile = file;
+ }
+ }
+
+ @Override
+ public void onFailure() {
+ }
+ });
+ findViewById(R.id.btn_camera).setOnClickListener(this);
+ findViewById(R.id.btn_live_class).setOnClickListener(this);
+ findViewById(R.id.btn_close).setOnClickListener(this);
+ findViewById(R.id.btn_beauty).setOnClickListener(this);
+ findViewById(R.id.btn_robot).setOnClickListener(this);
+ findViewById(R.id.btn_start_live).setOnClickListener(this);
+ findViewById(R.id.btn_wishlist).setOnClickListener(this);
+ findViewById(R.id.btn_horizontally).setOnClickListener(this);
+ findViewById(R.id.anchor_agreement_layout).setOnClickListener(this);
+ findViewById(R.id.btn_live_anchor_say).setOnClickListener(this);
+ findViewById(R.id.btn_live_anchor_call_me).setOnClickListener(this);
+
+ if (manager != null) {
+ manager.setFaceStatusChanged(new FaceManager.FaceStatusChanged() {
+ final Handler handler = new Handler(Looper.getMainLooper());
+
+ @Override
+ public void onFaceChanged(int num) {
+ handler.post(() -> {
+ if (num == 0) {
+ faceTextView.setVisibility(View.VISIBLE);
+ } else {
+ faceTextView.setVisibility(View.GONE);
+ }
+ });
+ }
+ });
+ //新美颜
+ setFaceUnity(true);
+
+ }
+ //设置清晰度
+// DeviceUtils.getMemory(mContext); //获取可用内存
+// DeviceUtils.getNetSpeed(mContext);//获取当前上传网速
+// Log.e("网速和内存", "内存:" + + " 网速:" + DeviceUtils.getNetSpeed(mContext));
+
+ IMLoginManager.get(mContext).setSelectClarity(selectClarity);
+ //setSelectClarity(IMLoginManager.get(mContext).getSelectClarity());
+ ViewClicksAntiShake
+ .clicksAntiShake(
+ findViewById(R.id.btn_live_clarity), () -> {
+
+ LiveClarityCustomPopup liveClarityCustomPopup =
+ new LiveClarityCustomPopup(mContext,
+ IMLoginManager.get(mContext).getSelectClarity(),
+ IMLoginManager.get(mContext).getClarity() ? 0 : LiveClarityCustomPopup.BAN_1080, false);
+ 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();
+ });
+ String keywordHtml2 = "" + mContext.getString(R.string.anchor_hint) + "";
+ String contextHtml = "" + mContext.getString(R.string.anchor_agreement) + "";
+ anchorAgreement.setText(Html.fromHtml(contextHtml + keywordHtml2));
+ selectorProtocol.setPressed(true);
+ selectorProtocol.setSelected(true);
+ selector = selectorProtocol.isSelected();
+ selectorProtocol.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ selector = !selector;
+ selectorProtocol.setSelected(selector);
+ }
+ });
+ }
+
+ 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;
+ }
+ if (liveOpenCustomPopup != null) {
+ liveOpenCustomPopup.setSelectClarity(selectClarity);
+ }
+ //SWManager.get().setDimensions(selectClarity);
+ Log.e("切换分辨率", "时间戳" + System.currentTimeMillis());
+ //重新发布一下流
+ Bus.get().post(new LivePushRyEvent());
+ }
+
+ public void setManager(FaceManager manager) {
+ this.manager = manager;
+ }
+
+
+ @Override
+ public void onClick(View v) {
+ if (!canClick()) {
+ return;
+ }
+ int i = v.getId();
+ if (i == R.id.avatar) {
+ setAvatar();
+
+ } else if (i == R.id.btn_camera) {
+ toggleCamera();
+ } else if (i == R.id.btn_close) {
+ close();
+ } else if (i == R.id.btn_live_class) {
+ chooseLiveClass();
+ } else if (i == R.id.btn_beauty) {
+ //beauty();//momo美颜
+ setFaceUnity(false); //新娱美颜
+ } else if (i == R.id.btn_wishlist) {
+ //点击心愿单
+ openWishListWindow();
+ } else if (i == R.id.btn_room_type) {
+ chooseLiveType();
+ } else if (i == R.id.btn_start_live) {
+ if (!selector) {
+ ToastUtil.show(mContext.getString(R.string.anchor_agreement_hint));
+ return;
+ }
+ if (mLiveClassID == 0) {
+ ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
+ return;
+ }
+// startLive();
+ liveOpenCustomPopup = new LiveOpenCustomPopup(mContext, IMLoginManager.get(mContext).getSelectClarity(), classBean, liveRoomTypeBean)
+ .setSayStatus(IMLoginManager.get(mContext).getAnchorSayStatus())
+ .setCallMeStatus(IMLoginManager.get(mContext).getAnchorCallStatus())
+ .setCallBack(new LiveOpenCustomPopup.LiveOpenCallBack() {
+ @Override
+
+ public void startLive(LiveRoomTypeBean liveRoomTypeModel, LiveClassBean classModel) {
+ if (classModel != null) {
+ classBean = classModel;
+ mLiveClassID = classBean.getId();
+ }
+ liveRoomTypeBean = liveRoomTypeModel;
+ mLiveType = liveRoomTypeModel.getId();
+ startLiveInit();
+ liveOpenCustomPopup = null;
+ }
+
+ @Override
+ public void selectClarity(int selectClarity) {
+ LiveClarityCustomPopup liveClarityCustomPopup =
+ new LiveClarityCustomPopup(mContext,
+ IMLoginManager.get(mContext).getSelectClarity(),
+ IMLoginManager.get(mContext).getClarity() ? 0 : LiveClarityCustomPopup.BAN_1080, false);
+ 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();
+ }
+
+ @Override
+ public void openRobot() {
+ LiveRobotSettingCustomPopup liveRobotSettingCustomPopup = new LiveRobotSettingCustomPopup(mContext);
+ 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) {
+ if (liveOpenCustomPopup != null) {
+ liveOpenCustomPopup.initDate();
+ }
+ }
+
+ @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(liveRobotSettingCustomPopup)
+ .show();
+ }
+
+ @Override
+ public void openLiveRoomType(LiveRoomTypeBean liveRoomTypeModel) {
+ liveRoomTypeBean = liveRoomTypeModel;
+ mLiveType = liveRoomTypeModel.getId();
+ chooseLiveType();
+ }
+
+ @Override
+ public void openLiveClass(LiveClassBean classModel) {
+ if (classModel != null) {
+ classBean = classModel;
+ mLiveClassID = classBean.getId();
+ }
+ chooseLiveClass();
+ }
+
+ @Override
+ public void openWishlist() {
+ //点击心愿单
+ openWishListWindow();
+ }
+
+ @Override
+ public void openAnchorSay() {
+ openAnchorSayDialog();
+ }
+
+ @Override
+ public void openCallMe() {
+ openAnchorCallMeDialog();
+ }
+ });
+ new XPopup.Builder(mContext)
+ .asCustom(liveOpenCustomPopup)
+ .show();
+ } else if (i == R.id.btn_locaiton) {
+ switchLocation();
+ } else if (i == R.id.btn_horizontally) {
+ SWManager.get().setMirrorMode();
+ } else if (i == R.id.btn_robot) {
+ new XPopup.Builder(mContext)
+ .asCustom(new LiveRobotSettingCustomPopup(mContext))
+ .show();
+ } else if (i == R.id.anchor_agreement_layout) {
+ String ct = Locale.getDefault().getLanguage();
+ IMLoginModel model = IMLoginManager.get(mContext).getUserInfo();
+ StringBuffer url = new StringBuffer();
+ url.append(CommonAppConfig.HOST);
+ if (TextUtils.equals(ct, "zh")) {
+ url.append("/index.php?g=portal&m=page&a=index&id=671");
+ } else {
+ url.append("/index.php?g=portal&m=page&a=index&id=672");
+ }
+ url.append("&uid=")
+ .append(model.getId())
+ .append("&token=")
+ .append(model.getToken()).append("&isZh=")
+ .append(WordUtil.isNewZh() ? "1" : 0);
+ RouteUtil.forwardLiveZhuangBanActivity(url.toString(), false);
+ } else if (i == R.id.btn_live_anchor_say) {
+ openAnchorSayDialog();
+ } else if (i == R.id.btn_live_anchor_call_me) {
+ openAnchorCallMeDialog();
+ }
+ }
+
+ /**
+ * 新娱美颜
+ */
+ public void setFaceUnity(boolean init) {
+ LiveFaceUnityDialogFragment fragment = new LiveFaceUnityDialogFragment(mContext);
+ fragment.setManager(manager);
+ fragment.setDismissShowUi(mRootView);
+ if (mContext instanceof LiveSwAnchorActivity) {
+ fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "FaceUnity");
+ mRootView.setVisibility(View.INVISIBLE);
+ if (init) {
+ fragment.dismiss();
+ }
+ }
+ }
+
+ public void setFaceUnityNew(boolean init){
+ LiveFaceUnityDialogNewFragment fragment = new LiveFaceUnityDialogNewFragment(mContext);
+ fragment.setManager(manager);
+ fragment.setDismissShowUi(mRootView);
+ if (mContext instanceof LiveSwAnchorActivity) {
+ fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "FaceUnity");
+ mRootView.setVisibility(View.INVISIBLE);
+ if (init) {
+ fragment.dismiss();
+ }
+ }
+ }
+
+
+ /**
+ * 打开心愿单窗口
+ */
+ public void openWishListWindow() {
+// LiveNewWishListDialogFragment fragment = new LiveNewWishListDialogFragment();
+//
+// if (mContext instanceof LiveRyAnchorActivity) {
+// fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "RY");
+//
+// }
+ new XPopup.Builder(mContext)
+ .enableDrag(false)
+ .asCustom(new LiveNewWishListPopup((LiveSwAnchorActivity) mContext))
+ .show();
+ }
+
+ public void openAnchorSayDialog() {
+ new LiveAnchorSayPopDialog(mContext).setLiveUid(mLiveUid).setOnItemClickListener(new OnItemClickListener() {
+ @Override
+ public void onItemClick(LiveAnchorSayModel bean, int position) {
+ if (liveOpenCustomPopup != null) {
+ liveOpenCustomPopup.setSayStatus(bean.getLivePreview().getIsShow() == 1);
+ }
+ }
+ }).showDialog();
+ }
+
+ public void openAnchorCallMeDialog() {
+ new LiveAnchorEditCallMeDialog(mContext).setLiveUid(mLiveUid).setOnItemClickListener(new OnItemClickListener() {
+ @Override
+ public void onItemClick(LiveAnchorCallMeModel bean, int position) {
+ if (liveOpenCustomPopup != null) {
+ liveOpenCustomPopup.setCallMeStatus(bean.getIsShow() == 1);
+ }
+ }
+ }).showDialog();
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void updateStart(LiveAudienceEvent event) {
+ if (event.getType() == WISH_LIST_UPDATE) {
+ if (liveOpenCustomPopup != null) {
+ liveOpenCustomPopup.initDate();
+ }
+ }
+ }
+
+ /**
+ * 打开 关闭位置
+ */
+ private void switchLocation() {
+ if (mOpenLocation) {
+ new DialogUitl.Builder(mContext)
+ .setContent(mContext.getString(R.string.live_location_close_3))
+ .setCancelable(true)
+ .setConfirmString(mContext.getString(R.string.live_location_close_2))
+ .setClickCallback(new DialogUitl.SimpleCallback() {
+
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ toggleLocation();
+ }
+ })
+ .build()
+ .show();
+ } else {
+ toggleLocation();
+ }
+ }
+
+ private void toggleLocation() {
+ mOpenLocation = !mOpenLocation;
+ }
+
+ /**
+ * 设置头像
+ */
+ private void setAvatar() {
+ if (mLiveSdk == Constants.LIVE_SDK_TX) {
+ mImageUtil.getImageByAlumb();
+ } else {
+ DialogUitl.showStringArrayDialog(mContext, new Integer[]{
+ R.string.camera, R.string.alumb}, new DialogUitl.StringArrayDialogCallback() {
+ @Override
+ public void onItemClick(String text, int tag) {
+ if (tag == R.string.camera) {
+ mImageUtil.getImageByCamera();
+ } else {
+ mImageUtil.getImageByAlumb();
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * 切换镜头
+ */
+ private void toggleCamera() {
+ ((LiveSwAnchorActivity) mContext).toggleCamera();
+ }
+
+ /**
+ * 关闭
+ */
+ private void close() {
+ ((LiveSwAnchorActivity) mContext).endLives();
+ }
+
+ /**
+ * 选择直播频道
+ */
+ private void chooseLiveClass() {
+ /* try {
+ Intent intent = new Intent(mContext, LiveChooseClassActivity.class);
+ intent.putExtra(Constants.CLASS_ID, mLiveClassID);
+ mImageUtil.startActivityForResult(intent, mActivityResultCallback);
+ }catch (Exception e){
+
+ }*/
+
+ Bundle bundle = new Bundle();
+ bundle.putInt(Constants.CLASS_ID, mLiveClassID);
+ LiveNewRoomClassDialogFragment fragment = new LiveNewRoomClassDialogFragment();
+ fragment.setArguments(bundle);
+ fragment.setCallback(new CommonCallback() {
+ @Override
+ public void callback(LiveClassBean bean) {
+ classBean = bean;
+ mLiveClassID = classBean.getId();
+ mLiveClass.setText(bean.getName());
+ if (liveOpenCustomPopup != null) {
+ liveOpenCustomPopup.setClassBean(classBean);
+ }
+ }
+ });
+ fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
+
+ }
+
+ /**
+ * 设置美颜
+ */
+ private void beauty() {
+ ((LiveSwAnchorActivity) mContext).beauty();
+ // Intent intent = new Intent(mContext, Beauty360Activity3.class);
+ // mContext.startActivity(intent);
+
+ }
+
+ /**
+ * 选择直播类型
+ */
+ private LiveRoomTypeBean liveRoomTypeBean = new LiveRoomTypeBean(0, mContext.getString(R.string.live_room_public));
+
+ private void chooseLiveType() {
+ Bundle bundle = new Bundle();
+ bundle.putInt(Constants.CHECKED_ID, mLiveType);
+ LiveNewRoomTypeDialogFragment fragment = new LiveNewRoomTypeDialogFragment();
+ fragment.setArguments(bundle);
+ fragment.setCallback(new CommonCallback() {
+ @Override
+ public void callback(LiveRoomTypeBean bean) {
+ liveRoomTypeBean = bean;
+ switch (bean.getId()) {
+ case Constants.LIVE_TYPE_NORMAL:
+ onLiveTypeNormal(bean);
+ break;
+ case Constants.LIVE_TYPE_PWD:
+ onLiveTypePwd(bean);
+ break;
+ case Constants.LIVE_TYPE_PAY:
+ onLiveTypePay(bean);
+ break;
+ case Constants.LIVE_TYPE_TIME:
+ onLiveTypeTime(bean);
+ break;
+ }
+ if (liveOpenCustomPopup != null) {
+ liveOpenCustomPopup.setLiveRoomTypeBean(liveRoomTypeBean);
+ }
+ }
+ });
+ fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
+ }
+
+ /**
+ * 普通房间
+ */
+ private void onLiveTypeNormal(LiveRoomTypeBean bean) {
+ mLiveType = bean.getId();
+ mLiveTypeTextView.setText(bean.getName());
+ mLiveTypeVal = 0;
+ mLiveTimeCoin = 0;
+ }
+
+ /**
+ * 密码房间
+ */
+ private void onLiveTypePwd(final LiveRoomTypeBean bean) {
+ DialogUitl.showSimpleInputDialog(mContext, mContext.getString(R.string.live_set_pwd), DialogUitl.INPUT_TYPE_NUMBER_PASSWORD, 8, new DialogUitl.SimpleCallback() {
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ if (TextUtils.isEmpty(content)) {
+ ToastUtil.show(mContext.getString(R.string.live_set_pwd_empty));
+ } else {
+ mLiveType = bean.getId();
+ mLiveTypeTextView.setText(WordUtil.isNewZh() ? "密碼房" : "password room");
+ if (StringUtil.isInt(content)) {
+ mLiveTypeVal = Integer.parseInt(content);
+ }
+ mLiveTimeCoin = 0;
+ dialog.dismiss();
+ }
+ }
+ });
+ }
+
+ /**
+ * 付费房间
+ */
+ private void onLiveTypePay(final LiveRoomTypeBean bean) {
+ DialogUitl.showSimpleInputDialog(mContext, mContext.getString(R.string.live_set_fee), DialogUitl.INPUT_TYPE_NUMBER, 8, new DialogUitl.SimpleCallback() {
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ if (TextUtils.isEmpty(content)) {
+ ToastUtil.show(mContext.getString(R.string.live_set_fee_empty));
+ } else {
+ mLiveType = bean.getId();
+ mLiveTypeTextView.setText(bean.getName());
+ if (StringUtil.isInt(content)) {
+ mLiveTypeVal = Integer.parseInt(content);
+ }
+ mLiveTimeCoin = 0;
+ dialog.dismiss();
+ }
+ }
+ });
+ }
+
+ /**
+ * 计时房间
+ */
+ private void onLiveTypeTime(final LiveRoomTypeBean bean) {
+ LiveTimeDialogFragment fragment = new LiveTimeDialogFragment();
+ Bundle bundle = new Bundle();
+ bundle.putInt(Constants.CHECKED_COIN, mLiveTimeCoin);
+ fragment.setArguments(bundle);
+ fragment.setCommonCallback(new CommonCallback() {
+ @Override
+ public void callback(Integer coin) {
+ mLiveType = bean.getId();
+ mLiveTypeTextView.setText(bean.getName());
+ mLiveTypeVal = coin;
+ mLiveTimeCoin = coin;
+ }
+ });
+ fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveTimeDialogFragment");
+ }
+
+ public void hide() {
+ if (mContentView != null && mContentView.getVisibility() == View.VISIBLE) {
+ mContentView.setVisibility(View.INVISIBLE);
+ }
+ }
+
+
+ public void show() {
+ if (mContentView != null && mContentView.getVisibility() != View.VISIBLE) {
+ mContentView.setVisibility(View.VISIBLE);
+ }
+ }
+
+ /**
+ * 点击开始直播按钮
+ */
+ private void startLiveInit() {
+ if (isWifiProxy(mContext) || checkVPN((ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE))) {
+ ToastUtil.show(WordUtil.isNewZh()?"檢測開啓了VPN或者代理,請先關閉VPN或者代理再開播。":
+ "It is detected that VPN or proxy is turned on. Please turn off VPN or proxy before starting the broadcast.");
+ } else {
+ boolean startPreview = ((LiveSwAnchorActivity) mContext).isStartPreview();
+// if (!startPreview) {
+// ToastUtil.show(R.string.please_wait);
+// return;
+// }
+ if (mLiveClassID == 0) {
+ ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
+ return;
+ }
+ createRoom();
+ }
+ }
+
+ private boolean isWifiProxy(Context context) {
+ final boolean IS_ICS_OR_LATER = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
+ String proxyAddress;
+ int proxyPort;
+ if (IS_ICS_OR_LATER) {
+ proxyAddress = System.getProperty("http.proxyHost");
+ String portStr = System.getProperty("http.proxyPort");
+ proxyPort = Integer.parseInt((portStr != null ? portStr : "-1"));
+ } else {
+ proxyAddress = android.net.Proxy.getHost(context);
+ proxyPort = android.net.Proxy.getPort(context);
+ }
+ return (!TextUtils.isEmpty(proxyAddress)) && (proxyPort != -1);
+ }
+
+ private boolean checkVPN(ConnectivityManager connMgr) {
+ //don't know why always returns null:
+ NetworkInfo networkInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_VPN);
+ boolean isVpnConn = networkInfo == null ? false : networkInfo.isConnected();
+ return isVpnConn;
+ }
+
+ /**
+ * 请求创建直播间接口,开始直播
+ */
+ boolean isHttpBack = false;
+
+ private void createRoom() {
+ if (!isHttpBack) {
+ isHttpBack = true;
+ if (mLiveClassID == 0) {
+ ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
+ return;
+ }
+ String title = mEditTitle.getText().toString().trim();
+ LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, IMLoginManager.get(mContext).getSelectClarity() + 1,true, new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, final String[] info) {
+ if (code == 0 && info.length > 0) {
+ L.e("开播", "createRoom------->" + info[0]);
+ isHttpBack = false;
+ final CommonAppConfig appConfig = CommonAppConfig.getInstance();
+ UserBean u = appConfig.getUserBean();
+ ((LiveSwAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal);
+ } else {
+ ToastUtil.show(msg);
+ }
+ }
+
+ @Override
+ public void onError() {
+ super.onError();
+ isHttpBack = false;
+ }
+ });
+ } else {
+ ToastUtil.show("請求中,請勿重複點擊");
+ }
+ }
+
+ public void release() {
+ mImageUtil = null;
+ }
+
+ @Override
+ public void onDestroy() {
+ LiveHttpUtil.cancel(LiveHttpConsts.CREATE_ROOM);
+ }
+
+ public void setLiveUid(String mLiveUid) {
+ this.mLiveUid = mLiveUid;
+ }
+}
diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java
index 4dc373b50..546f26826 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePlayKsyViewHolder.java
@@ -15,6 +15,7 @@ import com.tencent.live2.V2TXLiveDef;
import com.tencent.live2.V2TXLivePlayer;
import com.tencent.live2.impl.V2TXLivePlayerImpl;
import com.tencent.rtmp.ui.TXCloudVideoView;
+import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.L;
@@ -48,7 +49,6 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
public static int landscape; //1h 2s
public static Context contexts;
-
int screenWidth; // 屏幕宽(像素,如:480px)
int screenHeight; // 屏幕高(像素,如:800p)
@@ -68,7 +68,7 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
@Override
protected int getLayoutId() {
- return R.layout.view_live_play_ksy;
+ return R.layout.view_live_play_sw;
}
@Override
@@ -254,11 +254,55 @@ public class LivePlayKsyViewHolder extends LiveRoomPlayViewHolder {
}
}
+ @Override
+ public void setDrMicInfo(UserBean u) {
+ }
+
@Override
public void setLiveBeanLandscape(int landscape) {
LivePlayKsyViewHolder.landscape =landscape;
}
+ @Override
+ public void endPk() {
+
+ }
+
+ @Override
+ public void endpk(String liveUid) {
+
+ }
+
+ @Override
+ public void initSwEngine(String liveUid) {
+
+ }
+
+ @Override
+ public void removeLiveUid(String uid) {
+
+ }
+
+ @Override
+ public void removeDetailView() {
+
+ }
+
+ @Override
+ public void setPkView(String liveUid) {
+
+ }
+
+ @Override
+ public void claerDrPkInfoView() {
+
+ }
+
+ @Override
+ public void endLiveMic() {
+
+ }
+
@Override
public ViewGroup getSmallContainer() {
diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayListener.java b/live/src/main/java/com/yunbao/live/views/LivePlayListener.java
index befa67854..39359037b 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePlayListener.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePlayListener.java
@@ -12,7 +12,7 @@ public interface LivePlayListener extends LiveActivityLifeCallback {
*
* @param data 房间信息
*/
- void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk);
+ void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk,boolean isSw);
/**
* 用户滑动移除该页面
diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java
index 126ec891c..e6a66e1e7 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java
@@ -31,6 +31,7 @@ import com.lxj.xpopup.interfaces.XPopupCallback;
import com.lzf.easyfloat.EasyFloat;
import com.lzy.okserver.OkDownload;
import com.yunbao.common.bean.EnterRoomNewModel;
+import com.yunbao.common.bean.UserBean;
import com.yunbao.common.dialog.LiveFontSizeSettingDialog;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient;
@@ -409,6 +410,26 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
mCover.requestLayout();
}
+ @Override
+ public void endPk() {
+
+ }
+
+ @Override
+ public void endpk(String liveUid) {
+
+ }
+
+ @Override
+ public void initSwEngine(String liveUid) {
+
+ }
+
+ @Override
+ public void removeLiveUid(String uid) {
+
+ }
+
@Override
public void release() {
mEnd = true;
@@ -567,6 +588,11 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
// }
}
+ @Override
+ public void setDrMicInfo(UserBean u) {
+
+ }
+
public void removeDetailView() {
// if (detailsView != null) {
// mVideoView.removeView(detailsView);
@@ -574,6 +600,21 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
// }
}
+ @Override
+ public void setPkView(String liveUid) {
+
+ }
+
+ @Override
+ public void claerDrPkInfoView() {
+
+ }
+
+ @Override
+ public void endLiveMic() {
+
+ }
+
@Override
public ViewGroup getSmallContainer() {
return mSmallContainer;
@@ -629,7 +670,10 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(DpUtil.dp2px(24), DpUtil.dp2px(24));
params.addRule(RelativeLayout.CENTER_IN_PARENT);
mLoading.setLayoutParams(params);
- mRoot.addView(mLoading);
+ System.out.println(" changeToBig changeToBig changeToBig"+mLoading.getParent());
+ if(mLoading.getParent()!=mRoot){
+ mRoot.addView(mLoading);
+ }
}
}
diff --git a/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java
new file mode 100644
index 000000000..8ce62f8a6
--- /dev/null
+++ b/live/src/main/java/com/yunbao/live/views/LivePlaySwViewHolder.java
@@ -0,0 +1,1093 @@
+package com.yunbao.live.views;
+
+
+import android.Manifest;
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.Context;
+import android.graphics.Color;
+import android.media.AudioManager;
+import android.os.Build;
+import android.os.Handler;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.android.exoplayer2.ui.StyledPlayerView;
+import com.google.gson.Gson;
+import com.lxj.xpopup.XPopup;
+import com.lxj.xpopup.core.BasePopupView;
+import com.lxj.xpopup.interfaces.XPopupCallback;
+import com.lzf.easyfloat.EasyFloat;
+import com.yunbao.common.CommonAppConfig;
+import com.yunbao.common.Constants;
+import com.yunbao.common.bean.BaseModel;
+import com.yunbao.common.bean.EnterRoomNewModel;
+import com.yunbao.common.bean.UserBean;
+import com.yunbao.common.dialog.LiveFontSizeSettingDialog;
+import com.yunbao.common.http.API;
+import com.yunbao.common.http.HttpCallback;
+import com.yunbao.common.http.HttpClient;
+import com.yunbao.common.http.ResponseModel;
+import com.yunbao.common.interfaces.OnItemClickListener;
+import com.yunbao.common.manager.IMLoginManager;
+import com.yunbao.common.manager.MicUserManager;
+import com.yunbao.common.manager.MicedUserManager;
+import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
+import com.yunbao.common.utils.Bus;
+import com.yunbao.common.utils.DialogUitl;
+import com.yunbao.common.utils.DpUtil;
+import com.yunbao.common.utils.L;
+import com.yunbao.common.utils.MicStatusManager;
+import com.yunbao.common.utils.ScreenDimenUtil;
+import com.yunbao.common.utils.SpUtil;
+import com.yunbao.common.utils.ToastUtil;
+import com.yunbao.common.utils.WordUtil;
+import com.yunbao.common.views.LiveClarityCustomPopup;
+import com.yunbao.live.R;
+import com.yunbao.live.activity.LiveActivity;
+import com.yunbao.live.activity.LiveAudienceActivity;
+import com.yunbao.live.bean.DrPkbean;
+import com.yunbao.live.event.LiveAudienceEvent;
+import com.yunbao.live.socket.SocketSendBean;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import cn.rongcloud.rtc.api.stream.RCRTCInputStream;
+import io.agora.beautyapi.faceunity.agora.SWAuManager;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.functions.Consumer;
+import io.reactivex.schedulers.Schedulers;
+import io.rong.imkit.IMCenter;
+import io.rong.imlib.IRongCallback;
+import io.rong.imlib.RongIMClient;
+import io.rong.imlib.model.Conversation;
+import io.rong.imlib.model.Message;
+import io.rong.message.TextMessage;
+
+public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
+
+ private static final String TAG = "LivePlayViewHolder";
+ private ViewGroup mRoot;
+ private ViewGroup mSmallContainer;
+ private ViewGroup mLeftContainer;
+ private ViewGroup mRightContainer;
+ private ViewGroup mPkContainer;
+ public StyledPlayerView mVideoView;
+
+ private View mLoading, mLoading2;
+ private ImageView mCover;
+ private boolean mPaused;//是否切后台了
+ private boolean mStarted;//是否开始了播放
+ private boolean mEnd;//是否结束了播放
+ public static ImageView leave;
+
+ private boolean mPausedPlay;//是否被动暂停了播放
+ public int landscape; //1h 2s
+ public Context contexts;
+ public FrameLayout ry_view;
+
+ private static final int VIDEO_VERTICAL = 2;
+ private static final int VIDEO_HORIZONTAL = 1;
+ int videoLandscape = -1; // 视频方向,2=竖屏,1=横屏
+
+ static int vHeight;//视频高
+ private TextView debugView;
+ //private LiveExoPlayerManager mPlayer;
+ private boolean isPk = false;
+ private boolean userJoinLinkMic = false;//用户是否已加入房间
+
+ //0未申请1申请中2连麦中
+ String purl, srcUrl;
+ SWAuManager swAuManager;
+ String liveUid;
+
+ private LinearLayout dr_pk_view;
+ private FrameLayout dr1_preview;
+ private FrameLayout dr2_preview;
+ private FrameLayout dr3_preview;
+ private FrameLayout dr4_preview;
+
+ private View detailsView1, detailsView2, detailsView3, detailsView4;
+ private LinearLayout detailsLinearLayout1, detailsLinearLayout2, detailsLinearLayout3, detailsLinearLayout4;
+ private LinearLayout linearGrade1, linearGrade2, linearGrade3, linearGrade4;
+ private TextView textPkName1, textPkName2, textPkName3, textPkName4;
+ private TextView textGrade1, textGrade2, textGrade3, textGrade4;
+ private ImageView imageGrade1, imageGrade2, imageGrade3, imageGrade4;
+
+
+ public int getLandscape() {
+ return landscape;
+ }
+
+ public LivePlaySwViewHolder(Context context, ViewGroup parentView, int landscapes) {
+ super(context, parentView);
+ contexts = context;
+ landscape = landscapes;
+ Log.i("收收收", landscape + "");
+ L.eSw("liveUid:" + liveUid);
+ }
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.view_live_play_sw;
+ }
+
+ @Override
+ public void init() {
+ Log.i(TAG, "init: 初始化播放器ViewHolder");
+ EventBus.getDefault().register(this);
+ Bus.getOn(this);
+ mRoot = (ViewGroup) findViewById(R.id.root);
+ mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
+ mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
+ mRightContainer = (ViewGroup) findViewById(R.id.right_container);
+ mPkContainer = (FrameLayout) findViewById(R.id.pk_container);
+ mVideoView = (StyledPlayerView) findViewById(R.id.video_view);
+ ry_view = (FrameLayout) findViewById(R.id.ry_view);
+ leave = (ImageView) findViewById(R.id.leave);
+ mLoading = findViewById(R.id.loading);
+ mLoading2 = findViewById(R.id.loading2);
+ mCover = (ImageView) findViewById(R.id.cover);
+ ScreenDimenUtil util = ScreenDimenUtil.getInstance();
+ int mScreenWdith = util.getScreenWdith();
+ vHeight = mScreenWdith * 720 / 960;
+
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPkContainer.getLayoutParams();
+ params.height = vHeight;
+ mPkContainer.requestLayout();
+
+ debugView = new TextView(mContext);
+ debugView.setBackgroundColor(Color.WHITE);
+
+ dr_pk_view = (LinearLayout) findViewById(R.id.dr_pk_view);
+ dr1_preview = (FrameLayout) findViewById(R.id.dr1_preview);
+ dr2_preview = (FrameLayout) findViewById(R.id.dr2_preview);
+ dr3_preview = (FrameLayout) findViewById(R.id.dr3_preview);
+ dr4_preview = (FrameLayout) findViewById(R.id.dr4_preview);
+ dr_pk_view.setVisibility(View.GONE);
+ }
+
+ public void initSwEngine(String liveUid) {
+ this.liveUid = liveUid;
+ //初始化声网SDK
+ swAuManager = SWAuManager.get();
+ swAuManager.setAudienceContainer(ry_view);
+ swAuManager.initRtcEngine((Activity) mContext);
+ swAuManager.setupRemoteVideo(Integer.parseInt(liveUid));
+ swAuManager.setSwListener(new SWAuManager.SwListener() {
+ @Override
+ public void onUserOffline(int liveUid) {
+ API.get().createPDLiveApi(false)
+ .killDrLm(CommonAppConfig.getInstance().getUid(), String.valueOf(liveUid))
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribeOn(Schedulers.io())
+ .subscribe(new Consumer>() {
+ @Override
+ public void accept(ResponseModel stringResponseModel) throws Exception {
+
+ SocketSendBean socketSendBean = new SocketSendBean()
+ .param("_method_", Constants.LIAN_MAI)
+ .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName())
+ .param("avatar", CommonAppConfig.getInstance().getUserBean().getAvatar())
+ .param("uid", CommonAppConfig.getInstance().getUid());
+
+ ToastUtil.show(mContext.getString(R.string.live_mic_user_down));
+
+ socketSendBean.param("action", 8);
+ socketSendBean.create();
+ Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
+ TextMessage messageContent = TextMessage.obtain(socketSendBean.mResult.toString());
+ io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(CommonAppConfig.getInstance().getUid(), 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", "发送成功");
+
+ IMCenter.getInstance().deleteRemoteMessages(Conversation.ConversationType.PRIVATE, message.getTargetId(), new Message[]{message}, null);
+ IMCenter.getInstance().clearMessagesUnreadStatus(Conversation.ConversationType.PRIVATE, message.getTargetId(), null);
+ MicedUserManager.get().removeMiscUser(CommonAppConfig.getInstance().getUid());
+ }
+
+ @Override
+ public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
+ Log.e("ry", "发送失敗" + errorCode.toString());
+ }
+ });
+
+ }
+ }, Throwable::printStackTrace).isDisposed();
+ }
+ });
+ //进入主播房间
+ swAuManager.joinRoom(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, liveUid, SWAuManager.getChannelName(liveUid));
+ }
+
+ @Override
+ public void removeLiveUid(String uid) {
+ //先结束PK
+ if (drMicUserList != null) {
+ List tempList = new ArrayList<>();
+ int index = -1;
+ for (int i = 0; i < drMicUserList.size(); i++) {
+ if (!drMicUserList.get(i).getId().equals(uid)) {
+ tempList.add(drMicUserList.get(i));
+ }
+ }
+ //结束所有直播
+ endPk();
+ for (int i = 0; i < tempList.size(); i++) {
+ setDrMicInfo(tempList.get(i));
+ }
+ }
+ }
+
+ /**
+ * 开启单人PK
+ *
+ * @param Uid
+ */
+ public void setPkView(String Uid) {
+ L.eSw("setPkView Uid " + Uid);
+ mPkContainer.setVisibility(View.VISIBLE);
+ swAuManager.updateMyChannelView((FrameLayout) mLeftContainer, Integer.parseInt(liveUid));
+ ry_view.removeAllViews();
+ //加入对方主播房间
+ swAuManager.setPkContainer1((FrameLayout) mRightContainer);
+ swAuManager.joinExRoomEx(Integer.parseInt(Uid), CommonAppConfig.SWToken, SWAuManager.getChannelName(Uid));
+ }
+
+ List drMicUserList = new ArrayList<>();
+
+ boolean isAdd = true;
+
+ @Override
+ public void setDrMicInfo(UserBean u) {
+ isAdd = true;
+ L.eSw("setDrMicInfo:-----------------" + u.getId() + " drMicUserList" + new Gson().toJson(drMicUserList));
+ for (int i = 0; i < drMicUserList.size(); i++) {
+ if (u.getId().equals(drMicUserList.get(i).getId()) || u.getId().equals(liveUid)) {
+ isAdd = false;
+ }
+ }
+ L.eSw("setDrMicInfo:---------------isAdd--" + isAdd);
+ //加载多人PK(连麦)主播视图
+ if (isAdd) {
+ dr_pk_view.setVisibility(View.VISIBLE);
+ drMicUserList.add(u);
+ if (drMicUserList.size() == 1) {
+ L.eSw("setDrMicInfo:-----------------drMicUserList.size() == 1");
+ ry_view.removeAllViews();
+ swAuManager.updateMyChannelView((FrameLayout) dr1_preview, Integer.parseInt(liveUid));
+ swAuManager.joinChannelDrEx(dr2_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, u.getId(), SWAuManager.getChannelName(u.getId()));
+ dr1_preview.setVisibility(View.VISIBLE);
+ dr2_preview.setVisibility(View.VISIBLE);
+ dr3_preview.setVisibility(View.GONE);
+ dr4_preview.setVisibility(View.GONE);
+ } else if (drMicUserList.size() == 2) {
+ L.eSw("setDrMicInfo:-----------------drMicUserList.size() == 2");
+ dr4_preview.setVisibility(View.VISIBLE);
+ swAuManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, u.getId(), SWAuManager.getChannelName(u.getId()));
+ } else if (drMicUserList.size() == 3) {
+ L.eSw("setDrMicInfo:-----------------drMicUserList.size() == 3");
+ dr4_preview.setVisibility(View.VISIBLE);
+ dr3_preview.setVisibility(View.VISIBLE);
+ swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), drMicUserList.get(1).getId());
+ swAuManager.joinChannelDrEx(dr3_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drMicUserList.get(1).getId(), SWAuManager.getChannelName(drMicUserList.get(1).getId()));
+ swAuManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drMicUserList.get(2).getId(), SWAuManager.getChannelName(drMicUserList.get(2).getId()));
+ }
+ }
+
+ HttpClient.getInstance().get("Live.getDRPKroom", "Live.getDRPKroom").params("uid", CommonAppConfig.getInstance().getUid()).params("roomid", liveUid).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (info.length > 0) {
+ JSONObject obj = JSONObject.parseObject(info[0]);
+ List drPkbeans = JSONObject.parseArray(obj.getString("userlist"), DrPkbean.class);
+ int removeIndex = -1;
+ for (int i = 0; i < drPkbeans.size(); i++) {
+ if (liveUid.equals(String.valueOf(drPkbeans.get(i).getId()))) {
+ removeIndex = i;
+ }
+ }
+ if (removeIndex != -1) {
+ drPkbeans.remove(removeIndex);
+ }
+ setDrPkView(drPkbeans);
+ }
+ }
+ });
+ }
+
+ public void claerDrPkInfoView() {
+ if (detailsView1 != null) {
+ dr1_preview.removeView(detailsView1);
+ }
+ if (detailsView2 != null) {
+ dr2_preview.removeView(detailsView2);
+ }
+ if (detailsView3 != null) {
+ dr3_preview.removeView(detailsView3);
+ }
+ if (detailsView4 != null) {
+ dr4_preview.removeView(detailsView4);
+ }
+ }
+
+ public void setDrPkView(List drPkbeanList) {
+ if (detailsView1 != null) {
+ dr1_preview.removeView(detailsView1);
+ }
+
+ }
+
+ /**
+ * 退出单人pk
+ *
+ * @param pkUid
+ */
+ public void endpk(String pkUid) {
+ L.eSw("endpk " + pkUid);
+ mPkContainer.setVisibility(View.GONE);
+ swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), SWAuManager.getChannelName(pkUid));
+ swAuManager.updateMyChannelView(ry_view, Integer.parseInt(liveUid));
+ ry_view.setVisibility(View.VISIBLE);
+ mLeftContainer.removeAllViews();
+ mRightContainer.removeAllViews();
+ }
+
+ /**
+ * 退出所有连麦主播的房間
+ */
+ public void endPk() {
+ dr_pk_view.setVisibility(View.GONE);
+ dr1_preview.setVisibility(View.GONE);
+ dr2_preview.setVisibility(View.GONE);
+ dr3_preview.setVisibility(View.GONE);
+ dr4_preview.setVisibility(View.GONE);
+ dr1_preview.removeAllViews();
+ dr2_preview.removeAllViews();
+ dr3_preview.removeAllViews();
+ dr4_preview.removeAllViews();
+ //退出所有连麦主播的房間
+ for (int i = 0; i < drMicUserList.size(); i++) {
+ swAuManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), drMicUserList.get(i).getId());
+ }
+ drMicUserList = new ArrayList<>();
+ //將當前主播畫面放大
+ swAuManager.updateMyChannelView((FrameLayout) ry_view, Integer.parseInt(liveUid));
+ }
+
+ /**
+ * 将用户设置成主播,与主播连麦
+ */
+ private void joinLiveMic() {
+ L.eSw("joinLiveMic");
+ HttpClient.getInstance().get("live.joinDrLm", "live.joinDrLm").params("roomid", LiveActivity.mLiveUid).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ Log.e("ry", code + "热热热");
+ if (code == 0) {
+ MicStatusManager.getInstance().setMicData(MicStatusManager.MIC_TYPE_OPEN, LiveActivity.mLiveUid);
+ AudioManager audioManager = (AudioManager) contexts.getSystemService(Context.AUDIO_SERVICE);
+ audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
+ audioManager.setSpeakerphoneOn(true);
+ swAuManager.setMicAn(true);
+ userJoinLinkMic = true;
+ }
+ }
+ });
+ }
+
+ @Override
+ public void endLiveMic() {
+ L.eSw("endLiveMic");
+ if (swAuManager != null) {
+ swAuManager.setMicAn(false);
+ userJoinLinkMic = false;
+ MicStatusManager.getInstance().clear();
+ }
+ }
+
+ @Override
+ public void hideCover() {
+// if (mCover != null) {
+// if (mCover.getVisibility()==View.VISIBLE){
+//// new Handler().postDelayed(new Runnable() {
+//// @Override
+//// public void run() {
+////
+//// }
+//// },200);
+// mCover.setVisibility(View.GONE);
+// mLoading2.setVisibility(View.GONE);
+// }
+//
+//
+// }
+ }
+
+ @Override
+ public void setCover(String coverUrl) {
+// if (mCover != null) {
+// mCover.setVisibility(View.VISIBLE);
+// mLoading2.setVisibility(View.VISIBLE);
+// ImgLoader.displayBlurLive(mContext, coverUrl, mCover, 400, 600);
+//
+// }
+ }//
+
+ @Override
+ public synchronized void setLiveBeanLandscape(int landscape) {
+// landscape=1;
+ Log.i(TAG, "setLiveBeanLandscape: " + landscape + " isPk: " + isPk);
+ this.landscape = landscape;
+ this.videoLandscape = landscape;
+ if (landscape == 2) {
+ Log.i(TAG, "还原9:16");
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
+ params.topMargin = 0;
+ ry_view.setLayoutParams(params);
+ ry_view.requestLayout();
+
+ /* RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ params1.height = RelativeLayout.LayoutParams.MATCH_PARENT;
+ params1.topMargin = 0;
+ ry_view.setLayoutParams(params1);
+ ry_view.requestLayout();*/
+ RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
+ params2.height = RelativeLayout.LayoutParams.MATCH_PARENT;
+ params2.topMargin = 0;
+ mCover.setLayoutParams(params2);
+ mCover.requestLayout();
+
+ } else {
+ Log.i(TAG, "还原16:9");
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ params.height = vHeight;
+ params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ params.addRule(RelativeLayout.ALIGN_TOP);
+ ry_view.setLayoutParams(params);
+ ry_view.requestLayout();
+
+ /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ params1.height = vHeight;
+ params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ params1.addRule(RelativeLayout.ALIGN_TOP);
+ ry_view.setLayoutParams(params1);
+ ry_view.requestLayout();*/
+ RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
+ params2.height = DpUtil.dp2px(270);
+ params2.topMargin = DpUtil.dp2px(120);
+ mCover.setLayoutParams(params2);
+ mCover.requestLayout();
+ }
+ }
+
+ @Override
+ public void setLiveEnterRoomNewModel(EnterRoomNewModel data) {
+ super.setLiveEnterRoomNewModel(data);
+ isPk = data.getEnterRoomInfo().getIsconnection().equals("1");
+ if (isPk) {
+ setLiveBeanLandscape(data.getLiveInfo().getLandscape());
+ }
+ }
+
+ /**
+ * 暂停播放
+ */
+ @Override
+ public void pausePlay() {
+
+ }
+
+ /**
+ * 暂停播放后恢复
+ */
+ @Override
+ public void resumePlay() {
+
+ }
+
+ /**
+ * 开始播放
+ *
+ * @param url 流地址
+ */
+ @Override
+ public void play(String url, int playModel) {
+ srcUrl = url;
+ PLAY_MODEL = playModel;
+ waitNextUrl = null;
+ Log.i(TAG, "play" + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape" + videoLandscape);
+ purl = url;
+ onPrepared();
+ }
+
+ @Override
+ public void switchStream(String url, int playModel) {
+ srcUrl = url;
+ PLAY_MODEL = playModel;
+ Log.i(TAG, "switchStream: " + " url:" + url + " playModel: " + playModel + " landscape: " + landscape + " videoLandscape = " + videoLandscape + " ispk = " + isPk + " bean = " + roomModel.getEnterRoomInfo().getIsconnection());
+ if (playModel != PLAY_MODEL_DEF && !url.contains(videoFps[0] + ".flv")) {
+ if (landscape == VIDEO_VERTICAL && !isPk) {
+ url = url.replace(".flv", videoRatioVertical[playModel] + videoFps[0] + ".flv");
+ } else if (landscape == VIDEO_HORIZONTAL || isPk) {
+ url = url.replace(".flv", videoRatioHorizontal[playModel] + videoFps[0] + ".flv");
+ }
+ } else if (!url.contains(videoFps[0] + ".flv")) {
+ }
+ Log.e("purl121", url);
+
+ if (TextUtils.isEmpty(url) || mVideoView == null) {
+ return;
+ }
+
+
+ if (TextUtils.isEmpty(url) || mVideoView == null) {
+ return;
+ }
+ purl = url;
+ }
+
+ boolean tmpPk = false;
+ String waitNextUrl = null;
+
+ @Override
+ public void switchStreamPk(boolean isPk) {
+ super.switchStreamPk(isPk);
+ Log.i(TAG, "switchStreamPk: isPk1" + isPk + " tmp = " + !tmpPk + " isPk2 = " + this.isPk);
+ if (this.isPk && tmpPk) return;
+ if (isPk && !tmpPk || this.isPk) {
+ String url;
+ if (PLAY_MODEL != -1) {
+ url = srcUrl.replace(".flv", videoRatioHorizontal[PLAY_MODEL] + videoFps[0] + ".flv");
+ } else {
+ url = srcUrl.replace(".flv", videoRatioHorizontal[1] + videoFps[0] + ".flv");
+ }
+ if (!tmpPk) {
+ waitNextUrl = url;
+ }
+ tmpPk = true;
+ } else if (!isPk) {
+ tmpPk = false;
+ if (landscape == VIDEO_VERTICAL && PLAY_MODEL != -1) {
+ waitNextUrl = srcUrl.replace(".flv", videoRatioVertical[PLAY_MODEL] + videoFps[0] + ".flv");
+ } else if (landscape == VIDEO_HORIZONTAL && PLAY_MODEL != -1) {
+ waitNextUrl = srcUrl.replace(".flv", videoRatioHorizontal[PLAY_MODEL] + videoFps[0] + ".flv");
+ } else {
+ waitNextUrl = null;
+ }
+ }
+ }
+
+ @Override
+ public void clearFrame() {
+ super.clearFrame();
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
+ params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ params.addRule(RelativeLayout.ALIGN_TOP);
+ mVideoView.setLayoutParams(params);
+ mVideoView.requestLayout();
+
+ /* RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ params1.height = ViewGroup.LayoutParams.WRAP_CONTENT;
+ params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ params1.addRule(RelativeLayout.ALIGN_TOP);
+ ry_view.setLayoutParams(params1);
+ ry_view.requestLayout();*/
+ RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
+ params2.height = DpUtil.dp2px(270);
+ params2.topMargin = DpUtil.dp2px(120);
+ mCover.setLayoutParams(params2);
+ mCover.requestLayout();
+ }
+
+ @Override
+ public void release() {
+ mEnd = true;
+ mStarted = false;
+ Bus.getOff(this);
+ EventBus.getDefault().unregister(this);
+ //swAuManager.exitChannelAll();
+ L.e(TAG, "release------->");
+ }
+
+ @Override
+ public void stopPlay() {
+ Log.i(TAG, "stopPlay: ");
+ if (mCover != null) {
+ mCover.setAlpha(1f);
+ if (mCover.getVisibility() != View.VISIBLE) {
+ mCover.setVisibility(View.VISIBLE);
+ }
+ }
+ stopPlay2();
+ }
+
+ @Override
+ public void stopPlay2() {
+ swAuManager.exitChannelAll();
+ drMicUserList = new ArrayList<>();
+
+ }
+
+ @Override
+ public void setViewUP(int i) {
+ if (mVideoView == null) return;
+ Log.e("PK状态", "" + i);
+
+
+ /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ params1.height = vHeight;
+ params1.topMargin = contexts.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ params1.addRule(RelativeLayout.ALIGN_TOP);
+ ry_view.requestLayout();*/
+ isPk = true;
+ }
+
+ /**
+ * 播放开始
+ */
+ public void onPrepared() {
+ if (mEnd) {
+ release();
+ return;
+ }
+ int height;
+ if (videoLandscape == VIDEO_VERTICAL) {
+ height = ViewGroup.LayoutParams.MATCH_PARENT;
+ } else {
+ height = ViewGroup.LayoutParams.WRAP_CONTENT;
+ }
+ if (landscape == 2) {
+ Log.i(TAG, "onPrepared:还原9:16 land=" + videoLandscape);
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ params.height = height;
+ params.topMargin = 0;
+ params.addRule(RelativeLayout.ALIGN_TOP);
+ mVideoView.setLayoutParams(params);
+ mVideoView.requestLayout();
+
+ /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ params1.height = height;
+ params1.topMargin = 0;
+ ry_view.setLayoutParams(params1);
+ ry_view.requestLayout();*/
+ RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
+ params2.height = height;
+ params2.topMargin = 0;
+ mCover.setLayoutParams(params2);
+ mCover.requestLayout();
+ } else {
+ Log.i(TAG, "onPrepared:还原16:9");
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ params.height = height;
+ params.topMargin = 0;
+ if (videoLandscape == VIDEO_HORIZONTAL) {
+ params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ }
+ params.addRule(RelativeLayout.ALIGN_TOP);
+ mVideoView.setLayoutParams(params);
+ mVideoView.requestLayout();
+
+ /*RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) ry_view.getLayoutParams();
+ params1.height = height;
+ params1.topMargin = 0;
+ params1.addRule(RelativeLayout.ALIGN_TOP);
+ if (videoLandscape == VIDEO_HORIZONTAL) {
+ params1.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ }
+ ry_view.setLayoutParams(params1);
+ ry_view.requestLayout();*/
+ RelativeLayout.LayoutParams params2 = (RelativeLayout.LayoutParams) mCover.getLayoutParams();
+ params2.height = height;
+ params2.topMargin = DpUtil.dp2px(120);
+ mCover.setLayoutParams(params2);
+ mCover.requestLayout();
+ }
+ }
+
+ @Override
+ public void setPkview() {
+ Log.i("收到socket--->", "变成16:9");
+ String url = srcUrl;
+ isPk = true;
+ switchStreamPk(true);
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ params.height = vHeight;
+ params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ params.addRule(RelativeLayout.ALIGN_TOP);
+ mVideoView.requestLayout();
+ }
+
+ @Override
+ public synchronized void setPkEndview() {
+
+ Log.i("收收收", landscape + "");
+ isPk = false;
+ tmpPk = false;
+ switchStreamPk(false);
+ if (landscape == 2) {
+ Log.i("收到socket--->", "还原9:16");
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
+ params.topMargin = 0;
+ mVideoView.requestLayout();
+
+ } else {
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ params.height = vHeight;
+ params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ params.addRule(RelativeLayout.ALIGN_TOP);
+ mVideoView.requestLayout();
+ }
+// if (detailsView != null) {
+// mVideoView.removeView(detailsView);
+// detailsView = null;
+// }
+ }
+
+
+ public void removeDetailView() {
+// if (detailsView != null) {
+// mVideoView.removeView(detailsView);
+// detailsView = null;
+// }
+ }
+
+ @Override
+ public ViewGroup getSmallContainer() {
+ return mSmallContainer;
+ }
+
+
+ @Override
+ public ViewGroup getRightContainer() {
+ return mRightContainer;
+ }
+
+ @Override
+ public ViewGroup getPkContainer() {
+ return mPkContainer;
+ }
+
+ @Override
+ public void changeToLeft() {
+ if (mVideoView != null) {
+
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ params.height = vHeight;
+// params.height = mContext.getResources().getDimensionPixelOffset(R.dimen.live_view);
+ params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ params.addRule(RelativeLayout.ALIGN_TOP);
+ mVideoView.requestLayout();
+
+ }
+ if (mLoading != null && mLeftContainer != null) {
+ ViewParent viewParent = mLoading.getParent();
+ if (viewParent != null) {
+ ((ViewGroup) viewParent).removeView(mLoading);
+ }
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(DpUtil.dp2px(24), DpUtil.dp2px(24));
+ params.gravity = Gravity.CENTER;
+ mLoading.setLayoutParams(params);
+ mLeftContainer.addView(mLoading);
+ }
+ }
+
+ @Override
+ public void changeToBig() {
+ if (mVideoView != null) {
+ RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
+ mVideoView.setLayoutParams(params);
+
+ }
+ if (mLoading != null && mRoot != null) {
+ ViewParent viewParent = mLoading.getParent();
+ if (viewParent != null) {
+ ((ViewGroup) viewParent).removeView(mLoading);
+ }
+ RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(DpUtil.dp2px(24), DpUtil.dp2px(24));
+ params.addRule(RelativeLayout.CENTER_IN_PARENT);
+ mLoading.setLayoutParams(params);
+ mRoot.addView(mLoading);
+ }
+ }
+
+ @Override
+ public void onResume() {
+ if (!mPausedPlay && mPaused && mVideoView != null) {
+// mVideoView.runInForeground();
+// mVideoView.start();
+ }
+ mPaused = false;
+// if (mPlayer.isPlaying() == 1) {
+// mPlayer.resumeVideo();
+// mPlayer.resumeAudio();
+// }
+ }
+
+ @Override
+ public void onPause() {
+// if (!mPausedPlay && mVideoView != null) {
+// mVideoView.runInBackground(false);
+// }
+// mPaused = true;
+// mPlayer.pauseVideo();
+// mPlayer.pauseAudio();
+ }
+
+ @Override
+ public void onDestroy() {
+ release();
+ }
+
+ //全屏
+ @Override
+ public void fullScreen() {
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ params.height = RelativeLayout.LayoutParams.MATCH_PARENT;
+ params.topMargin = 0;
+ params.addRule(RelativeLayout.ALIGN_TOP);
+ mVideoView.requestLayout();
+ }
+
+ //小屏
+ @Override
+ public void smallScreen() {
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mVideoView.getLayoutParams();
+ params.height = vHeight;
+ params.topMargin = mContext.getResources().getDimensionPixelOffset(R.dimen.live_top);
+ // mPlayer.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0);
+ params.addRule(RelativeLayout.ALIGN_TOP);
+ mVideoView.requestLayout();
+ }
+
+ boolean isShow = false;
+
+ boolean isShowInvitation = false;
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onUpdata(String str) {
+
+ if ("UsertoRY".equals(str)) {
+ //todo 新增dis监听
+ if (isShow || MicStatusManager.getInstance().getMicStatus() == MicStatusManager.MIC_TYPE_OPEN) {
+ return;
+ }
+ isShow = true;
+ DialogUitl.showSimpleDialog(mContext, mContext.getString(R.string.mic_tag), new DialogUitl.SimpleCallback2() {
+ @Override
+ public void onCancelClick() {
+ MicStatusManager.getInstance().setMicData(MicStatusManager.MIC_TYPE_DEFAULT, LiveActivity.mLiveUid);
+ userJoinLinkMic = false;
+ isShow = false;
+ }
+
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ UsertoRY();
+ isShow = false;
+ }
+ });
+
+ } else if ("inviteMic".equals(str)) {
+ if (isShowInvitation || MicStatusManager.getInstance().getMicStatus() == MicStatusManager.MIC_TYPE_OPEN) {
+ return;
+ }
+ isShowInvitation = true;
+ String content = "邀請您進行語音連麥";
+ String confirm = "接受";
+ String cancel = "拒絕";
+ if (!WordUtil.isNewZh()) {
+ content = "You are invited to join the voice connection";
+ confirm = "accept";
+ cancel = "cancel";
+ }
+ DialogUitl.Builder builder = new DialogUitl.Builder(mContext).setContent(content).setTitle(mLiveBean.getUserNiceName()).setConfirmString(confirm).setCancelString(cancel).setView(R.layout.dialog_live_mic_invite).setClickCallback3(new DialogUitl.SimpleCallback3() {
+ @Override
+ public void onConfirmClick(Dialog dialog) {
+ String[] permissions;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
+ permissions = new String[]{Manifest.permission.READ_MEDIA_IMAGES, Manifest.permission.RECORD_AUDIO};
+ } else {
+ permissions = new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO};
+ }
+ LiveAudienceActivity.mProcessResultUtil.requestPermissions(permissions, new Runnable() {
+ @Override
+ public void run() {
+ L.eSw("将自己设置成给主播,和主播连麦");
+ joinLiveMic();
+ isShowInvitation = false;
+ }
+ });
+ }
+
+ @Override
+ public void onCancel() {
+ isShowInvitation = false;
+ }
+ });
+ builder.build().show();
+
+ } else if ("endMic".equals(str)) {
+ L.eSw("endMic.equals(str))" + str);
+ // 开始切换为观众身份
+ //声网-将用户身份切换只观众
+ endLiveMic();
+ } else if ("Debug".equals(str)) {
+ if (EasyFloat.isShow("Debug")) {
+ EasyFloat.dismiss("Debug");
+ return;
+ }
+ EasyFloat.with(mContext).setDragEnable(true).setTag("Debug").setLayout(debugView).show();
+ }
+ }
+
+ public void endLiveMicUser() {
+ endLiveMic();
+ }
+
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onOpenDrawer(LiveAudienceEvent event) {
+ if (event.getType() == LiveAudienceEvent.LiveAudienceType.LIVE_VIDEO) {
+ int ban = 0;//全模式都可以选择
+ switch (roomModel.getClarityType() - 1) {
+ case PLAY_MODEL_720://仅允许720(高清),ban掉1080(超高清)模式
+ ban = LiveClarityCustomPopup.BAN_1080;
+ break;
+ case -1://没有该字段
+ case PLAY_MODEL_480://仅允许480(流畅),ban掉1080(超高清)和720(高清)模式
+ ban = LiveClarityCustomPopup.BAN_720;
+ break;
+
+ }
+ LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, IMLoginManager.get(mContext).getInt(PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR), ban, true);
+ 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) {
+ int selectClarity = liveClarityCustomPopup.getSelectClarity();
+ if (selectClarity == PLAY_MODEL || selectClarity == IMLoginManager.get(mContext).getInt(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, PLAY_MODEL_ANCHOR))
+ return;
+ if (selectClarity == PLAY_MODEL_ANCHOR) {
+ switchStream(srcUrl, PLAY_MODEL_DEF);
+ setAudiencePlayModel(selectClarity);
+ } else {
+ switchStream(srcUrl, selectClarity);
+ }
+ IMLoginManager.get(mContext).put(LiveRoomPlayViewHolder.PLAY_MODEL_KEY, selectClarity);
+ showToast();
+ }
+
+ private void showToast() {
+ if (WordUtil.isNewZh()) {
+ DialogUitl.showToast(mContext, "設置成功\n" + "正在為你轉換中", 3000);
+ } else {
+ DialogUitl.showToast(mContext, "successful\n" + "It's being converted for you", 3000);
+ }
+ }
+
+ @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();
+ } else if (event.getType() == LiveAudienceEvent.LiveAudienceType.FONT_SIZE) {
+ int fount = 0;
+ try {
+ fount = Integer.parseInt(SpUtil.getStringValue("pd_live_room_fount_size"));
+ } catch (Exception ignored) {
+
+ }
+ new LiveFontSizeSettingDialog(mContext, fount).setOnItemClickListener(new OnItemClickListener() {
+ @Override
+ public void onItemClick(Integer bean, int position) {
+ EventBus.getDefault().post(new LiveAudienceEvent().setNums(bean).setType(LiveAudienceEvent.LiveAudienceType.LIVE_FONT_SIZE));
+ }
+ }).showDialog();
+ } else if (event.getType() == LiveAudienceEvent.LiveAudienceType.PK_TWO_START) {
+ //将当前主播画面换个画布展示
+ String pkUid = (String) event.getObject();
+ setPkView(pkUid);
+
+ } else if (event.getType() == LiveAudienceEvent.LiveAudienceType.LIVE_PK_END) {
+ String pkUid = (String) event.getObject();
+ //endpk(pkUid);
+ }
+ }
+
+ /**
+ * 把观众转换成主播
+ */
+ public List userinputStreamList = new ArrayList<>();
+
+ public void UsertoRY() {
+ userinputStreamList.clear();
+ Log.e("ry", "主播同意了UsertoRY");
+ joinLiveMic();
+ }
+
+ @Override
+ public void setLoadViewListener(LoadingListener listener) {
+ super.setLoadViewListener(listener);
+ }
+}
diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder.java
index cb8a577fd..6097d1038 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder.java
@@ -18,6 +18,7 @@ import com.tencent.live2.impl.V2TXLivePlayerImpl;
import com.tencent.rtmp.ITXLivePlayListener;
import com.tencent.rtmp.TXLivePlayConfig;
import com.tencent.rtmp.ui.TXCloudVideoView;
+import com.yunbao.common.bean.UserBean;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.utils.L;
@@ -69,10 +70,55 @@ public class LivePlayTxViewHolder extends LiveRoomPlayViewHolder implements ITXL
}
+ @Override
+ public void setDrMicInfo(UserBean u) {
+
+ }
+
@Override
public void setLiveBeanLandscape(int landscape) {
}
+ @Override
+ public void endPk() {
+
+ }
+
+ @Override
+ public void endpk(String liveUid) {
+
+ }
+
+ @Override
+ public void initSwEngine(String liveUid) {
+
+ }
+
+ @Override
+ public void removeLiveUid(String uid) {
+
+ }
+
+ @Override
+ public void removeDetailView() {
+
+ }
+
+ @Override
+ public void setPkView(String liveUid) {
+
+ }
+
+ @Override
+ public void claerDrPkInfoView() {
+
+ }
+
+ @Override
+ public void endLiveMic() {
+
+ }
+
@Override
protected int getLayoutId() {
return R.layout.view_live_play_tx;
diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder_backup.java b/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder_backup.java
deleted file mode 100644
index 28a1f10ed..000000000
--- a/live/src/main/java/com/yunbao/live/views/LivePlayTxViewHolder_backup.java
+++ /dev/null
@@ -1,470 +0,0 @@
-package com.yunbao.live.views;
-
-import android.content.Context;
-import android.os.Bundle;
-import android.os.Handler;
-import android.text.TextUtils;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.ViewParent;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.tencent.rtmp.ITXLivePlayListener;
-import com.tencent.rtmp.TXLiveConstants;
-import com.tencent.rtmp.TXLivePlayConfig;
-import com.tencent.rtmp.TXLivePlayer;
-import com.tencent.rtmp.ui.TXCloudVideoView;
-import com.yunbao.common.glide.ImgLoader;
-import com.yunbao.common.http.HttpCallback;
-import com.yunbao.common.utils.DpUtil;
-import com.yunbao.common.utils.L;
-import com.yunbao.common.utils.ToastUtil;
-import com.yunbao.live.R;
-import com.yunbao.common.http.LiveHttpConsts;
-import com.yunbao.common.http.LiveHttpUtil;
-
-/**
- * Created by cxf on 2018/10/10.
- * 直播间播放器 腾讯播放器
- */
-
-public class LivePlayTxViewHolder_backup extends LiveRoomPlayViewHolder implements ITXLivePlayListener {
-
- private static final String TAG = "LiveTxPlayViewHolder";
- private ViewGroup mRoot;
- private ViewGroup mSmallContainer;
- private ViewGroup mLeftContainer;
- private ViewGroup mRightContainer;
- private ViewGroup mPkContainer;
- private TXCloudVideoView mVideoView;
- private View mLoading;
- private ImageView mCover;
- private TXLivePlayer mPlayer;
- private boolean mPaused;//是否切后台了
- private boolean mStarted;//是否开始了播放
- private boolean mEnd;//是否结束了播放
- private boolean mPausedPlay;//是否被动暂停了播放
- private boolean mChangeToLeft;
- private boolean mChangeToAnchorLinkMic;
- private String mUrl;
- private int mPlayType;
- private HttpCallback mGetTxLinkMicAccUrlCallback;
- private Handler mHandler;
- private int mVideoLastProgress;
-
- @Override
- public void setPkview() {
-
- }
-
- @Override
- public void setPkEndview() {
-
- }
-
- @Override
- public void setLiveBeanLandscape(int landscape) {
-
- }
-
- public LivePlayTxViewHolder_backup(Context context, ViewGroup parentView) {
- super(context, parentView);
- }
-
- @Override
- protected int getLayoutId() {
- return R.layout.view_live_play_tx;
- }
-
- @Override
- public void init() {
- mRoot = (ViewGroup) findViewById(R.id.root);
- mSmallContainer = (ViewGroup) findViewById(R.id.small_container);
- mLeftContainer = (ViewGroup) findViewById(R.id.left_container);
- mRightContainer = (ViewGroup) findViewById(R.id.right_container);
- mPkContainer = (ViewGroup) findViewById(R.id.pk_container);
- mLoading = findViewById(R.id.loading);
- mCover = (ImageView) findViewById(R.id.cover);
- mVideoView = (TXCloudVideoView) findViewById(R.id.video_view);
-
- mPlayer = new TXLivePlayer(mContext);
- mPlayer.setPlayListener(this);
- mPlayer.setPlayerView(mVideoView);
- mPlayer.enableHardwareDecode(false);
- mPlayer.setRenderRotation(TXLiveConstants.RENDER_ROTATION_PORTRAIT);
- mPlayer.setRenderMode(TXLiveConstants.RENDER_MODE_FULL_FILL_SCREEN);
- TXLivePlayConfig playConfig = new TXLivePlayConfig();
- playConfig.setAutoAdjustCacheTime(true);
- playConfig.setMaxAutoAdjustCacheTime(5.0f);
- playConfig.setMinAutoAdjustCacheTime(1.0f);
- mPlayer.setConfig(playConfig);
-
- }
-
-
- @Override
- public void onPlayEvent(int e, Bundle bundle) {
- if (mEnd) {
- return;
- }
- switch (e) {
- case TXLiveConstants.PLAY_EVT_PLAY_BEGIN://播放开始
- if (mLoading != null && mLoading.getVisibility() == View.VISIBLE) {
- mLoading.setVisibility(View.INVISIBLE);
- }
- break;
- case TXLiveConstants.PLAY_EVT_PLAY_LOADING:
- if (mLoading != null && mLoading.getVisibility() != View.VISIBLE) {
- mLoading.setVisibility(View.VISIBLE);
- }
- break;
- case TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME://第一帧
- hideCover();
- break;
- case TXLiveConstants.PLAY_EVT_PLAY_END://播放结束
- replay();
- break;
- case TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION://获取视频宽高
- if (mChangeToLeft || mChangeToAnchorLinkMic) {
- return;
- }
- float width = bundle.getInt("EVT_PARAM1", 0);
- float height = bundle.getInt("EVT_PARAM2", 0);
- L.e(TAG, "流---width----->" + width);
- L.e(TAG, "流---height----->" + height);
- FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
- int targetH = 0;
- if (width >= height) {//横屏 9:16=0.5625
- targetH = (int) (mVideoView.getWidth() / width * height);
- } else {
- targetH = ViewGroup.LayoutParams.MATCH_PARENT;
- }
- if (targetH != params.height) {
- params.height = targetH;
- params.gravity = Gravity.CENTER;
- mVideoView.requestLayout();
- }
-
- break;
- case TXLiveConstants.PLAY_ERR_NET_DISCONNECT://播放失败
- case TXLiveConstants.PLAY_ERR_FILE_NOT_FOUND:
- ToastUtil.show(mContext.getString(R.string.live_play_error));
- break;
- case TXLiveConstants.PLAY_EVT_PLAY_PROGRESS:
- int progress = bundle.getInt("EVT_PLAY_PROGRESS_MS");
- if (mVideoLastProgress == progress) {
- replay();
- } else {
- mVideoLastProgress = progress;
- }
- break;
- default:break;
- }
- }
-
- @Override
- public void onNetStatus(Bundle bundle) {
-
- }
-
-
- @Override
- public void hideCover() {
- if (mCover != null) {
- mCover.animate().alpha(0).setDuration(500).start();
- }
- }
-
- @Override
- public void setCover(String coverUrl) {
- if (mCover != null) {
- ImgLoader.displayBlur(mContext, coverUrl, mCover);
- }
- }
-
- @Override
- public void fullScreen() {
-
- }
-
- @Override
- public void smallScreen() {
-
- }
-
- /**
- * 循环播放
- */
- private void replay() {
- if (mStarted && mPlayer != null) {
- mPlayer.seek(0);
- mPlayer.resume();
- }
- }
-
-
- /**
- * 暂停播放
- */
- @Override
- public void pausePlay() {
- if (!mPausedPlay) {
- mPausedPlay = true;
- if (!mPaused) {
- if (mPlayer != null) {
- mPlayer.pause();
- }
- }
- if (mCover != null) {
- mCover.setAlpha(1f);
- if (mCover.getVisibility() != View.VISIBLE) {
- mCover.setVisibility(View.VISIBLE);
- }
- }
- }
- }
-
- /**
- * 暂停播放后恢复
- */
- @Override
- public void resumePlay() {
- if (mPausedPlay) {
- mPausedPlay = false;
- if (!mPaused) {
- if (mPlayer != null) {
- mPlayer.resume();
- }
- }
- hideCover();
- }
- }
-
- /**
- * 开始播放
- *
- * @param url 流地址
- */
- @Override
- public void play(String url,int playModel) {
- if (TextUtils.isEmpty(url)) {
- return;
- }
- int playType = -1;
- if (url.startsWith("rtmp://")) {
- playType = TXLivePlayer.PLAY_TYPE_LIVE_RTMP;
- } else if (url.endsWith(".flv")) {
- playType = TXLivePlayer.PLAY_TYPE_LIVE_FLV;
- } else if (url.endsWith(".m3u8")) {
- playType = TXLivePlayer.PLAY_TYPE_VOD_HLS;
- } else if (url.endsWith(".mp4")) {
- playType = TXLivePlayer.PLAY_TYPE_VOD_MP4;
- }
- if (playType == -1) {
- ToastUtil.show(mContext.getString(R.string.live_play_error_2));
- return;
- }
- if (mPlayer != null) {
- int result = mPlayer.startPlay(url, playType);
- if (result == 0) {
- mStarted = true;
- mUrl = url;
- mPlayType = playType;
- }
- }
- L.e(TAG, "play----url--->" + url);
- }
-
- @Override
- public void switchStream(String url, int playModel) {
-
- }
-
- @Override
- public void stopPlay() {
- mChangeToLeft = false;
- mChangeToAnchorLinkMic = false;
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- }
- if (mCover != null) {
- mCover.setAlpha(1f);
- if (mCover.getVisibility() != View.VISIBLE) {
- mCover.setVisibility(View.VISIBLE);
- }
- }
- stopPlay2();
- }
-
- @Override
- public void stopPlay2() {
- if (mPlayer != null) {
- mPlayer.stopPlay(false);
- }
- }
-
- @Override
- public void release() {
- mEnd = true;
- if (mHandler != null) {
- mHandler.removeCallbacksAndMessages(null);
- }
- mHandler = null;
- LiveHttpUtil.cancel(LiveHttpConsts.GET_TX_LINK_MIC_ACC_URL);
- if (mPlayer != null) {
- mPlayer.stopPlay(false);
- mPlayer.setPlayListener(null);
- }
- mPlayer = null;
- L.e(TAG, "release------->");
- }
-
-
- @Override
- public ViewGroup getSmallContainer() {
- return mSmallContainer;
- }
-
-
- @Override
- public ViewGroup getRightContainer() {
- return mRightContainer;
- }
-
- @Override
- public ViewGroup getPkContainer() {
- return mPkContainer;
- }
-
- @Override
- public void changeToLeft() {
- mChangeToLeft = true;
- if (mVideoView != null) {
- FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
- params.width = mVideoView.getWidth() / 2;
- params.height = DpUtil.dp2px(250);
- params.topMargin = DpUtil.dp2px(130);
- mVideoView.setLayoutParams(params);
- }
- if (mLoading != null && mLeftContainer != null) {
- ViewParent viewParent = mLoading.getParent();
- if (viewParent != null) {
- ((ViewGroup) viewParent).removeView(mLoading);
- }
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(DpUtil.dp2px(24), DpUtil.dp2px(24));
- params.gravity = Gravity.CENTER;
- mLoading.setLayoutParams(params);
- mLeftContainer.addView(mLoading);
- }
- }
-
- @Override
- public void changeToBig() {
- mChangeToLeft = false;
- if (mVideoView != null) {
- FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
- params.width = ViewGroup.LayoutParams.MATCH_PARENT;
- params.height = ViewGroup.LayoutParams.MATCH_PARENT;
- params.topMargin = 0;
- mVideoView.setLayoutParams(params);
- }
- if (mLoading != null && mRoot != null) {
- ViewParent viewParent = mLoading.getParent();
- if (viewParent != null) {
- ((ViewGroup) viewParent).removeView(mLoading);
- }
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(DpUtil.dp2px(24), DpUtil.dp2px(24));
- params.gravity = Gravity.CENTER;
- mLoading.setLayoutParams(params);
- mRoot.addView(mLoading);
- }
- }
-
- @Override
- public void onResume() {
- if (!mPausedPlay && mPaused && mPlayer != null) {
- mPlayer.resume();
- }
- mPaused = false;
- }
-
- @Override
- public void onPause() {
- if (!mPausedPlay && mPlayer != null) {
- mPlayer.pause();
- }
- mPaused = true;
- }
-
- @Override
- public void onDestroy() {
- release();
- }
-
- /**
- * 腾讯sdk连麦时候切换低延时流
- */
- public void onLinkMicTxAccEvent(boolean linkMic) {
- if (mStarted && mPlayer != null && !TextUtils.isEmpty(mUrl)) {
- mPlayer.stopPlay(false);
- if (linkMic) {
- if (mGetTxLinkMicAccUrlCallback == null) {
- mGetTxLinkMicAccUrlCallback = 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) {
- String accUrl = obj.getString("streamUrlWithSignature");
- if (!TextUtils.isEmpty(accUrl) && mPlayer != null) {
- L.e(TAG, "低延时流----->" + accUrl);
- mPlayer.startPlay(accUrl, TXLivePlayer.PLAY_TYPE_LIVE_RTMP_ACC);
- }
- }
- }
- }
- };
- }
- LiveHttpUtil.getTxLinkMicAccUrl(mUrl, mGetTxLinkMicAccUrlCallback);
- } else {
- mPlayer.startPlay(mUrl, mPlayType);
- }
- }
- }
-
- /**
- * 设置主播连麦模式
- *
- * @param anchorLinkMic
- */
- public void setAnchorLinkMic(final boolean anchorLinkMic, int delayTime) {
- if (mVideoView == null) {
- return;
- }
- if (mHandler == null) {
- mHandler = new Handler();
- }
- mHandler.postDelayed(new Runnable() {
- @Override
- public void run() {
- mChangeToAnchorLinkMic = anchorLinkMic;
- FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mVideoView.getLayoutParams();
- if (anchorLinkMic) {
- params.height = DpUtil.dp2px(250);
- params.topMargin = DpUtil.dp2px(130);
- params.gravity = Gravity.TOP;
- } else {
- params.height = ViewGroup.LayoutParams.MATCH_PARENT;
- params.topMargin = 0;
- params.gravity = Gravity.CENTER;
- }
- mVideoView.setLayoutParams(params);
- }
- }, delayTime);
-
- }
-}
diff --git a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java
index f849d6d3d..169b32dce 100644
--- a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java
@@ -415,7 +415,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override
public void onError(String error) {
- ToastUtil.show(WordUtil.isNewZh()?"抱歉!出錯了!":"i \\'m sorry! An error occurred");
+ ToastUtil.show(WordUtil.isNewZh()?"抱歉!出錯了!":"i \\'m sorry! An error occurred");
}
});
diff --git a/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java
new file mode 100644
index 000000000..2c124fad2
--- /dev/null
+++ b/live/src/main/java/com/yunbao/live/views/LivePushSwViewHolder.java
@@ -0,0 +1,677 @@
+package com.yunbao.live.views;
+
+import static com.yunbao.live.activity.LiveActivity.mLiveSwLinkMicPkPresenter;
+import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.LIVE_PK_END;
+import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.LIVE_PK_ING;
+import static com.yunbao.live.presenter.LiveSwLinkMicPkPresenter.inputStreamList;
+import static com.yunbao.live.presenter.LiveSwLinkMicPkPresenter.inputStreamList1;
+import static com.yunbao.live.presenter.LiveSwLinkMicPkPresenter.mPkUid;
+
+import android.app.Activity;
+import android.app.Dialog;
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
+import android.util.Log;
+import android.util.TypedValue;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.tencent.rtmp.ITXLivePushListener;
+import com.tencent.rtmp.TXLiveConstants;
+import com.yunbao.common.CommonAppConfig;
+import com.yunbao.common.Constants;
+import com.yunbao.common.bean.UserBean;
+import com.yunbao.common.event.AnchorInfoEvent;
+import com.yunbao.common.event.LivePushRyEvent;
+import com.yunbao.common.glide.ImgLoader;
+import com.yunbao.common.http.HttpCallback;
+import com.yunbao.common.http.HttpClient;
+import com.yunbao.common.manager.IMLoginManager;
+import com.yunbao.common.utils.Bus;
+import com.yunbao.common.utils.DialogUitl;
+import com.yunbao.common.utils.DpUtil;
+import com.yunbao.common.utils.L;
+import com.yunbao.common.utils.StringUtil;
+import com.yunbao.common.utils.ToastUtil;
+import com.yunbao.common.utils.WordUtil;
+import com.yunbao.live.R;
+import com.yunbao.live.activity.LiveActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
+import com.yunbao.live.bean.DrPkbean;
+import com.yunbao.live.event.LiveAudienceEvent;
+import com.yunbao.common.http.LiveHttpConsts;
+import com.yunbao.common.http.LiveHttpUtil;
+import com.yunbao.live.presenter.LiveSwLinkMicPkPresenter;
+import com.yunbao.live.socket.SocketSendBean;
+
+import org.greenrobot.eventbus.EventBus;
+import org.greenrobot.eventbus.Subscribe;
+import org.greenrobot.eventbus.ThreadMode;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import cn.rongcloud.rtc.api.RCRTCEngine;
+import cn.rongcloud.rtc.api.RCRTCMixConfig;
+import cn.rongcloud.rtc.api.RCRTCRoom;
+import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
+import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback;
+import cn.rongcloud.rtc.api.stream.RCRTCLiveInfo;
+import cn.rongcloud.rtc.base.RCRTCParamsType;
+import cn.rongcloud.rtc.base.RTCErrorCode;
+import io.agora.beautyapi.faceunity.agora.SWAuManager;
+import io.agora.beautyapi.faceunity.agora.SWManager;
+import io.rong.imlib.IRongCallback;
+import io.rong.imlib.RongIMClient;
+import io.rong.imlib.model.Conversation;
+import io.rong.imlib.model.Message;
+import io.rong.message.TextMessage;
+
+/**
+ * Created by cxf on 2018/10/7.
+ * 腾讯云直播推流
+ */
+
+public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITXLivePushListener {
+ private int mMeiBaiVal;//基础美颜 美白
+ private int mMoPiVal;//基础美颜 磨皮
+ private int mHongRunVal;//基础美颜 红润
+ private String mBgmPath;//背景音乐路径
+ private Bitmap mFilterBmp;
+ private Handler mMainHandler;
+ public static Context contexts;
+ public static TextView btn_close;
+ public LinearLayout dr_pk_view;
+ public static RCRTCRoom rtcRoom;
+ public static RCRTCLiveInfo rcrtcLiveInfo;
+ private ViewGroup liveActivityContainer;
+ public FrameLayout timeTitle;
+ public TextView textTime;
+ private TextView tv_avatarOther_name;
+ private ImageView avatarOther;
+ private LinearLayout goto_room_view;
+ private boolean isPk = false;
+ private boolean isNeedOpenCamera = false;
+ private SWManager swManager;
+ private String pkUid1; //单人PK 对方主播 uid
+
+ //修改上面主播的头像
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void onUPAnchorInfo(AnchorInfoEvent e) {
+ Log.i(TAG, "onUPAnchorInfo: " + e);
+ if (e != null) {
+ if (!e.isClear()) {
+ tv_avatarOther_name.setText(e.getUserNiceName());
+ tv_avatarOther_name.setTag(e.getUserNiceName());
+ ImgLoader.displayAvatar(mContext, e.getAvatar(), avatarOther);
+ goto_room_view.setVisibility(View.VISIBLE);
+ } else {
+ goto_room_view.setVisibility(View.GONE);
+ }
+ }
+ }
+
+ public onDrPkJoinSuccessListener onDrPkJoinSuccessListener;
+
+ public void setOnDrPkJoinSuccessListener(LivePushSwViewHolder.onDrPkJoinSuccessListener onDrPkJoinSuccessListener) {
+ this.onDrPkJoinSuccessListener = onDrPkJoinSuccessListener;
+ }
+
+ public LivePushSwViewHolder(Context context, ViewGroup parentView) {
+ super(context, parentView);
+ this.contexts = context;
+ EventBus.getDefault().register(this);
+ }
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.view_live_push_sw;
+ }
+
+ public void setLiveActivityContainer(ViewGroup liveActivityContainer) {
+ this.liveActivityContainer = liveActivityContainer;
+ }
+
+ @Override
+ public void init() {
+ super.init();
+ Bus.getOn(this);
+ mPreView = (FrameLayout) findViewById(R.id.camera_preview);
+ camera = (LinearLayout) findViewById(R.id.camera);
+ mPreView1 = (FrameLayout) findViewById(R.id.camera_preview1);
+ cameraPreview3 = (FrameLayout) findViewById(R.id.camera_preview3);
+ dr1_preview = (FrameLayout) findViewById(R.id.dr1_preview);
+ dr2_preview = (FrameLayout) findViewById(R.id.dr2_preview);
+ dr3_preview = (FrameLayout) findViewById(R.id.dr3_preview);
+ dr4_preview = (FrameLayout) findViewById(R.id.dr4_preview);
+ leave = (ImageView) findViewById(R.id.leave);
+ dr_pk_view = (LinearLayout) findViewById(R.id.dr_pk_view);
+ timeTitle = (FrameLayout) findViewById(R.id.time_title);
+ textTime = (TextView) findViewById(R.id.text_time);
+ dr_pk_view.setVisibility(View.GONE);
+ cameraPreview3.setVisibility(View.GONE);
+ btn_close = (TextView) findViewById(R.id.btn_close);
+ tv_avatarOther_name = (TextView) findViewById(R.id.tv_avatarOther_name);
+ avatarOther = (ImageView) findViewById(R.id.avatarOther);
+ goto_room_view = (LinearLayout) findViewById(R.id.goto_room_view);
+ goto_room_view.setVisibility(View.GONE);
+ mMainHandler = new Handler(Looper.getMainLooper());
+ btn_close.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ DialogUitl.showSimpleDialog(mContext, WordUtil.isNewZh() ? "是否要斷開連麥?" : "Do you want to disconnect Link?", new DialogUitl.SimpleCallback() {
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ Log.i("PK----->", "updateSub: " + isPk + "|");
+ aheadOfScheduleEndPK(mPkUid, CommonAppConfig.getInstance().getUserBean().getUserNiceName(), (String) tv_avatarOther_name.getTag());
+ //断开连麦
+ LiveSwAnchorActivity.isDRPK = 0;
+ HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout").execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ }
+ });
+
+ HttpClient.getInstance().get("Livepk.endPK", "Livepk.endPK").params("uid", CommonAppConfig.getInstance().getUid()).params("addtime", "1").params("type", "1").params("sign", "1").execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0) {
+ JSONObject datas = JSONObject.parseObject(info[0]);
+ String pkUid = datas.getString("pkuid");
+
+ //退出副房间
+ // TODO: 2024/4/13 退出对方主播直播间
+ SWManager.get().exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), pkUid1);
+ SWManager.get().updateMyChannelView((FrameLayout) mBigContainer);
+ btn_close.setVisibility(View.GONE);//隐藏连麦按钮
+ EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
+ closeButtonGone();
+ L.eSw("ac333333333333333333333");
+ SocketSendBean seed_msg = new SocketSendBean().param("_method_", Constants.SOCKET_LINK_MIC_PK).param("action", 9).param("msgtype", 10).param("win_uid", datas.getString("win_uid")).param("uid", CommonAppConfig.getInstance().getUid());
+ seed_msg.create();
+ Log.i("seed", seed_msg.mResult.toString());
+ HttpClient.getInstance().get("Tx.sendmsgzs2", "Tx.sendmsgzs2").params("GroupId", "g" + pkUid).params("jsonstr", seed_msg.mResult.toString()).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+
+ HttpClient.getInstance().get("Tx.sendmsgzs2", "Tx.sendmsgzs2").params("GroupId", "g" + CommonAppConfig.getInstance().getUid()).params("jsonstr", seed_msg.mResult.toString()).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+
+ SocketSendBean seed_msgs = new SocketSendBean().param("_method_", Constants.SOCKET_LINK_MIC_PK).param("action", 5).param("msgtype", 10).param("uname", "1").param("uimg", "1").param("pkuid", LiveSwLinkMicPkPresenter.oldmPkUid).param("uid", CommonAppConfig.getInstance().getUid());
+ seed_msgs.create();
+ Log.i("seed", seed_msgs.mResult.toString());
+
+ HttpClient.getInstance().get("Tx.sendmsgzs2", "Tx.sendmsgzs2").params("GroupId", "g" + LiveSwLinkMicPkPresenter.oldmPkUid).params("jsonstr", seed_msgs.mResult.toString()).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ HttpClient.getInstance().get("Tx.sendmsgzs2", "Tx.sendmsgzs2").params("GroupId", "g" + CommonAppConfig.getInstance().getUid()).params("jsonstr", seed_msgs.mResult.toString()).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+ });
+
+ }
+
+ }
+ });
+
+
+ }
+ });
+ }
+ });
+ initRtcEngine();
+ }
+
+ /**
+ * 初始化声网SDK
+ */
+ private void initRtcEngine() {
+ swManager = SWManager.get();
+ swManager.setAnchorContainer((FrameLayout) mBigContainer);
+ swManager.initRtcEngine((Activity) mContext, CommonAppConfig.getInstance().getUid());
+ swManager.setOnRtcEngineListener(new SWManager.onRtcEngineListener() {
+ @Override
+ public void onOpenSuccess(String channel, int uid) {
+ //开播成功
+ L.eSw("开播成功");
+ }
+
+ @Override
+ public void onUserOffline(int uid) {
+
+ }
+ });
+ }
+
+ public void exitChannelDrPk(List drPkbeanList) {
+ for (int i = 0; i < drPkbeanList.size(); i++) {
+ if (!CommonAppConfig.getInstance().getUid().equals(String.valueOf(drPkbeanList.get(i).getId()))) {
+ SWManager.get().exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), String.valueOf(drPkbeanList.get(i).getId()));
+ }
+ }
+ SWManager.get().updateMyChannelView((FrameLayout) mBigContainer);
+ currentPosition = 0;
+ drpkUid3 = "";
+ }
+
+ public void setAnPkRtc(UserBean u) {
+ EventBus.getDefault().post(new AnchorInfoEvent(false, u.getId(), u.getUserNiceName(), u.getAvatar()));
+ if (swManager != null && u != null) {
+ //将多人pk画面屏蔽
+ dr_pk_view.setVisibility(View.GONE);
+ L.eSw("设置对方主播的视图setAnPkRtc" + u);
+ pkUid1 = u.getId();
+ mPkContainer.setVisibility(View.VISIBLE);
+ //将自己的渲染视图设置到 leftContainer
+ swManager.updateMyChannelView((FrameLayout) mLeftContainer);
+ //清除 mBigContainer 中的渲染
+ mBigContainer.removeAllViews();
+ showButtonGone();
+ //设置对方主播的渲染视图 设置到 rightContainer
+ swManager.setPkContainer(mRightContainer);
+ swManager.joinChannelEx(CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, u.getId(), SWAuManager.getChannelName(u.getId()));
+ }
+
+ 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) {
+ HttpClient.getInstance().get("Livepk.setPK", "Livepk.setPK")
+ .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) {
+ L.eSw("555555555555555555555555555555555555");
+ final SocketSendBean msg1 = new SocketSendBean()
+ .param("_method_", Constants.SOCKET_LINK_MIC_PK)
+ .param("action", 4)
+ .param("pkname", u.getUserNiceName())
+ .param("pkuid", u.getId())
+ .param("pkhead", u.getAvatar())
+ .param("uname", u.getUserNiceName())
+ .param("uhead", u.getAvatar())
+ .param("uid", CommonAppConfig.getInstance().getUid());
+ msg1.create();
+
+ Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM;
+ TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
+ Message message1 = Message.obtain("g" + CommonAppConfig.getInstance().getUid(), conversationType, messageContent);
+
+ RongIMClient.getInstance().sendMessage(message1, null, null, new IRongCallback.ISendMessageCallback() {
+ @Override
+ public void onAttached(Message message) {
+
+ }
+
+ @Override
+ public void onSuccess(Message message) {
+ Log.i("tx", "发送成功");
+ }
+
+ @Override
+ public void onError(Message message, RongIMClient.ErrorCode errorCode) {
+
+ }
+ });
+ }
+
+ }
+ });
+ }
+ }
+ });
+ }
+
+ private int currentPosition = 0;
+
+ private String drpkUid3 = "";
+
+ public int setAnDrPkRtc(String uid, int position) {
+ L.eSw("setAnDrPkRtc uid:" + uid + " position" + position);
+ int temp = -1;
+ if (swManager != null && !StringUtil.isEmpty(uid)) {
+ L.eSw("设置对方主播的视图 setAnDrPkRtc" + uid + "position:" + position);
+ if (currentPosition == 0) {
+ position = 2;
+ }
+ if (position == -1) {
+ temp = currentPosition + 1;
+ } else {
+ temp = position;
+ }
+ switch (temp) {
+ case 2:
+ swManager.joinChannelDrEx(dr2_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid),temp);
+ swManager.updateMyChannelView(dr1_preview);
+ mBigContainer.removeAllViews();
+
+ dr3_preview.setVisibility(View.GONE);
+ dr4_preview.setVisibility(View.GONE);
+ break;
+ case 3:
+ drpkUid3 = uid;
+ swManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid),temp);
+ dr3_preview.setVisibility(View.GONE);
+ dr4_preview.setVisibility(View.VISIBLE);
+ break;
+ case 4:
+ dr3_preview.setVisibility(View.VISIBLE);
+ //先退出这个主播的直播间,在进入该直播间,(视图问题暂时這樣處理)
+ swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()), drpkUid3);
+ swManager.joinChannelDrEx(dr3_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, drpkUid3, SWAuManager.getChannelName(drpkUid3),temp);
+
+ swManager.joinChannelDrEx(dr4_preview, CommonAppConfig.getInstance().getUid(), CommonAppConfig.SWToken, uid, SWAuManager.getChannelName(uid),temp);
+ break;
+ }
+ dr_pk_view.setVisibility(View.VISIBLE);
+ currentPosition = temp;
+ }
+ return currentPosition;
+ }
+
+ public void anchorClose() {
+ swManager.exitChannelToUid(Integer.parseInt(CommonAppConfig.getInstance().getUid()),pkUid1);
+ swManager.updateMyChannelView((FrameLayout) mBigContainer); //用户主动断开连麦再退出画面
+ mPkContainer.setVisibility(View.GONE);
+ pkUid1 = null;
+ }
+
+ public void onLinkMicAnchorClose() {
+ //swManager.updateMyChannelView((FrameLayout) mBigContainer); 用户主动断开连麦再退出画面
+ //LivePushRyViewHolder.btn_close.setVisibility(View.GONE);
+ }
+
+
+ public void onLinkDRMicPkApply(UserBean userBean) {
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onLinkDRMicPkApply(userBean);
+ }
+ }
+
+
+ @Override
+ public void changeToLeft() {
+ if (mPreView != null) {
+ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mPreView.getLayoutParams();
+ params.width = mPreView.getWidth() / 2;
+ params.height = DpUtil.dp2px(mPreView.getHeight());
+ params.topMargin = DpUtil.dp2px(130);
+ camera.setLayoutParams(params);
+ }
+ }
+
+ @Override
+ public void changeToBig() {
+ if (camera != null) {
+ LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) camera.getLayoutParams();
+ params.width = ViewGroup.LayoutParams.MATCH_PARENT;
+ params.height = ViewGroup.LayoutParams.MATCH_PARENT;
+ params.topMargin = 0;
+ camera.setLayoutParams(params);
+ }
+ if (mPreView1.getVisibility() == View.VISIBLE) {
+ mPreView1.removeAllViews();
+ mPreView1.setVisibility(View.GONE);
+ inputStreamList.clear();
+ inputStreamList1.clear();
+ }
+ }
+
+ public void closeButtonGone() {
+ btn_close.setVisibility(View.GONE);
+ }
+
+ public void showButtonGone() {
+ btn_close.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ public void toggleCamera() {
+ if (mCameraFront) {
+ mCameraFront = false;
+ } else {
+ mCameraFront = true;
+ }
+ swManager.switchCamera();
+ }
+
+ /**
+ * 打开关闭闪光灯
+ */
+ @Override
+ public void toggleFlash() {
+ if (mCameraFront) {
+ ToastUtil.show(mContext.getString(R.string.live_open_flash));
+ return;
+ }
+ }
+
+ /**
+ * 开始推流
+ *
+ * @param pushUrl 推流地址
+ */
+ @Override
+ public void startPush(String pushUrl) {
+ //开播成功,创建频道
+ if (swManager != null) {
+ swManager.createChannel(CommonAppConfig.SWToken, CommonAppConfig.getChannelName());
+ }
+ }
+
+ public boolean isPking() {
+ if (btn_close != null) {
+ return btn_close.getVisibility() == View.VISIBLE;
+ }
+ return false;
+ }
+
+ @Override
+ public void onPause() {
+ mPaused = true;
+ }
+
+ @Override
+ public void onResume() {
+ mPaused = false;
+ Log.i("摄像头", "onResume: " + isNeedOpenCamera);
+ if (isNeedOpenCamera) {
+ RCRTCEngine.getInstance().getDefaultVideoStream().startCamera(new IRCRTCResultDataCallback() {
+ @Override
+ public void onSuccess(Boolean data) {
+ //设置摄像头最大缩放比例
+ boolean zoom = RCRTCEngine.getInstance().getDefaultVideoStream().setCameraZoomFactor(1.0f);
+ // ToastUtil.show("设置比例="+zoom);
+ Log.i("摄像头", "onSuccess: 打开摄像头");
+ isNeedOpenCamera = false;
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode errorCode) {
+ Log.i("摄像头", "onFailed: 打开摄像头失败 " + errorCode);
+ }
+ });
+ }
+ }
+
+ @Override
+ public void startBgm(String path) {
+ mBgmPath = path;
+
+ }
+
+ @Override
+ public void pauseBgm() {
+
+ }
+
+ @Override
+ public void resumeBgm() {
+
+ }
+
+ @Override
+ public void stopBgm() {
+ mBgmPath = null;
+ }
+
+
+ @Override
+ public void release() {
+ super.release();
+ Bus.getOff(this);
+ LiveHttpUtil.cancel(LiveHttpConsts.LINK_MIC_TX_MIX_STREAM);
+ rtcRoom = null;
+ }
+
+ @Override
+ public void onPushEvent(int e, Bundle bundle) {
+ if (e == TXLiveConstants.PUSH_ERR_OPEN_CAMERA_FAIL) {
+ ToastUtil.show(mContext.getString(R.string.live_push_failed_1));
+
+ } else if (e == TXLiveConstants.PUSH_ERR_OPEN_MIC_FAIL) {
+ ToastUtil.show(mContext.getString(R.string.live_push_failed_2));
+
+ } else if (e == TXLiveConstants.PUSH_ERR_NET_DISCONNECT || e == TXLiveConstants.PUSH_ERR_INVALID_ADDRESS) {
+ L.e(TAG, "网络断开,推流失败------>");
+
+ } else if (e == TXLiveConstants.PUSH_WARNING_HW_ACCELERATION_FAIL) {
+ L.e(TAG, "不支持硬件加速------>");
+
+ } else if (e == TXLiveConstants.PUSH_EVT_FIRST_FRAME_AVAILABLE) {//预览成功
+ L.e(TAG, "mStearm--->初始化完毕");
+ if (mLivePushListener != null) {
+ mLivePushListener.onPreviewStart();
+ }
+ } else if (e == TXLiveConstants.PUSH_EVT_PUSH_BEGIN) {//推流成功
+ L.e(TAG, "mStearm--->推流成功");
+ if (!mStartPush) {
+ mStartPush = true;
+ if (mLivePushListener != null) {
+ mLivePushListener.onPushStart();
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onNetStatus(Bundle bundle) {
+
+ }
+
+ private void aheadOfScheduleEndPK(String pkUid, String uname, String pkname) {
+ if (!isPk) {
+ return;
+ }
+ String ct = "由於 " + uname + " 退出比賽," + pkname + " 獲得勝利";
+
+ SocketSendBean seed_msg = new SocketSendBean().param("_method_", Constants.SOCKET_SYSTEM).param("action", 1).param("ct", ct);
+ seed_msg.create();
+
+ HttpClient.getInstance().get("Tx.sendmsgzs2", "Tx.sendmsgzs2").params("GroupId", "g" + pkUid).params("jsonstr", seed_msg.mResult.toString()).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ HttpClient.getInstance().post("Tx.sendmsgzs2", "Tx.sendmsgzs2").params("GroupId", "g" + CommonAppConfig.getInstance().getUid()).params("jsonstr", seed_msg.mResult.toString()).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+
+ }
+ });
+ }
+ });
+ }
+
+ private Bitmap decodeResource(Resources resources, int id) {
+ TypedValue value = new TypedValue();
+ resources.openRawResource(id, value);
+ BitmapFactory.Options opts = new BitmapFactory.Options();
+ opts.inTargetDensity = value.density;
+ return BitmapFactory.decodeResource(resources, id, opts);
+ }
+
+ public static String getLiveStream() {
+ return ((LiveActivity) contexts).getStream();
+ }
+
+ private String getTxAppId() {
+ return ((LiveActivity) mContext).getTxAppId();
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void setSelectClarity(LivePushRyEvent event) {
+ if (rtcRoom != null)
+ rtcRoom.getLocalUser().publishDefaultLiveStreams(new IRCRTCResultDataCallback() {
+ @Override
+ public void onSuccess(RCRTCLiveInfo rcrtcLiveInfo1) {
+ rcrtcLiveInfo = rcrtcLiveInfo1;
+ }
+
+ @Override
+ public void onFailed(RTCErrorCode rtcErrorCode) {
+ Log.e("ry", "rtcErrorCode" + rtcErrorCode);
+ }
+ });
+ }
+
+ public void setEnableBeauty(boolean flag) {
+ if (swManager != null) {
+ swManager.setEnableBeauty(flag);
+ }
+ }
+
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void updateSub(LiveAudienceEvent event) {
+ if (event.getType() == LIVE_PK_END) {
+ isPk = false;
+ } else if (event.getType() == LIVE_PK_ING) {
+ isPk = true;
+ }
+ Log.i("PK----->", "updateSub: " + isPk + "|" + event.getType());
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ if (swManager != null) {
+ swManager.exitChannelAll();
+ }
+ }
+
+ public interface onDrPkJoinSuccessListener{
+ void joinSuccess1();
+ void joinSuccess2();
+ void joinSuccess3();
+ void joinSuccess4();
+
+ }
+
+}
diff --git a/live/src/main/java/com/yunbao/live/views/LiveReadyRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveReadyRyViewHolder.java
index e329329eb..8d44d530f 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveReadyRyViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveReadyRyViewHolder.java
@@ -35,6 +35,7 @@ import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveChooseClassActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveRyAnchorActivity;
import com.yunbao.live.adapter.LiveReadyShareAdapter;
import com.yunbao.common.bean.LiveRoomTypeBean;
import com.yunbao.live.dialog.LiveRoomTypeDialogFragment;
@@ -218,7 +219,7 @@ public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClick
public void openWishListWindow() {
LiveWishListDialogFragment fragment = new LiveWishListDialogFragment();
- if (mContext instanceof LiveRyAnchorActivity){
+ if (mContext instanceof LiveRyAnchorActivity){
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "RY");
}
}
@@ -471,7 +472,7 @@ public class LiveReadyRyViewHolder extends AbsViewHolder implements View.OnClick
return;
}
String title = mEditTitle.getText().toString().trim();
- LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile,0, new HttpCallback() {
+ LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile,0, false,new HttpCallback() {
@Override
public void onSuccess(int code, String msg, final String[] info) {
if (code == 0 && info.length > 0) {
diff --git a/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java
index abf89e1fb..a19123a46 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveReadyViewHolder.java
@@ -492,7 +492,7 @@ public class LiveReadyViewHolder extends AbsViewHolder implements View.OnClickLi
return;
}
String title = mEditTitle.getText().toString().trim();
- LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, 0, new HttpCallback() {
+ LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, 0, false,new HttpCallback() {
@Override
public void onSuccess(int code, String msg, final String[] info) {
if (code == 0 && info.length > 0) {
diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java
index 440030882..36c8f80b1 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveRoomPlayViewHolder.java
@@ -6,6 +6,7 @@ import android.view.ViewGroup;
import com.alibaba.fastjson.JSONArray;
import com.yunbao.common.bean.EnterRoomNewModel;
import com.yunbao.common.bean.LiveBean;
+import com.yunbao.common.bean.UserBean;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.AbsViewHolder;
import com.yunbao.live.interfaces.ILiveLinkMicViewHolder;
@@ -70,6 +71,8 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL
public abstract void setPkEndview();
+ public abstract void setDrMicInfo(UserBean u);
+
public abstract void setLiveBeanLandscape(int landscape);
public void setLiveBean(LiveBean data) {
@@ -79,6 +82,18 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL
public void setViewUP(int i) {
}
+ public void setViewPkMic(int uid) {
+ }
+
+ public void setViewPk() {
+ }
+
+ public void setViewDrMic() {
+ }
+
+ public void setViewDrPk() {
+ }
+
public OnMicCallback getOnMicCallback() {
return onMicCallback;
}
@@ -101,6 +116,21 @@ public abstract class LiveRoomPlayViewHolder extends AbsViewHolder implements IL
public void clearFrame() {
}
+ public abstract void endPk();
+
+ public abstract void endpk(String liveUid);
+
+ public abstract void initSwEngine(String liveUid);
+
+ public abstract void removeLiveUid(String uid);
+
+ public abstract void removeDetailView();
+
+ public abstract void setPkView(String liveUid);
+
+ public abstract void claerDrPkInfoView();
+
+ public abstract void endLiveMic();
public interface OnMicCallback {
diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
index 312689662..4165190ae 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
@@ -51,6 +51,7 @@ import com.bumptech.glide.load.resource.gif.GifDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
+import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.makeramen.roundedimageview.RoundedImageView;
import com.ms.banner.Banner;
@@ -124,6 +125,7 @@ import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
+import com.yunbao.common.utils.L;
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.RouteUtil;
@@ -147,6 +149,7 @@ import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.activity.ZhuangBanActivity;
import com.yunbao.live.adapter.LiveChatAdapter;
import com.yunbao.live.adapter.LiveRoomFastMessageRecyclerViewAdapter;
@@ -179,6 +182,7 @@ import com.yunbao.live.dialog.ReceiveRendPacketPopup;
import com.yunbao.live.dialog.ResultRendPacketPopup;
import com.yunbao.live.event.LiveAnchorEvent;
import com.yunbao.live.event.LiveAudienceEvent;
+import com.yunbao.live.event.LivePKRightUserInfoEvent;
import com.yunbao.live.presenter.LiveDanmuPresenter;
import com.yunbao.live.presenter.LiveEnterRoomAnimPresenter;
import com.yunbao.live.presenter.LiveGiftAnimPresenter;
@@ -396,11 +400,18 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
private View quick_gift_reminder;
private int guardType = 0;
+ private static boolean isSw;
+
public LiveRoomViewHolder setGuardType(int guardType) {
this.guardType = guardType;
return this;
}
+ @Override
+ protected int getLayoutId() {
+ return R.layout.view_live_room;
+ }
+
@Subscribe(threadMode = ThreadMode.MAIN)
public void onUpdata(String str) {
if ("svga_new_user_gif".equals(str)) {
@@ -435,14 +446,12 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if ("svga_new_user_gif".equals(str)) {
if (fastMsgRecyclerView == null) return;
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
- fastMsgRecyclerView.getLayoutParams();
+ RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) fastMsgRecyclerView.getLayoutParams();
params1.rightMargin = DeviceUtils.getScreenWidth((Activity) mContext) / 3;
fastMsgRecyclerView.setLayoutParams(params1);
} else if ("stop_svga_new_user_gif".equals(str)) {
if (fastMsgRecyclerView == null) return;
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
- fastMsgRecyclerView.getLayoutParams();
+ RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) fastMsgRecyclerView.getLayoutParams();
params1.rightMargin = 0;
fastMsgRecyclerView.setLayoutParams(params1);
} else if ("showBanner".equals(str)) {
@@ -542,8 +551,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
- public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) {
+ public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager, boolean isSw) {
super(context, parentView);
+ this.isSw = isSw;
Contexts = context;
this.forAct = forActivity;
// this.isRy = isRys;
@@ -654,8 +664,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
bean.setContent(model.getMsg());
bean.setUserNiceName(model.getUserName());
- bean.setAtUserName(model.getXydgiftname())
- .setLevel(model.getLevel());
+ bean.setAtUserName(model.getXydgiftname()).setLevel(model.getLevel());
bean.setType(LiveChatBean.XYD_COMPLETE);
mLiveChatAdapter.insertItem(bean);
xydCompleteModels.add(model);
@@ -685,9 +694,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public void setSudName(String sudName, SudGameDateModel sudGameDateModel) {
sud_text_name = (TextView) findViewById(R.id.sud_text_name);
sud_layout_name = (LinearLayout) findViewById(R.id.sud_layout_name);
- sud_text_name.setText(WordUtil.isNewZh() ?
- String.format("主播创建了【%s】房间,快来与主播同玩~", sudName) :
- String.format("The anchor has created a 【%s】 room. Come and play with the anchor~", sudName));
+ sud_text_name.setText(WordUtil.isNewZh() ? String.format("主播创建了【%s】房间,快来与主播同玩~", sudName) : String.format("The anchor has created a 【%s】 room. Come and play with the anchor~", sudName));
sud_layout_name.setVisibility(View.VISIBLE);
ViewClicksAntiShake.clicksAntiShake(sud_layout_name, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
@@ -711,11 +718,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
sudNameHandler.postDelayed(sudNameRunnable, 10000);
}
- @Override
- protected int getLayoutId() {
- return R.layout.view_live_room;
- }
-
private View sudGameMin;
public void onShowHideEvent() {
@@ -868,10 +870,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
dr_pk_end_gif.setVisibility(View.VISIBLE);
visibility = false;
RequestOptions options = new RequestOptions().skipMemoryCache(true);//配置
- Glide.with(mContext).asGif()
- .apply(options)//应用配置
- .load(WordUtil.isNewZh() ? R.mipmap.drpkend : R.mipmap.drpkend_en)
- .listener(new RequestListener() {
+ Glide.with(mContext).asGif().apply(options)//应用配置
+ .load(WordUtil.isNewZh() ? R.mipmap.drpkend : R.mipmap.drpkend_en).listener(new RequestListener() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) {
return false;
@@ -883,12 +883,10 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
resource.setLoopCount(1);//只播放一次
}
//发送延时消息,通知动画结束
- mHandler.sendEmptyMessageDelayed(1,
- 3000);
+ mHandler.sendEmptyMessageDelayed(1, 3000);
return false;
}
- })
- .into(dr_pk_end_gif);
+ }).into(dr_pk_end_gif);
}
@@ -1260,7 +1258,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
topBanner1 = (Banner) findViewById(R.id.top_banner1);
topBanner2 = (Banner) findViewById(R.id.top_banner2);
- if (LivePushTxViewHolder.mTRTCCloud != null || LivePushRyViewHolder.rtcRoom != null) {
+ if (LivePushTxViewHolder.mTRTCCloud != null || LivePushSwViewHolder.rtcRoom != null) {
fans_btn.setVisibility(View.GONE);
}
mPkRankTopIcon.setVisibility(View.GONE);
@@ -1303,8 +1301,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
chat_view = (RelativeLayout) findViewById(R.id.chat_view);
int topMargin = mScreenWdith * 720 / 960 + 210;
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)
- chat_view.getLayoutParams();
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) chat_view.getLayoutParams();
params.topMargin = topMargin;
chat_view.setLayoutParams(params);
@@ -1314,8 +1311,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
msgLayout.setLayoutParams(msgLayoutLayoutParams);
voteManager.setMarginPosition(topMargin + DpUtil.dp2px(50));
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
- mChatRecyclerView.getLayoutParams();
+ RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) mChatRecyclerView.getLayoutParams();
params1.topMargin = DpUtil.dp2px(65);
mChatRecyclerView.setLayoutParams(params1);
@@ -1343,8 +1339,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
((LiveActivity) mContext).sendChatMessage("Hi~", null, null);
} else if (bean.getType() == -5) {
String url = CommonAppConfig.HOST + "/index.php?g=Appapi&m=Turntable&a=tricky";
- url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
- + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
+ url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
Log.i("tag", url);
Bundle bundle1 = new Bundle();
bundle1.putString("url", url);
@@ -1463,18 +1458,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
liveAudienceActivity.pausePlay();
if (code == 1008) {//余额不足
liveAudienceActivity.setCoinNotEnough(true);
- DialogUitl.showSimpleDialog(mContext, mContext.getString(R.string.live_coin_not_enough), false,
- new DialogUitl.SimpleCallback2() {
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- RouteUtil.forwardMyCoin(mContext);
- }
+ DialogUitl.showSimpleDialog(mContext, mContext.getString(R.string.live_coin_not_enough), false, new DialogUitl.SimpleCallback2() {
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ RouteUtil.forwardMyCoin(mContext);
+ }
- @Override
- public void onCancelClick() {
- liveAudienceActivity.exitLiveRoom();
- }
- });
+ @Override
+ public void onCancelClick() {
+ liveAudienceActivity.exitLiveRoom();
+ }
+ });
}
}
}
@@ -1506,11 +1500,9 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
// ft_hot_add = (FrameLayout) findViewById(R.id.ft_hot_add);
// img_hot_gif = (ImageView) findViewById(R.id.img_hot_gif);
findViewById(R.id.ft_hot_add).setOnClickListener(this);
- ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.open_sidebar), () -> Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.SIDEBAR)));
+ ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.open_sidebar), () -> Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.SIDEBAR)));
//点击心愿单
- ViewClicksAntiShake.clicksAntiShake(wishListLayout, () -> Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.WISH_LIST)));
+ ViewClicksAntiShake.clicksAntiShake(wishListLayout, () -> Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.WISH_LIST)));
mBanner1.setOutlineProvider(new ViewOutlineProvider() {
@Override
@@ -1576,11 +1568,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
// fastMsgRecyclerView.setItemAnimator(new DefaultItemAnimator());
//主播页面隐藏头部
+ if (mContext instanceof LiveSwAnchorActivity) {
+ findViewById(R.id.open_sidebar).setVisibility(View.GONE);
+ findViewById(R.id.btn_follow).setVisibility(View.GONE);
+ findViewById(R.id.live_rank_pk).setVisibility(View.GONE);
+ }
if (mContext instanceof LiveRyAnchorActivity) {
findViewById(R.id.open_sidebar).setVisibility(View.GONE);
findViewById(R.id.btn_follow).setVisibility(View.GONE);
findViewById(R.id.live_rank_pk).setVisibility(View.GONE);
}
+
customFullServiceNotify = (ImageView) findViewById(R.id.custom_full_service_notify);
reloadIM();
// initStarChallengeStatus();
@@ -1646,9 +1644,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
redTimeCountdown = 0;
timeHandler.removeCallbacks(timeRunnable);
StringBuffer stringBuffer = new StringBuffer();
- stringBuffer.append(mRedPacketModel.getRedPacketRemain())
- .append("/")
- .append(mRedPacketModel.getRedPacketQuantity());
+ stringBuffer.append(mRedPacketModel.getRedPacketRemain()).append("/").append(mRedPacketModel.getRedPacketQuantity());
redSchedule.setText(stringBuffer.toString());
openRedPacket.setText(String.format(mContext.getString(R.string.open_red_packet), mRedPacketModel.getRedPacketCount() + ""));
redPacketCountdown.setVisibility(View.GONE);
@@ -1669,18 +1665,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
anchorTimeHandler.postDelayed(anchorTimeRunnable, 1000);
Log.e("主播倒计时", String.format(mContext.getString(R.string.red_packet_countdown), TimeUtils.getTime(mCountdown)));
if (mCountdown == 180) {
- LiveNetManager.get(mContext).
- startRedPacketRobot(mLiveUid, mStream, mRedPacketModel.getRedPacketId(), new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(String data) {
+ LiveNetManager.get(mContext).startRedPacketRobot(mLiveUid, mStream, mRedPacketModel.getRedPacketId(), new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(String data) {
- }
+ }
- @Override
- public void onError(String error) {
- ToastUtil.show(error);
- }
- });
+ @Override
+ public void onError(String error) {
+ ToastUtil.show(error);
+ }
+ });
}
} else {
redPacket.setVisibility(View.GONE);
@@ -1693,19 +1688,23 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
layoutParams.topMargin = DpUtil.dp2px(110);
dragonImmediateParticipationTime.setLayoutParams(layoutParams);
}
+ if (dragonImmediateParticipationTime.getVisibility() == View.VISIBLE) {
+ RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) dragonImmediateParticipation.getLayoutParams();
+ layoutParams.topMargin = DpUtil.dp2px(110);
+ dragonImmediateParticipationTime.setLayoutParams(layoutParams);
+ }
anchorTimeHandler.removeCallbacks(anchorTimeRunnable);
- LiveNetManager.get(mContext).
- endRedPacket(mLiveUid, mRedPacketModel.getRedPacketId(), new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(String data) {
+ LiveNetManager.get(mContext).endRedPacket(mLiveUid, mRedPacketModel.getRedPacketId(), new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(String data) {
- }
+ }
- @Override
- public void onError(String error) {
- ToastUtil.show(error);
- }
- });
+ @Override
+ public void onError(String error) {
+ ToastUtil.show(error);
+ }
+ });
}
}
};
@@ -1738,6 +1737,22 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
layoutParams.topMargin = DpUtil.dp2px(110);
redPacket.setLayoutParams(layoutParams);
}
+ if (dragonImmediateParticipationTime.getVisibility() == View.VISIBLE && mContext instanceof LiveRyAnchorActivity) {
+ RelativeLayout.LayoutParams layoutParamsredPacket = (RelativeLayout.LayoutParams) redPacket.getLayoutParams();
+ layoutParamsredPacket.topMargin = DpUtil.dp2px(110);
+ redPacket.setLayoutParams(layoutParamsredPacket);
+
+ RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) dragonImmediateParticipationTime.getLayoutParams();
+ layoutParams.topMargin = DpUtil.dp2px(190);
+ dragonImmediateParticipationTime.setLayoutParams(layoutParams);
+ }
+ if(mContext instanceof LiveRyAnchorActivity ||mContext instanceof LiveSwAnchorActivity){
+ if (dragonImmediateParticipationTime.getVisibility() == View.GONE ) {
+ RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) redPacket.getLayoutParams();
+ layoutParams.topMargin = DpUtil.dp2px(110);
+ redPacket.setLayoutParams(layoutParams);
+ }
+ }
if (redPacketModel.getCountdown() > 180) {
redPacketQueue.setVisibility(View.GONE);
redPacketCountdown.setVisibility(View.VISIBLE);
@@ -1750,13 +1765,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
redPacketQueue.setVisibility(View.VISIBLE);
redPacketCountdown.setVisibility(View.GONE);
StringBuffer stringBuffer = new StringBuffer();
- stringBuffer.append(mRedPacketModel.getRedPacketRemain())
- .append("/")
- .append(mRedPacketModel.getRedPacketQuantity());
+ stringBuffer.append(mRedPacketModel.getRedPacketRemain()).append("/").append(mRedPacketModel.getRedPacketQuantity());
redSchedule.setText(stringBuffer.toString());
openRedPacket.setText(String.format(mContext.getString(R.string.open_red_packet), mRedPacketModel.getRedPacketCount() + ""));
}
- if (IMLoginManager.get(mContext).getUserInfo().anchorUserType() && mContext instanceof LiveRyAnchorActivity) {
+ if (IMLoginManager.get(mContext).getUserInfo().anchorUserType() && (mContext instanceof LiveSwAnchorActivity||mContext instanceof LiveRyAnchorActivity)) {
anchorTimeHandler.removeCallbacks(anchorTimeRunnable);
anchorTimeHandler.post(anchorTimeRunnable);
}
@@ -1768,41 +1781,33 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
@Override
public void onViewClicks() {
- if (!(mContext instanceof LiveRyAnchorActivity)) {
- LiveNetManager.get(mContext)
- .redPacketInfo(mLiveUid, redPacketModel.getRedPacketId(), new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(RedPacketInfoModel data) {
- if (TextUtils.equals(data.getReceiveStatus(), "0")) {
- redTimeCountdown = redTimeCountdown - 1;
- new XPopup.Builder(mContext)
- .asCustom(new ReceiveRendPacketPopup(mContext, redTimeCountdown, mLiveUid, mStream, redPacketModel.getRedPacketId(), data, false, isFans))
- .show();
- } else if (TextUtils.equals(data.getReceiveStatus(), "1")) {
- new XPopup.Builder(mContext)
- .asCustom(new ResultRendPacketPopup(mContext, true, data.setRedPacketId(redPacketModel.getRedPacketId()), false))
- .show();
- } else {
- if (data.getGiftModels().size() > 0) {
- new XPopup.Builder(mContext)
- .asCustom(new ResultRendPacketPopup(mContext, false, data.setRedPacketId(redPacketModel.getRedPacketId()), false))
- .show();
- } else {
- new XPopup.Builder(mContext)
- .asCustom(new ResultRendPacketPopup(mContext, true, data.setRedPacketId(redPacketModel.getRedPacketId()), false))
- .show();
- }
- }
+ if (!(mContext instanceof LiveSwAnchorActivity||mContext instanceof LiveRyAnchorActivity)) {
+ LiveNetManager.get(mContext).redPacketInfo(mLiveUid, redPacketModel.getRedPacketId(), new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(RedPacketInfoModel data) {
+ if (TextUtils.equals(data.getReceiveStatus(), "0")) {
+ redTimeCountdown = redTimeCountdown - 1;
+ new XPopup.Builder(mContext).asCustom(new ReceiveRendPacketPopup(mContext, redTimeCountdown, mLiveUid, mStream, redPacketModel.getRedPacketId(), data, false, isFans)).show();
+ } else if (TextUtils.equals(data.getReceiveStatus(), "1")) {
+ new XPopup.Builder(mContext).asCustom(new ResultRendPacketPopup(mContext, true, data.setRedPacketId(redPacketModel.getRedPacketId()), false)).show();
+ } else {
+ if (data.getGiftModels().size() > 0) {
+ new XPopup.Builder(mContext).asCustom(new ResultRendPacketPopup(mContext, false, data.setRedPacketId(redPacketModel.getRedPacketId()), false)).show();
+ } else {
+ new XPopup.Builder(mContext).asCustom(new ResultRendPacketPopup(mContext, true, data.setRedPacketId(redPacketModel.getRedPacketId()), false)).show();
}
+ }
+ }
- @Override
- public void onError(String error) {
- ToastUtil.show(error);
- }
- });
+ @Override
+ public void onError(String error) {
+ ToastUtil.show(error);
+ }
+ });
}
+
}
});
}
@@ -1822,9 +1827,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
public void setRedPacketInfoModel(RedPacketInfoModel redPacket) {
- new XPopup.Builder(mContext)
- .asCustom(new ReceiveRendPacketPopup(mContext, 0, mLiveUid, mStream, redPacket.getRedPacketId(), redPacket, true, isFans))
- .show();
+ new XPopup.Builder(mContext).asCustom(new ReceiveRendPacketPopup(mContext, 0, mLiveUid, mStream, redPacket.getRedPacketId(), redPacket, true, isFans)).show();
}
/**
@@ -1873,19 +1876,18 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
* 获取当前直播间星级
*/
private void initStarChallengeStatus() {
- LiveNetManager.get(mContext)
- .getStarChallengeStatus(PortraitLiveManager.liveID, new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(StarChallengeStatusModel data1) {
- showStart(data1);
- Log.e("PortraitLiveManager", data1.toString());
- }
+ LiveNetManager.get(mContext).getStarChallengeStatus(PortraitLiveManager.liveID, new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(StarChallengeStatusModel data1) {
+ showStart(data1);
+ Log.e("PortraitLiveManager", data1.toString());
+ }
- @Override
- public void onError(String error) {
- Log.e("PortraitLiveManager", error);
- }
- });
+ @Override
+ public void onError(String error) {
+ Log.e("PortraitLiveManager", error);
+ }
+ });
}
@@ -1907,7 +1909,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if (d_pk_view != null) {
d_pk_view.setVisibility(View.GONE);
}
- if (LivePushTxViewHolder.mTRTCCloud != null || LivePushRyViewHolder.rtcRoom != null) {
+ if (LivePushTxViewHolder.mTRTCCloud != null || LivePushSwViewHolder.rtcRoom != null) {
fans_btn.setVisibility(View.GONE);
}
mRedVal.setVisibility(View.GONE);
@@ -2029,155 +2031,94 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if (mBannerList2 != null && mBanner2 != null) {
btn_event2.setVisibility(View.VISIBLE);
if (mBannerList2.size() == 1) {
- mBanner2.setAutoPlay(false)
- .setPages(mBannerList2, new CustomViewHolder())
- .setDelayTime(3200)
- .setBannerStyle(BannerConfig.NOT_INDICATOR)
- .setOnBannerClickListener(new OnBannerClickListener() {
- @Override
- public void onBannerClick(List datas, int p) {
- if (showLoadingDialog()) {
+ mBanner2.setAutoPlay(false).setPages(mBannerList2, new CustomViewHolder()).setDelayTime(3200).setBannerStyle(BannerConfig.NOT_INDICATOR).setOnBannerClickListener(new OnBannerClickListener() {
+ @Override
+ public void onBannerClick(List datas, int p) {
+ if (showLoadingDialog()) {
+ return;
+ }
+ if (mBannerList2 != null) {
+ if (p >= 0 && p < mBannerList2.size()) {
+ IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
+ BannerBean bean = mBannerList2.get(p);
+ String type = "";
+ if (bean.getLink().equals("BattlePass")) {
+ RouteUtil.forwardBattlePass();
return;
}
- if (mBannerList2 != null) {
- if (p >= 0 && p < mBannerList2.size()) {
- IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
- BannerBean bean = mBannerList2.get(p);
- String type = "";
- if (bean.getLink().equals("BattlePass")) {
- RouteUtil.forwardBattlePass();
- return;
- }
- StringBuffer htmlUrl = new StringBuffer();
- //判断是否是星级活动
- if (bean.isStart()) {
+ StringBuffer htmlUrl = new StringBuffer();
+ //判断是否是星级活动
+ if (bean.isStart()) {
- type = bean.getModel().getType();
- htmlUrl.append(CommonAppConfig.HOST)
- .append("/")
- .append(bean.getModel().getActivityUrl())
- .append(bean.getModel().getActivityUrl().contains("?") ? "&nickname=" : "?nickname=")
- .append(userInfo.getUserNicename())
- .append("&token=")
- .append(userInfo.getToken())
- .append("&anchorUid=")
- .append(mLiveUid)
- .append("&uid=")
- .append(userInfo.getId())
- .append("&k=")
- .append(System.currentTimeMillis())
- .append("&isZh=")
- .append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
- } else {
- type = bean.getShow_type();
- htmlUrl.append(bean.getLink())
- .append("?uid=")
- .append(userInfo.getId())
- .append("&token=")
- .append(userInfo.getToken())
- .append("&anchorUid=")
- .append(mLiveUid)
- .append("&t=")
- .append(System.currentTimeMillis())
- .append("&isZh=")
- .append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
- }
- if (htmlUrl.toString().contains("StarChallenge")) {
- Map map_ekv = new HashMap();
- map_ekv.put("link", htmlUrl.toString());
- MobclickAgent.onEvent(mContext, "live_room_star", map_ekv);
- }
- if (TextUtils.equals(type, "1")) {
- ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false, 1);
- } else {
- Bundle bundle = new Bundle();
- bundle.putString("url", htmlUrl.toString());
- LiveHDDialogFragment fragment = new LiveHDDialogFragment();
- fragment.setArguments(bundle);
- fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
- }
- }
+ type = bean.getModel().getType();
+ htmlUrl.append(CommonAppConfig.HOST).append("/").append(bean.getModel().getActivityUrl()).append(bean.getModel().getActivityUrl().contains("?") ? "&nickname=" : "?nickname=").append(userInfo.getUserNicename()).append("&token=").append(userInfo.getToken()).append("&anchorUid=").append(mLiveUid).append("&uid=").append(userInfo.getId()).append("&k=").append(System.currentTimeMillis()).append("&isZh=").append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
+ } else {
+ type = bean.getShow_type();
+ htmlUrl.append(bean.getLink()).append("?uid=").append(userInfo.getId()).append("&token=").append(userInfo.getToken()).append("&anchorUid=").append(mLiveUid).append("&t=").append(System.currentTimeMillis()).append("&isZh=").append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
+ }
+ if (htmlUrl.toString().contains("StarChallenge")) {
+ Map map_ekv = new HashMap();
+ map_ekv.put("link", htmlUrl.toString());
+ MobclickAgent.onEvent(mContext, "live_room_star", map_ekv);
+ }
+ if (TextUtils.equals(type, "1")) {
+ ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false, 1);
+ } else {
+ Bundle bundle = new Bundle();
+ bundle.putString("url", htmlUrl.toString());
+ LiveHDDialogFragment fragment = new LiveHDDialogFragment();
+ fragment.setArguments(bundle);
+ fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}
}
- })
- .start();
+ }
+ }
+ }).start();
} else {
- mBanner2.setAutoPlay(true)
- .setPages(mBannerList2, new CustomViewHolder())
- .setDelayTime(3200)
- .setBannerStyle(BannerConfig.NOT_INDICATOR)
- .setOnBannerClickListener(new OnBannerClickListener() {
- @Override
- public void onBannerClick(List datas, int p) {
- if (showLoadingDialog()) {
+ mBanner2.setAutoPlay(true).setPages(mBannerList2, new CustomViewHolder()).setDelayTime(3200).setBannerStyle(BannerConfig.NOT_INDICATOR).setOnBannerClickListener(new OnBannerClickListener() {
+ @Override
+ public void onBannerClick(List datas, int p) {
+ if (showLoadingDialog()) {
+ return;
+ }
+ if (mBannerList2 != null) {
+ if (p >= 0 && p < mBannerList2.size()) {
+ IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
+ BannerBean bean = mBannerList2.get(p);
+ if (bean.getLink().equals("BattlePass")) {
+ RouteUtil.forwardBattlePass();
return;
}
- if (mBannerList2 != null) {
- if (p >= 0 && p < mBannerList2.size()) {
- IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
- BannerBean bean = mBannerList2.get(p);
- if (bean.getLink().equals("BattlePass")) {
- RouteUtil.forwardBattlePass();
- return;
- }
- String type = "";
- StringBuffer htmlUrl = new StringBuffer();
- //判断是否是星级活动
- if (bean.isStart()) {
- type = bean.getModel().getType();
- htmlUrl.append(CommonAppConfig.HOST)
- .append("/")
- .append(bean.getModel().getActivityUrl())
- .append(bean.getModel().getActivityUrl().contains("?") ? "&nickname=" : "?nickname=")
- .append(userInfo.getUserNicename())
- .append("&token=")
- .append(userInfo.getToken())
- .append("&anchorUid=")
- .append(mLiveUid)
- .append("&uid=")
- .append(userInfo.getId())
- .append("&k=")
- .append(System.currentTimeMillis())
- .append("&isZh=")
- .append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
+ String type = "";
+ StringBuffer htmlUrl = new StringBuffer();
+ //判断是否是星级活动
+ if (bean.isStart()) {
+ type = bean.getModel().getType();
+ htmlUrl.append(CommonAppConfig.HOST).append("/").append(bean.getModel().getActivityUrl()).append(bean.getModel().getActivityUrl().contains("?") ? "&nickname=" : "?nickname=").append(userInfo.getUserNicename()).append("&token=").append(userInfo.getToken()).append("&anchorUid=").append(mLiveUid).append("&uid=").append(userInfo.getId()).append("&k=").append(System.currentTimeMillis()).append("&isZh=").append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
- } else {
- type = bean.getShow_type();
- htmlUrl.append(bean.getLink())
- .append(bean.getLink().contains("?") ? "&uid=" : "?uid=")
- .append(userInfo.getId())
- .append("&token=")
- .append(userInfo.getToken())
- .append("&anchorUid=")
- .append(mLiveUid)
- .append("&liveUid=")
- .append(mLiveUid)
- .append("&t=")
- .append(System.currentTimeMillis())
- .append("&g=Appapi&m=Wish&a=index")
- .append("&isZh=")
- .append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
- }
- if (htmlUrl.toString().contains("StarChallenge")) {
- Map map_ekv = new HashMap();
- map_ekv.put("link", htmlUrl.toString());
- MobclickAgent.onEvent(mContext, "live_room_star", map_ekv);
- }
- if (TextUtils.equals(type, "1")) {
- ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false, 1);
- } else {
- Bundle bundle = new Bundle();
- bundle.putString("url", htmlUrl.toString());
- LiveHDDialogFragment fragment = new LiveHDDialogFragment();
- fragment.setArguments(bundle);
- fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
- }
- }
+ } else {
+ type = bean.getShow_type();
+ htmlUrl.append(bean.getLink()).append(bean.getLink().contains("?") ? "&uid=" : "?uid=").append(userInfo.getId()).append("&token=").append(userInfo.getToken()).append("&anchorUid=").append(mLiveUid).append("&liveUid=").append(mLiveUid).append("&t=").append(System.currentTimeMillis()).append("&g=Appapi&m=Wish&a=index").append("&isZh=").append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
+ }
+ if (htmlUrl.toString().contains("StarChallenge")) {
+ Map map_ekv = new HashMap();
+ map_ekv.put("link", htmlUrl.toString());
+ MobclickAgent.onEvent(mContext, "live_room_star", map_ekv);
+ }
+ if (TextUtils.equals(type, "1")) {
+ ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false, 1);
+ } else {
+ Bundle bundle = new Bundle();
+ bundle.putString("url", htmlUrl.toString());
+ LiveHDDialogFragment fragment = new LiveHDDialogFragment();
+ fragment.setArguments(bundle);
+ fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}
}
- })
- .start();
+ }
+ }
+ }).start();
}
}
@@ -2269,73 +2210,67 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
public void showLiveRoomActivityBanner() {
- LiveNetManager.get(mContext)
- .getLiveRoomActivityBanner(new com.yunbao.common.http.base.HttpCallback>() {
- @Override
- public void onSuccess(List data) {
- mBannerList4.clear();
- for (LiveRoomActivityBanner datum : data) {
- if (datum.getHidden() == 1) {
- continue;
- }
- BannerBean bean = new BannerBean();
- bean.setActivityId(datum.getActiveId());
- bean.setName(datum.getName());
- bean.setLink(datum.getLink());
- bean.setImageUrl(datum.getImg());
- bean.setShow_type(datum.getType());
- mBannerList4.add(bean);
- }
- showBanner4();
+ LiveNetManager.get(mContext).getLiveRoomActivityBanner(new com.yunbao.common.http.base.HttpCallback>() {
+ @Override
+ public void onSuccess(List data) {
+ mBannerList4.clear();
+ for (LiveRoomActivityBanner datum : data) {
+ if (datum.getHidden() == 1) {
+ continue;
}
+ BannerBean bean = new BannerBean();
+ bean.setActivityId(datum.getActiveId());
+ bean.setName(datum.getName());
+ bean.setLink(datum.getLink());
+ bean.setImageUrl(datum.getImg());
+ bean.setShow_type(datum.getType());
+ mBannerList4.add(bean);
+ }
+ showBanner4();
+ }
- @Override
- public void onError(String error) {
+ @Override
+ public void onError(String error) {
- }
- });
+ }
+ });
}
private void showBanner() {
if (mBannerList1 == null || mBannerList1.size() == 0 || mBanner1 == null) {
return;
}
- mBanner1.setAutoPlay(true)
- .setPages(mBannerList1, new CustomViewHolder())
- .setDelayTime(3000)
- .setBannerStyle(BannerConfig.NOT_INDICATOR)
- .setOnBannerClickListener(new OnBannerClickListener() {
- @Override
- public void onBannerClick(List datas, int p) {
- if (mBannerList1 != null) {
- if (p >= 0 && p < mBannerList1.size()) {
- BannerBean bean = mBannerList1.get(p);
- if (bean != null) {
- String link = bean.getLink();
- if (link.equals("BattlePass")) {
- RouteUtil.forwardBattlePass();
- return;
- }
- if (link.equals("sc")) {
- String url;
- if (!"".equals(bean.getmIntoUrl()) && bean.getmIntoUrl() != null) {
- url = CommonAppConfig.HOST + bean.getmIntoUrl() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
- } else {
- url = CommonAppConfig.HOST + "/h5/activity/firstTopUp/newUp.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
- }
- ZhuangBanActivity.forward(mContext, url, false, 1);
- } else if (link.equals("zxb")) {
- String url = CommonAppConfig.HOST + "/h5/activity/weekStar/index.html?&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
- ZhuangBanActivity.forward(mContext, url, false, 1);
- } else if (link.equals("xyd")) {
- openWishListWindow();
- }
+ mBanner1.setAutoPlay(true).setPages(mBannerList1, new CustomViewHolder()).setDelayTime(3000).setBannerStyle(BannerConfig.NOT_INDICATOR).setOnBannerClickListener(new OnBannerClickListener() {
+ @Override
+ public void onBannerClick(List datas, int p) {
+ if (mBannerList1 != null) {
+ if (p >= 0 && p < mBannerList1.size()) {
+ BannerBean bean = mBannerList1.get(p);
+ if (bean != null) {
+ String link = bean.getLink();
+ if (link.equals("BattlePass")) {
+ RouteUtil.forwardBattlePass();
+ return;
+ }
+ if (link.equals("sc")) {
+ String url;
+ if (!"".equals(bean.getmIntoUrl()) && bean.getmIntoUrl() != null) {
+ url = CommonAppConfig.HOST + bean.getmIntoUrl() + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
+ } else {
+ url = CommonAppConfig.HOST + "/h5/activity/firstTopUp/newUp.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
}
+ ZhuangBanActivity.forward(mContext, url, false, 1);
+ } else if (link.equals("zxb")) {
+ String url = CommonAppConfig.HOST + "/h5/activity/weekStar/index.html?&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
+ ZhuangBanActivity.forward(mContext, url, false, 1);
+ } else if (link.equals("xyd")) {
+ openWishListWindow();
}
}
}
- })
- .start();
+ }
+ }
+ }).start();
}
/**
@@ -2419,8 +2354,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
path = "/" + path;
}
String url = CommonAppConfig.HOST + path;
- url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
- + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid;
+ url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid;
bundle.putString("url", url);
bundle.putInt("height", DpUtil.dp2px(500));
bundle.putInt("show_type", 0);
@@ -2443,51 +2377,47 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
textParams.leftMargin = DpUtil.dp2px(5);
params.leftMargin = DpUtil.dp2px(5);
- API.get().pdLiveApi(mContext).getHourChartRank(mLiveUid)
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe(listResponseModel -> {
- List info = listResponseModel.getData().getInfo();
- if (!info.isEmpty()) {
- View hotView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
- View hourView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
- ImageView hotPic = hotView.findViewById(R.id.wish_pic);
- ImageView hourPic = hourView.findViewById(R.id.wish_pic);
- mHotText = hotView.findViewById(R.id.wish_index);
- mHourRank = hourView.findViewById(R.id.wish_index);
- mHotText.setText("0");
- mHotText.setLayoutParams(textParams);
- mHourRank.setLayoutParams(textParams);
- mHotText.setGravity(Gravity.CENTER);
- mHourRank.setGravity(Gravity.CENTER);
- setHourRankData(info.get(0).getRank());
- hotPic.setImageResource(R.drawable.icon_time_new);
- hourPic.setImageResource(R.drawable.icon_heat_new);
- hotPic.setLayoutParams(params);
- hourPic.setLayoutParams(params);
- flipper.addView(hotView);
- flipper.addView(hourView);
- flipper.startFlipping();
+ API.get().pdLiveApi(mContext).getHourChartRank(mLiveUid).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(listResponseModel -> {
+ List info = listResponseModel.getData().getInfo();
+ if (!info.isEmpty()) {
+ View hotView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
+ View hourView = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
+ ImageView hotPic = hotView.findViewById(R.id.wish_pic);
+ ImageView hourPic = hourView.findViewById(R.id.wish_pic);
+ mHotText = hotView.findViewById(R.id.wish_index);
+ mHourRank = hourView.findViewById(R.id.wish_index);
+ mHotText.setText("0");
+ mHotText.setLayoutParams(textParams);
+ mHourRank.setLayoutParams(textParams);
+ mHotText.setGravity(Gravity.CENTER);
+ mHourRank.setGravity(Gravity.CENTER);
+ setHourRankData(info.get(0).getRank());
+ hotPic.setImageResource(R.drawable.icon_time_new);
+ hourPic.setImageResource(R.drawable.icon_heat_new);
+ hotPic.setLayoutParams(params);
+ hourPic.setLayoutParams(params);
+ flipper.addView(hotView);
+ flipper.addView(hourView);
+ flipper.startFlipping();
// flipper.setOnClickListener(view -> {
//
// });
- ViewClicksAntiShake.clicksAntiShake(hotView, new ViewClicksAntiShake.ViewClicksCallBack() {
- @Override
- public void onViewClicks() {
- showUrlHDDialog(info.get(0).getUrl());
- }
- });
- ViewClicksAntiShake.clicksAntiShake(hourView, new ViewClicksAntiShake.ViewClicksCallBack() {
- @Override
- public void onViewClicks() {
- showUrlHDDialog(info.get(0).getUrl());
- }
- });
-
-
+ ViewClicksAntiShake.clicksAntiShake(hotView, new ViewClicksAntiShake.ViewClicksCallBack() {
+ @Override
+ public void onViewClicks() {
+ showUrlHDDialog(info.get(0).getUrl());
}
- }, Throwable::printStackTrace)
- .isDisposed();
+ });
+ ViewClicksAntiShake.clicksAntiShake(hourView, new ViewClicksAntiShake.ViewClicksCallBack() {
+ @Override
+ public void onViewClicks() {
+ showUrlHDDialog(info.get(0).getUrl());
+ }
+ });
+
+
+ }
+ }, Throwable::printStackTrace).isDisposed();
new LoadDian9TuUtil().loadDian9TuAssets2(mContext, hourRankLayout, "rectangle_new.png", 1);
}
@@ -2497,9 +2427,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
path = "/" + path;
}
String url = CommonAppConfig.HOST + path;
- url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token="
- + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid
- + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0");
+ url += "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0");
bundle.putString("url", url);
bundle.putInt("height", DpUtil.dp2px(500));
bundle.putInt("show_type", 0);
@@ -2589,85 +2517,82 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
public void initRankPKInfo(String mLiveUid, String pkUid) {
- LiveNetManager.get(mContext)
- .getRandomPk(mLiveUid, pkUid, new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(PkRankBean bean) {
- if (bean != null) {
- initPkRankView(bean);
- if (!StringUtil.isEmpty(bean.getClickUrl())) {
+ LiveNetManager.get(mContext).getRandomPk(mLiveUid, pkUid, new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(PkRankBean bean) {
+ if (bean != null) {
+ initPkRankView(bean);
+ if (!StringUtil.isEmpty(bean.getClickUrl())) {
-
- pkRankVf.setOnClickListener(v -> {
- MobclickAgent.onEvent(mContext, "live_room_sky", "天梯赛按钮");
- Bundle bundle = new Bundle();
- String path = bean.getClickUrl();
- if (!path.startsWith("/") && !path.startsWith("http")) {
- path = "/" + path;
- }
- String url = null;
- if (path.startsWith("http") || path.startsWith("/http")) {
- url = path;
- } else {
- url = CommonAppConfig.HOST + path;
- }
- if (!url.contains("?")) {
- url += "?";
- } else {
- url += "&";
- }
- url += "uid=" + CommonAppConfig.getInstance().getUid() + "&token="
- + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
- bundle.putString("url", url);
- bundle.putInt("height", DpUtil.dp2px(500));
- bundle.putInt("show_type", 0);
- bundle.putString("roomId", mLiveUid);
- LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
- liveHDDialogFragment.setArguments(bundle);
- liveHDDialogFragment.show(((AbsActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
- });
+ pkRankVf.setOnClickListener(v -> {
+ MobclickAgent.onEvent(mContext, "live_room_sky", "天梯赛按钮");
+ Bundle bundle = new Bundle();
+ String path = bean.getClickUrl();
+ if (!path.startsWith("/") && !path.startsWith("http")) {
+ path = "/" + path;
}
- pkRankLayout.setVisibility(View.VISIBLE);
-
- liveRankPk2.setVisibility(View.VISIBLE);
- mPkRankText.setText(bean.getName());
- ImgLoader.display(mContext, bean.getImg(), mPkRankIcon);
- pkUidTmp = "";
- if (StringUtil.isEmpty(bean.getPkTopImgUrl())) {
- return;
+ String url = null;
+ if (path.startsWith("http") || path.startsWith("/http")) {
+ url = path;
+ } else {
+ url = CommonAppConfig.HOST + path;
}
- if (!StringUtil.isEmpty(isLadders)) {
- bean.setPkTopImgUrl(isLadders);
+ if (!url.contains("?")) {
+ url += "?";
+ } else {
+ url += "&";
}
- if (Integer.parseInt(bean.getRedVal()) > 2) {
- mRedVal.setVisibility(View.VISIBLE);
- mRedVal.setText(bean.getRedVal() + (WordUtil.isNewZh() ? "連勝" : "Win"));
- }
- if (Integer.parseInt(bean.getBlueVal()) > 2) {
- mBlueVal.setVisibility(View.VISIBLE);
- mBlueVal.setText(bean.getBlueVal() + (WordUtil.isNewZh() ? "連勝" : "Win"));
- }
- mPkRankTopIcon.setVisibility(View.VISIBLE);
- ImgLoader.display(mContext, bean.getPkTopImgUrl(), mPkRankTopIcon);
- }
- if (mRedVal.getVisibility() == View.VISIBLE) {
- RelativeLayout.LayoutParams redValLayoutParams = (RelativeLayout.LayoutParams) mRedVal.getLayoutParams();
- redValLayoutParams.bottomMargin = DpUtil.dp2px(10);
- mRedVal.setLayoutParams(redValLayoutParams);
- }
- if (mBlueVal.getVisibility() == View.VISIBLE) {
- RelativeLayout.LayoutParams blueValLayoutParams = (RelativeLayout.LayoutParams) mBlueVal.getLayoutParams();
- blueValLayoutParams.bottomMargin = DpUtil.dp2px(10);
- mBlueVal.setLayoutParams(blueValLayoutParams);
- }
+ url += "uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid + "&isZh=" + (WordUtil.isNewZh() ? "1" : 0);
+ bundle.putString("url", url);
+ bundle.putInt("height", DpUtil.dp2px(500));
+ bundle.putInt("show_type", 0);
+ bundle.putString("roomId", mLiveUid);
+ LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
+ liveHDDialogFragment.setArguments(bundle);
+ liveHDDialogFragment.show(((AbsActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
+ });
}
+ pkRankLayout.setVisibility(View.VISIBLE);
- @Override
- public void onError(String error) {
- ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
- pkUidTmp = "";
+ liveRankPk2.setVisibility(View.VISIBLE);
+ mPkRankText.setText(bean.getName());
+ ImgLoader.display(mContext, bean.getImg(), mPkRankIcon);
+ pkUidTmp = "";
+ if (StringUtil.isEmpty(bean.getPkTopImgUrl())) {
+ return;
}
- });
+ if (!StringUtil.isEmpty(isLadders)) {
+ bean.setPkTopImgUrl(isLadders);
+ }
+ if (Integer.parseInt(bean.getRedVal()) > 2) {
+ mRedVal.setVisibility(View.VISIBLE);
+ mRedVal.setText(bean.getRedVal() + (WordUtil.isNewZh() ? "連勝" : "Win"));
+ }
+ if (Integer.parseInt(bean.getBlueVal()) > 2) {
+ mBlueVal.setVisibility(View.VISIBLE);
+ mBlueVal.setText(bean.getBlueVal() + (WordUtil.isNewZh() ? "連勝" : "Win"));
+ }
+ mPkRankTopIcon.setVisibility(View.VISIBLE);
+ ImgLoader.display(mContext, bean.getPkTopImgUrl(), mPkRankTopIcon);
+ }
+ if (mRedVal.getVisibility() == View.VISIBLE) {
+ RelativeLayout.LayoutParams redValLayoutParams = (RelativeLayout.LayoutParams) mRedVal.getLayoutParams();
+ redValLayoutParams.bottomMargin = DpUtil.dp2px(10);
+ mRedVal.setLayoutParams(redValLayoutParams);
+ }
+ if (mBlueVal.getVisibility() == View.VISIBLE) {
+ RelativeLayout.LayoutParams blueValLayoutParams = (RelativeLayout.LayoutParams) mBlueVal.getLayoutParams();
+ blueValLayoutParams.bottomMargin = DpUtil.dp2px(10);
+ mBlueVal.setLayoutParams(blueValLayoutParams);
+ }
+ }
+
+ @Override
+ public void onError(String error) {
+ ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
+ pkUidTmp = "";
+ }
+ });
}
/**
@@ -3052,7 +2977,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
bundle.putString("toUid", toUid);
bundle.putInt("isAttention", isAttention);
bundle.putBoolean("isLive", isAnchor);
- bundle.putBoolean("SBW", !(mContext instanceof LiveRyAnchorActivity));
+ bundle.putBoolean("SBW", !(mContext instanceof LiveSwAnchorActivity ||mContext instanceof LiveRyAnchorActivity ));
giftWallDialog.setArguments(bundle);
giftWallDialog.show(((AbsActivity) mContext).getSupportFragmentManager(), "GiftWallDialog");
@@ -3060,6 +2985,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public boolean pkHandler = true;
+ @Subscribe(threadMode = ThreadMode.MAIN)
+ public void setOtherInfo(LivePKRightUserInfoEvent livePKRightUserInfoEvent) {
+ setOtherInfo(livePKRightUserInfoEvent.getUid(), livePKRightUserInfoEvent.getuHead(), livePKRightUserInfoEvent.getuName());
+ }
+
//左上角显示对方主播头像及昵称
public void setOtherInfo(String touids, String url, String name) {
if (!pkHandler) {
@@ -3277,19 +3207,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
participation_time.postDelayed(sendMoneyRunnable, 1000);
} else {
participation_time.removeCallbacks(sendMoneyRunnable);
- LiveNetManager.get(mContext)
- .endSendMoneyLong(mLiveUid, mSendMoneyLongModel.getSendMoneyLongKey(),
- new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(SendMoneyLongModel data) {
+ LiveNetManager.get(mContext).endSendMoneyLong(mLiveUid, mSendMoneyLongModel.getSendMoneyLongKey(), new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(SendMoneyLongModel data) {
- }
+ }
- @Override
- public void onError(String error) {
+ @Override
+ public void onError(String error) {
- }
- });
+ }
+ });
}
}
};
@@ -3329,10 +3257,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
weekViewPic.setLayoutParams(params);
if (!TextUtils.isEmpty(giftWallLightenNumber) && !TextUtils.isEmpty(giftWallLightenTotal)) {
StringBuffer stringBuffer = new StringBuffer();
- stringBuffer.append(mContext.getString(R.string.gift_wall))
- .append(giftWallLightenNumber)
- .append("/")
- .append(giftWallLightenTotal);
+ stringBuffer.append(mContext.getString(R.string.gift_wall)).append(giftWallLightenNumber).append("/").append(giftWallLightenTotal);
View giftWall = LayoutInflater.from(mContext).inflate(R.layout.view_wish_list, null);
ImageView giftWallPic = giftWall.findViewById(R.id.wish_pic);
TextView giftText = giftWall.findViewById(R.id.wish_index);
@@ -3345,12 +3270,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
ViewClicksAntiShake.clicksAntiShake(giftWall, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.GIFT_WALL)
- .setUid(mLiveUid)
- .setVoicePress(true)
- .setAvatar(mAvatarUrl)
- .setUname(mAnchorName));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.GIFT_WALL).setUid(mLiveUid).setVoicePress(true).setAvatar(mAvatarUrl).setUname(mAnchorName));
}
});
}
@@ -3359,8 +3279,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
@Override
public void onViewClicks() {
MobclickAgent.onEvent(mContext, "live_room_week", "周星榜按钮");
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LIVE_WKS));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIVE_WKS));
}
});
wksAndGiftWall.addView(weekView);
@@ -3423,7 +3342,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
//直播间 粉丝排行榜
openMedalRankWindow();
} else if (i == R.id.btn_guard) {
- ((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveRyAnchorActivity);
+ ((LiveActivity) mContext).openNewGuardListWindow((mContext instanceof LiveSwAnchorActivity||mContext instanceof LiveRyAnchorActivity ));
} else if (i == R.id.btn_red_pack) {
((LiveActivity) mContext).openRedPackListWindow();
@@ -3431,13 +3350,13 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
((LiveActivity) mContext).openPrizePoolWindow();
} else if (i == R.id.user_more) {
MobclickAgent.onEvent(mContext, "live_room_audience_list", "直播间上面点观众列表按钮");
- ((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveRyAnchorActivity);
+ ((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveSwAnchorActivity||mContext instanceof LiveRyAnchorActivity);
} else if (i == R.id.hot_btn) {
- ((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveRyAnchorActivity);
+ ((LiveActivity) mContext).openUserMoreListWindow(1, false, false, mContext instanceof LiveSwAnchorActivity||mContext instanceof LiveRyAnchorActivity);
} else if (i == R.id.noble_seat) {
MobclickAgent.onEvent(mContext, "live_room_noble", "贵族按钮");
- ((LiveActivity) mContext).openUserMoreListWindow(1, false, true, mContext instanceof LiveRyAnchorActivity);
+ ((LiveActivity) mContext).openUserMoreListWindow(1, false, true, mContext instanceof LiveSwAnchorActivity||mContext instanceof LiveRyAnchorActivity);
} else if (i == R.id.btn_close) {
// if (sudGameMin!=null&&sudGameMin.getVisibility()==View.VISIBLE) {
// new XPopup.Builder(mContext)
@@ -3470,7 +3389,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
} else if (i == R.id.user_guard) {
MobclickAgent.onEvent(mContext, "anchor_avatar_guard", "守护按钮");
// ((LiveActivity) mContext).openUserMoreListWindow(2, true);
- ((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveRyAnchorActivity);
+ ((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveSwAnchorActivity||mContext instanceof LiveRyAnchorActivity);
}
if (i == R.id.lt_trickery) {
showTrickeryDialog();
@@ -3495,7 +3414,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
* @param in 展示的view
*/
private void changeMsgView(View out, View in) {
- if (mContext instanceof LiveRyAnchorActivity) {
+ if (mContext instanceof LiveSwAnchorActivity||mContext instanceof LiveRyAnchorActivity) {
return;
}
if (in.getVisibility() == View.VISIBLE) {
@@ -3643,8 +3562,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
@Override
public void callback(Integer isAttention) {
if (isAttention == 1) {
- LiveActivity.sendSystemMessage(
- CommonAppConfig.getInstance().getUserBean().getUserNiceName() + Contexts.getString(R.string.live_follow_anchor));
+ if (isSw) {
+ LiveActivity.sendSystemMessageSw(CommonAppConfig.getInstance().getUserBean().getUserNiceName() + Contexts.getString(R.string.live_follow_anchor));
+ } else {
+ LiveActivity.sendSystemMessageRy(CommonAppConfig.getInstance().getUserBean().getUserNiceName() + Contexts.getString(R.string.live_follow_anchor));
+ }
}
}
});
@@ -3705,6 +3627,24 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
((LiveAudienceActivity) mContext).setBackIndex(1);
((LiveAnchorActivity) mContext).onBackPressed();
}
+ } else if (mContext instanceof LiveSwAnchorActivity) {
+ if (forAct == 1) {
+ //是否关注0==没关注
+ if (isAttention == 0) {
+ if (isStayRoomfive) {
+ showFollowDialog(mNameText, mAvatarUrl, mContext);
+ } else {
+ LiveSwAnchorActivity.backIndex = 1;
+ ((LiveSwAnchorActivity) mContext).onBackPressed();
+ }
+ } else {
+ LiveSwAnchorActivity.backIndex = 1;
+ ((LiveSwAnchorActivity) mContext).onBackPressed();
+ }
+ } else {
+ LiveSwAnchorActivity.backIndex = 1;
+ ((LiveSwAnchorActivity) mContext).onBackPressed();
+ }
} else if (mContext instanceof LiveRyAnchorActivity) {
if (forAct == 1) {
//是否关注0==没关注
@@ -3979,8 +3919,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
setHotData(formatBigNum.formatBigNum(bean.getHot_num()));
mTvMedalRank.setText(bean.getMedalRankNum());
//开通粉丝勋章成功弹窗
- if (!isAncher && bean.getMedalFirstGet() != null && bean.getMedalFirstGet().equals("1")
- && bean.getUid().equals(CommonAppConfig.getInstance().getUid())) {
+ if (!isAncher && bean.getMedalFirstGet() != null && bean.getMedalFirstGet().equals("1") && bean.getUid().equals(CommonAppConfig.getInstance().getUid())) {
((LiveAudienceActivity) mContext).openFansMedalOkWindow();
}
@@ -3992,7 +3931,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if (mLiveGiftAnimPresenter == null) {
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
}
- mLiveGiftAnimPresenter.setLiveUidStream(mLiveUid,mStream);
+ mLiveGiftAnimPresenter.setLiveUidStream(mLiveUid, mStream);
mLiveGiftAnimPresenter.showGiftAnim(bean, isAncher);
}
@@ -4016,14 +3955,21 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
- public void showAllServerNotifyFFGGGD(AllServerNotifyFFGGGDJANEvent notifyFFGGGDJANEvent,boolean showB) {
+ public void showAllServerNotifyFFGGGD(AllServerNotifyFFGGGDJANEvent notifyFFGGGDJANEvent, boolean showB) {
if (mLiveGiftAnimPresenter == null) {
mLiveGiftAnimPresenter = new LiveGiftAnimPresenter(mContext, mContentView, mGifImageView, mSVGAImageView, mLiveGiftPrizePoolContainer, windowManager);
}
mLiveGiftAnimPresenter.setLiveUidStream(mLiveUid, mStream);
- mLiveGiftAnimPresenter.showAllServerNotifyFFGGGD(notifyFFGGGDJANEvent,showB);
+ mLiveGiftAnimPresenter.showAllServerNotifyFFGGGD(notifyFFGGGDJANEvent, showB);
}
+ public void cancelAllAnim() {
+ if (mLiveGiftAnimPresenter != null) {
+ mLiveGiftAnimPresenter.releaseServiceNotice();
+ }
+ }
+
+
//全服通知 购买坐骑
public void showBuyZuojiMessage(LiveReceiveGiftBean bean) {
if (mLiveGiftAnimPresenter == null) {
@@ -4049,60 +3995,25 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
switch (bean.getNobilityid()) {
case "1":
- noble.setRootView(bean.getUhead(),
- bean.getUname(),
- bean.getAncherName(),
- bean.getRoomnum())
- .setRoleType(NobleNoticeView.RoleType.BARON)
- .setCallBack(() -> gotoLive(bean.getRoomnum()));
+ noble.setRootView(bean.getUhead(), bean.getUname(), bean.getAncherName(), bean.getRoomnum()).setRoleType(NobleNoticeView.RoleType.BARON).setCallBack(() -> gotoLive(bean.getRoomnum()));
break;
case "2":
- noble.setRootView(bean.getUhead(),
- bean.getUname(),
- bean.getAncherName(),
- bean.getRoomnum())
- .setRoleType(NobleNoticeView.RoleType.VISCOUNT)
- .setCallBack(() -> gotoLive(bean.getRoomnum()));
+ noble.setRootView(bean.getUhead(), bean.getUname(), bean.getAncherName(), bean.getRoomnum()).setRoleType(NobleNoticeView.RoleType.VISCOUNT).setCallBack(() -> gotoLive(bean.getRoomnum()));
break;
case "3":
- noble.setRootView(bean.getUhead(),
- bean.getUname(),
- bean.getAncherName(),
- bean.getRoomnum())
- .setRoleType(NobleNoticeView.RoleType.MARQUIS)
- .setCallBack(() -> gotoLive(bean.getRoomnum()));
+ noble.setRootView(bean.getUhead(), bean.getUname(), bean.getAncherName(), bean.getRoomnum()).setRoleType(NobleNoticeView.RoleType.MARQUIS).setCallBack(() -> gotoLive(bean.getRoomnum()));
break;
case "4":
- noble.setRootView(bean.getUhead(),
- bean.getUname(),
- bean.getAncherName(),
- bean.getRoomnum())
- .setRoleType(NobleNoticeView.RoleType.DUKE)
- .setCallBack(() -> gotoLive(bean.getRoomnum()));
+ noble.setRootView(bean.getUhead(), bean.getUname(), bean.getAncherName(), bean.getRoomnum()).setRoleType(NobleNoticeView.RoleType.DUKE).setCallBack(() -> gotoLive(bean.getRoomnum()));
break;
case "5":
- noble.setRootView(bean.getUhead(),
- bean.getUname(),
- bean.getAncherName(),
- bean.getRoomnum())
- .setRoleType(NobleNoticeView.RoleType.KING)
- .setCallBack(() -> gotoLive(bean.getRoomnum()));
+ noble.setRootView(bean.getUhead(), bean.getUname(), bean.getAncherName(), bean.getRoomnum()).setRoleType(NobleNoticeView.RoleType.KING).setCallBack(() -> gotoLive(bean.getRoomnum()));
break;
case "6":
- noble.setRootView(bean.getUhead(),
- bean.getUname(),
- bean.getAncherName(),
- bean.getRoomnum())
- .setRoleType(NobleNoticeView.RoleType.EMPEROR)
- .setCallBack(() -> gotoLive(bean.getRoomnum()));
+ noble.setRootView(bean.getUhead(), bean.getUname(), bean.getAncherName(), bean.getRoomnum()).setRoleType(NobleNoticeView.RoleType.EMPEROR).setCallBack(() -> gotoLive(bean.getRoomnum()));
break;
case "7":
- noble.setRootView(bean.getUhead(),
- bean.getUname(),
- bean.getAncherName(),
- bean.getRoomnum())
- .setRoleType(NobleNoticeView.RoleType.BETTER_EMPEROR)
- .setCallBack(() -> gotoLive(bean.getRoomnum()));
+ noble.setRootView(bean.getUhead(), bean.getUname(), bean.getAncherName(), bean.getRoomnum()).setRoleType(NobleNoticeView.RoleType.BETTER_EMPEROR).setCallBack(() -> gotoLive(bean.getRoomnum()));
break;
}
}
@@ -4413,8 +4324,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public void setFastMessage(List greetings) {
fastMsgRecyclerView.setVisibility(View.VISIBLE);
fastMessageRecyclerViewAdapter.setMessage(greetings);
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
- mChatRecyclerView.getLayoutParams();
+ RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) mChatRecyclerView.getLayoutParams();
if (greetings.size() > 0) {
params1.bottomMargin = 100;
} else {
@@ -4474,14 +4384,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
public void openGiftDialog(String giftId) {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP)
- .setmLiveUid(mLiveUid)
- .setmStream(mStream)
- .setPk(false)
- .setLiveGuardInfo(null)
- .setmWishGiftId(giftId)
- .setUname("0"));//setUname==by
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP).setmLiveUid(mLiveUid).setmStream(mStream).setPk(false).setLiveGuardInfo(null).setmWishGiftId(giftId).setUname("0"));//setUname==by
}
public void setFansGroup(String isFans) {
@@ -4599,32 +4502,27 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
return;
}
- mBanner3.setAutoPlay(true)
- .setPages(mBannerList3, new Banner3CustomViewHolder())
- .setDelayTime(3000)
- .setBannerStyle(BannerConfig.NOT_INDICATOR)
- .setOnBannerClickListener(new OnBannerClickListener() {
- @Override
- public void onBannerClick(List datas, int p) {
- if (mBannerList3 != null) {
- if (mBannerList3.get(p).getLink().equals("BattlePass")) {
- RouteUtil.forwardBattlePass();
- return;
- }
- if (mBannerList3.get(p).getLink().equals("0")) {
- if (p == 0) {
- ((LiveAudienceActivity) mContext).openGiftWindow("" + bean1.getId(), "1");
- EventBus.getDefault().post("svga_new_user_gif");
- } else if (p == 1) {
- EventBus.getDefault().post("svga_new_user_follow");
- } else if (p == 2) {
- EventBus.getDefault().post("svga_new_user_double");
- }
- }
+ mBanner3.setAutoPlay(true).setPages(mBannerList3, new Banner3CustomViewHolder()).setDelayTime(3000).setBannerStyle(BannerConfig.NOT_INDICATOR).setOnBannerClickListener(new OnBannerClickListener() {
+ @Override
+ public void onBannerClick(List datas, int p) {
+ if (mBannerList3 != null) {
+ if (mBannerList3.get(p).getLink().equals("BattlePass")) {
+ RouteUtil.forwardBattlePass();
+ return;
+ }
+ if (mBannerList3.get(p).getLink().equals("0")) {
+ if (p == 0) {
+ ((LiveAudienceActivity) mContext).openGiftWindow("" + bean1.getId(), "1");
+ EventBus.getDefault().post("svga_new_user_gif");
+ } else if (p == 1) {
+ EventBus.getDefault().post("svga_new_user_follow");
+ } else if (p == 2) {
+ EventBus.getDefault().post("svga_new_user_double");
}
}
- })
- .start();
+ }
+ }
+ }).start();
}
/**
@@ -4638,69 +4536,61 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
for (BannerBean bean : mBannerList4) {
Log.i("debug", "showBanner4: " + bean.toString());
}
- mBanner4.setAutoPlay(true)
- .setPages(mBannerList4, new Banner4CustomViewHolder())
- .setDelayTime(2800)
- .setBannerStyle(BannerConfig.NOT_INDICATOR)
- .setOnBannerClickListener(new OnBannerClickListener() {
+ mBanner4.setAutoPlay(true).setPages(mBannerList4, new Banner4CustomViewHolder()).setDelayTime(2800).setBannerStyle(BannerConfig.NOT_INDICATOR).setOnBannerClickListener(new OnBannerClickListener() {
- @Override
- public void onBannerClick(List datas, int p) {
- if (mBannerList4.get(p).getLink().equals("BattlePass") || mBannerList4.get(p).getType() == 888) {
- RouteUtil.forwardBattlePass();
- return;
- }
- if (TextUtils.equals("特惠首冲", mBannerList4.get(p).getName())) {
+ @Override
+ public void onBannerClick(List datas, int p) {
+ if (mBannerList4.get(p).getLink().equals("BattlePass") || mBannerList4.get(p).getType() == 888) {
+ RouteUtil.forwardBattlePass();
+ return;
+ }
+ if (TextUtils.equals("特惠首冲", mBannerList4.get(p).getName())) {
- Map map_ekv = new HashMap();
- map_ekv.put("link", mBannerList4.get(p).getLink());
- MobclickAgent.onEvent(mContext, "live_room_first_charge", map_ekv);
- }
- Log.i("debug", "onBannerClick: " + mBannerList4.get(p).toString());
- BannerBean bean = mBannerList4.get(p);
- if (showLoadingDialog()) {
- return;
- }
- if (bean.getActivityId() == -1) {//-1写死跳活动弹窗
- Bus.get().post(new LiveAudienceEvent()
- .setActivity(true)
- .setType(LiveAudienceEvent.LiveAudienceType.BOTTOM_COLLECTION));
- } else if (bean.getActivityId() == 0) {
- openWebDialog(bean.getLink());
- } else {
- LiveGameDialogFragment fragment = new LiveGameDialogFragment("1".equals(bean.getShow_type()));
- fragment.setActivityId(bean.getActivityId());
- fragment.setRoomId(mLiveUid);
- fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGameDialogFragment");
- }
+ Map map_ekv = new HashMap();
+ map_ekv.put("link", mBannerList4.get(p).getLink());
+ MobclickAgent.onEvent(mContext, "live_room_first_charge", map_ekv);
+ }
+ Log.i("debug", "onBannerClick: " + mBannerList4.get(p).toString());
+ BannerBean bean = mBannerList4.get(p);
+ if (showLoadingDialog()) {
+ return;
+ }
+ if (bean.getActivityId() == -1) {//-1写死跳活动弹窗
+ Bus.get().post(new LiveAudienceEvent().setActivity(true).setType(LiveAudienceEvent.LiveAudienceType.BOTTOM_COLLECTION));
+ } else if (bean.getActivityId() == 0) {
+ openWebDialog(bean.getLink());
+ } else {
+ LiveGameDialogFragment fragment = new LiveGameDialogFragment("1".equals(bean.getShow_type()));
+ fragment.setActivityId(bean.getActivityId());
+ fragment.setRoomId(mLiveUid);
+ fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveGameDialogFragment");
+ }
+ }
+
+
+ private void openWebDialog(String url) {
+ if (!url.startsWith("http")) {
+ if (url.startsWith("/")) {
+ url = CommonAppConfig.HOST + url;
+ } else {
+ url = CommonAppConfig.HOST + "/" + url;
}
+ }
+ if (url.contains("?")) {
+ url += "&";
+ } else {
+ url += "?";
+ }
+ url += "uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid;
+ Log.i("tag", url);
+ Bundle bundle1 = new Bundle();
+ bundle1.putString("url", url);
+ LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
+ liveHDDialogFragment.setArguments(bundle1);
+ liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
-
- private void openWebDialog(String url) {
- if (!url.startsWith("http")) {
- if (url.startsWith("/")) {
- url = CommonAppConfig.HOST + url;
- } else {
- url = CommonAppConfig.HOST + "/" + url;
- }
- }
- if (url.contains("?")) {
- url += "&";
- } else {
- url += "?";
- }
- url += "uid=" + CommonAppConfig.getInstance().getUid() + "&token="
- + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid;
- Log.i("tag", url);
- Bundle bundle1 = new Bundle();
- bundle1.putString("url", url);
- LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
- liveHDDialogFragment.setArguments(bundle1);
- liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
-
- }
- })
- .start();
+ }
+ }).start();
}
private int nowTime = 0;
@@ -4877,7 +4767,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
lt_trickster_salvation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- if (mContext instanceof LiveRyAnchorActivity) {
+ if (mContext instanceof LiveSwAnchorActivity||mContext instanceof LiveRyAnchorActivity) {
dialog.dismiss();
return;
}
@@ -4903,9 +4793,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
* @param msgModel
*/
public void showFullScreen(MsgModel msgModel) {
- fullScreen.setUserNameAndUserText(msgModel.getUserName(), msgModel.getTrumpetMsg())
- .setType(msgModel.getRoleType())
- .setCallBack(() -> gotoLive(msgModel.getAnchorId()));
+ fullScreen.setUserNameAndUserText(msgModel.getUserName(), msgModel.getTrumpetMsg()).setType(msgModel.getRoleType()).setCallBack(() -> gotoLive(msgModel.getAnchorId()));
}
/**
@@ -4920,20 +4808,14 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) {
if (liveBean == null) {
return;
}
if (MicStatusManager.getInstance().getMicStatus() == MicStatusManager.MIC_TYPE_REQUEST) {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LIAN_MAI)
- .setMicIng(1)
- .setBean(liveBean).setLiveType(liveType).setLiveTypeVal(Integer.parseInt(liveTypeVal)));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIAN_MAI).setMicIng(1).setBean(liveBean).setLiveType(liveType).setLiveTypeVal(Integer.parseInt(liveTypeVal)));
} else if (MicStatusManager.getInstance().getMicStatus() == MicStatusManager.MIC_TYPE_OPEN) {
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.LIAN_MAI)
- .setMicIng(2)
- .setBean(liveBean).setLiveType(liveType).setLiveTypeVal(Integer.parseInt(liveTypeVal)));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.LIAN_MAI).setMicIng(2).setBean(liveBean).setLiveType(liveType).setLiveTypeVal(Integer.parseInt(liveTypeVal)));
} else {
if (MicStatusManager.getInstance().isMic(liveUid)) {
MicStatusManager.getInstance().showDownMicDialog(mContext);
@@ -5167,12 +5049,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
@Override
public void run() {
BannerBean bannerBean = new BannerBean();
- bannerBean.setWishlistIcon(model.getWishlistIcon())
- .setWishlistName(model.getWishlistName())
- .setWishlistNum(model.getWishlistNum())
- .setWishlistProgress(model.getWishlistProgress())
- .setmLink(CommonAppConfig.HOST + "/index.php")
- .setType(1);
+ bannerBean.setWishlistIcon(model.getWishlistIcon()).setWishlistName(model.getWishlistName()).setWishlistNum(model.getWishlistNum()).setWishlistProgress(model.getWishlistProgress()).setmLink(CommonAppConfig.HOST + "/index.php").setType(1);
bannerBean.setShow_type("2");
mTopBannerList.add(bannerBean);
LiveChatBean bean = new LiveChatBean();
@@ -5301,8 +5178,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if (mPkTimeCount2 == 0) {
timeTitle.setVisibility(View.GONE);
timeTitle.removeCallbacks(countdownRunnable);
- Bus.get().post(new LiveAudienceEvent()
- .setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT));
+ Bus.get().post(new LiveAudienceEvent().setType(LiveAudienceEvent.LiveAudienceType.PK_TIME_COUNT));
} else {
timeTitle.setVisibility(View.VISIBLE);
Log.e("多人Pk", "countdownRunnable mPkTimeCount:" + mPkTimeCount2);
@@ -5315,47 +5191,53 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
};
+
public void upDataPkScore(JSONArray pkScores, int time) {
+ L.eSw("upDataPkScore(JSONArray pkScores, int time) {" + new Gson().toJson(pkScores));
isShowGif = true;
- if (detailsView == null) {
- detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
- timeTitle = detailsView.findViewById(R.id.time_title);
- textTime = detailsView.findViewById(R.id.text_time);
- linearGrade1 = detailsView.findViewById(R.id.lin_pk1);
- linearGrade2 = detailsView.findViewById(R.id.lin_pk2);
- linearGrade3 = detailsView.findViewById(R.id.lin_pk3);
- linearGrade4 = detailsView.findViewById(R.id.lin_pk4);
- textPkName1 = detailsView.findViewById(R.id.text_pk_name1);
- textPkName2 = detailsView.findViewById(R.id.text_pk_name2);
- textPkName3 = detailsView.findViewById(R.id.text_pk_name3);
- textPkName4 = detailsView.findViewById(R.id.text_pk_name4);
- textGrade1 = detailsView.findViewById(R.id.text_grade1);
- textGrade2 = detailsView.findViewById(R.id.text_grade2);
- textGrade3 = detailsView.findViewById(R.id.text_grade3);
- textGrade4 = detailsView.findViewById(R.id.text_grade4);
- imageGrade1 = detailsView.findViewById(R.id.image_grade1);
- imageGrade2 = detailsView.findViewById(R.id.image_grade2);
- imageGrade3 = detailsView.findViewById(R.id.image_grade3);
- imageGrade4 = detailsView.findViewById(R.id.image_grade4);
- linearGrade1.setVisibility(View.GONE);
- linearGrade2.setVisibility(View.GONE);
- linearGrade3.setVisibility(View.GONE);
- linearGrade4.setVisibility(View.GONE);
- mRoot.addView(detailsView);
- mRoot.post(new Runnable() {
- @Override
- public void run() {
- int mScreenWdith = ScreenDimenUtil.getInstance().getScreenWdith();
- int vHeight = mScreenWdith * 720 / 960;
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) detailsView.getLayoutParams();
- params.height = vHeight;
- params.width = mScreenWdith;
- params.topMargin = DpUtil.dp2px(105);
- params.addRule(RelativeLayout.ALIGN_TOP);
- detailsView.setLayoutParams(params);
- }
- });
+ if (detailsView != null) {
+ mRoot.removeView(detailsView);
}
+ L.eSw("upDataPkScore(JSONArray pkScores, int time) {detailsView=null");
+ detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
+ timeTitle = detailsView.findViewById(R.id.time_title);
+ textTime = detailsView.findViewById(R.id.text_time);
+ linearGrade1 = detailsView.findViewById(R.id.lin_pk1);
+ linearGrade2 = detailsView.findViewById(R.id.lin_pk2);
+ linearGrade3 = detailsView.findViewById(R.id.lin_pk3);
+ linearGrade4 = detailsView.findViewById(R.id.lin_pk4);
+ textPkName1 = detailsView.findViewById(R.id.text_pk_name1);
+ textPkName2 = detailsView.findViewById(R.id.text_pk_name2);
+ textPkName3 = detailsView.findViewById(R.id.text_pk_name3);
+ textPkName4 = detailsView.findViewById(R.id.text_pk_name4);
+ textGrade1 = detailsView.findViewById(R.id.text_grade1);
+ textGrade2 = detailsView.findViewById(R.id.text_grade2);
+ textGrade3 = detailsView.findViewById(R.id.text_grade3);
+ textGrade4 = detailsView.findViewById(R.id.text_grade4);
+ imageGrade1 = detailsView.findViewById(R.id.image_grade1);
+ imageGrade2 = detailsView.findViewById(R.id.image_grade2);
+ imageGrade3 = detailsView.findViewById(R.id.image_grade3);
+ imageGrade4 = detailsView.findViewById(R.id.image_grade4);
+ //暂时关闭
+ linearGrade1.setVisibility(View.GONE);
+ linearGrade2.setVisibility(View.GONE);
+ linearGrade3.setVisibility(View.GONE);
+ linearGrade4.setVisibility(View.GONE);
+
+ mRoot.addView(detailsView);
+ mRoot.post(new Runnable() {
+ @Override
+ public void run() {
+ int mScreenWdith = ScreenDimenUtil.getInstance().getScreenWdith();
+ int vHeight = mScreenWdith * 720 / 960;
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) detailsView.getLayoutParams();
+ params.height = vHeight;
+ params.width = mScreenWdith;
+ params.topMargin = DpUtil.dp2px(105);
+ params.addRule(RelativeLayout.ALIGN_TOP);
+ detailsView.setLayoutParams(params);
+ }
+ });
if (time > 0) {
mPkTimeCount2 = time;
drPKtIME = time;
@@ -5445,7 +5327,142 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
showUserDialog(userId3);
}
});
+ }
+ public void upDataPkScore(JSONArray pkScores) {
+ L.eSw("upDataPkScore(JSONArray pkScores, int time) {" + new Gson().toJson(pkScores));
+ isShowGif = true;
+ if (detailsView == null) {
+ L.eSw("upDataPkScore(JSONArray pkScores, int time) {detailsView=null");
+ detailsView = LayoutInflater.from(mContext).inflate(R.layout.view_live_pk_details, null);
+ timeTitle = detailsView.findViewById(R.id.time_title);
+ textTime = detailsView.findViewById(R.id.text_time);
+ linearGrade1 = detailsView.findViewById(R.id.lin_pk1);
+ linearGrade2 = detailsView.findViewById(R.id.lin_pk2);
+ linearGrade3 = detailsView.findViewById(R.id.lin_pk3);
+ linearGrade4 = detailsView.findViewById(R.id.lin_pk4);
+ textPkName1 = detailsView.findViewById(R.id.text_pk_name1);
+ textPkName2 = detailsView.findViewById(R.id.text_pk_name2);
+ textPkName3 = detailsView.findViewById(R.id.text_pk_name3);
+ textPkName4 = detailsView.findViewById(R.id.text_pk_name4);
+ textGrade1 = detailsView.findViewById(R.id.text_grade1);
+ textGrade2 = detailsView.findViewById(R.id.text_grade2);
+ textGrade3 = detailsView.findViewById(R.id.text_grade3);
+ textGrade4 = detailsView.findViewById(R.id.text_grade4);
+ imageGrade1 = detailsView.findViewById(R.id.image_grade1);
+ imageGrade2 = detailsView.findViewById(R.id.image_grade2);
+ imageGrade3 = detailsView.findViewById(R.id.image_grade3);
+ imageGrade4 = detailsView.findViewById(R.id.image_grade4);
+ //暂时关闭
+ linearGrade1.setVisibility(View.GONE);
+ linearGrade2.setVisibility(View.GONE);
+ linearGrade3.setVisibility(View.GONE);
+ linearGrade4.setVisibility(View.GONE);
+ mRoot.removeView(detailsView);
+ mRoot.addView(detailsView);
+ mRoot.post(new Runnable() {
+ @Override
+ public void run() {
+ int mScreenWdith = ScreenDimenUtil.getInstance().getScreenWdith();
+ int vHeight = mScreenWdith * 720 / 960;
+ RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) detailsView.getLayoutParams();
+ params.height = vHeight;
+ params.width = mScreenWdith;
+ params.topMargin = DpUtil.dp2px(105);
+ params.addRule(RelativeLayout.ALIGN_TOP);
+ detailsView.setLayoutParams(params);
+ }
+ });
+ }
+ Log.e("多人Pk", "upDataPkScore mPkTimeCount:" + mPkTimeCount);
+ if (pkScores.size() == 2) {
+ linearGrade3.setVisibility(View.GONE);
+ linearGrade4.setVisibility(View.GONE);
+ } else if(pkScores.size()==3){
+ linearGrade4.setVisibility(View.GONE);
+ }
+ for (int i = 0; i < pkScores.size(); i++) {
+ JSONObject score = pkScores.getJSONObject(i);
+ String userNiceName = score.getString("user_nicename");
+ long userScore = score.getLong("score");
+ String userId = score.getString("id");
+ int resScore = R.mipmap.icon_livepk_no1;
+ if (userScore == 0 && !score.containsKey("paiming")) {
+ resScore = R.mipmap.icon_livepk_no1;
+ } else {
+ if (score.containsKey("paiming")) {
+ int ranking = score.getIntValue("paiming");
+ switch (ranking) {
+ case 1:
+ resScore = R.mipmap.icon_livepk_no1;
+ break;
+ case 2:
+ resScore = R.mipmap.icon_livepk_no2;
+ break;
+ case 3:
+ resScore = R.mipmap.icon_livepk_no3;
+ break;
+ case 4:
+ resScore = R.mipmap.icon_livepk_no4;
+ break;
+ }
+ }
+ }
+ if (i == 0) {
+ linearGrade1.setVisibility(View.VISIBLE);
+ textPkName1.setText(userNiceName);
+ ImgLoader.display(mContext, resScore, imageGrade1);
+ textGrade1.setText(String.valueOf(userScore));
+
+ } else if (i == 1) {
+ linearGrade2.setVisibility(View.VISIBLE);
+ textPkName2.setText(userNiceName);
+ ImgLoader.display(mContext, resScore, imageGrade2);
+ textGrade2.setText(String.valueOf(userScore));
+ userId2 = userId;
+ } else if (i == 2) {
+ if (pkScores.size() == 3) {
+ linearGrade4.setVisibility(View.VISIBLE);
+ textPkName4.setText(userNiceName);
+ ImgLoader.display(mContext, resScore, imageGrade4);
+ textGrade4.setText(String.valueOf(userScore));
+ userId4 = userId;
+ } else {
+ linearGrade3.setVisibility(View.VISIBLE);
+ textPkName3.setText(userNiceName);
+ ImgLoader.display(mContext, resScore, imageGrade3);
+ textGrade3.setText(String.valueOf(userScore));
+ userId3 = userId;
+ }
+
+ } else if (i == 3) {
+ linearGrade4.setVisibility(View.VISIBLE);
+ textPkName4.setText(userNiceName);
+ ImgLoader.display(mContext, resScore, imageGrade4);
+ textGrade4.setText(String.valueOf(userScore));
+ userId4 = userId;
+ }
+ }
+
+
+ textPkName2.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showUserDialog(userId2);
+ }
+ });
+ textPkName4.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showUserDialog(userId4);
+ }
+ });
+ textPkName3.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showUserDialog(userId3);
+ }
+ });
}
@@ -5474,8 +5491,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
* @param landscape
*/
public void changeMessageLandscape(int landscape) {
- RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams)
- mChatRecyclerView.getLayoutParams();
+ RelativeLayout.LayoutParams params1 = (RelativeLayout.LayoutParams) mChatRecyclerView.getLayoutParams();
RelativeLayout.LayoutParams enterRoomParams = (RelativeLayout.LayoutParams) enterRoomLeave.getLayoutParams();
if (landscape == 2) {
params1.height = DpUtil.dp2px(200);
@@ -5568,10 +5584,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
TextView userName = fans_enter_room_leave.findViewById(R.id.user_name);
ImageView bg = fans_enter_room_leave.findViewById(R.id.bg);
- userName.setText(Html.fromHtml(String.format("@%s %s",
- model.getUserNiceName(),
- mContext.getString(R.string.live_fans_group_enter_room)
- )));
+ userName.setText(Html.fromHtml(String.format("@%s %s", model.getUserNiceName(), mContext.getString(R.string.live_fans_group_enter_room))));
ImgLoader.display(mContext, model.getFansEnterRoomUrl(), bg);
fans_enter_room_leave.setVisibility(View.VISIBLE);
TranslateAnimation animationTranslate = new TranslateAnimation(DeviceUtils.getScreenWidth((Activity) mContext), 0, 0, 0);
@@ -5660,47 +5673,46 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
LiveAnchorSayModel sayModel;
public void initAnchorSayData() {
- LiveNetManager.get(mContext)
- .getLivePreviewInfo(mLiveUid, new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(LiveAnchorSayModel data) {
- Log.i("女神说", "onSuccess: " + data);
- sayModel = data;
- LiveAnchorSayModel.LivePreview preview = data.getLivePreview();
- if (preview != null) {
- mAnchorSayText.setText(getText(data.getLivePreview().getContent()));
- ImgLoader.display(mContext, preview.getStyleImage(), mAnchorSayImage);
- if (preview.getIsShow() == 1) {
- mAnchorSay.setVisibility(View.VISIBLE);
- } else {
- mAnchorSay.setVisibility(View.INVISIBLE);
- }
- } else {
- mAnchorSay.setVisibility(View.INVISIBLE);
- }
-
+ LiveNetManager.get(mContext).getLivePreviewInfo(mLiveUid, new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(LiveAnchorSayModel data) {
+ Log.i("女神说", "onSuccess: " + data);
+ sayModel = data;
+ LiveAnchorSayModel.LivePreview preview = data.getLivePreview();
+ if (preview != null) {
+ mAnchorSayText.setText(getText(data.getLivePreview().getContent()));
+ ImgLoader.display(mContext, preview.getStyleImage(), mAnchorSayImage);
+ if (preview.getIsShow() == 1) {
+ mAnchorSay.setVisibility(View.VISIBLE);
+ } else {
+ mAnchorSay.setVisibility(View.INVISIBLE);
}
+ } else {
+ mAnchorSay.setVisibility(View.INVISIBLE);
+ }
- @Override
- public void onError(String error) {
+ }
+ @Override
+ public void onError(String error) {
+
+ }
+
+ public String getText(String content) {
+ int t = 4;
+ float len = (float) content.length() / t;
+ StringBuilder sb = new StringBuilder();
+ sb.append("\n");
+ for (int i = 0; i < len; i++) {
+ if (len - i < 1) {
+ sb.append(content.substring(i * t));
+ } else {
+ sb.append(content.substring(i * t, i * t + t)).append("\n");
}
-
- public String getText(String content) {
- int t = 4;
- float len = (float) content.length() / t;
- StringBuilder sb = new StringBuilder();
- sb.append("\n");
- for (int i = 0; i < len; i++) {
- if (len - i < 1) {
- sb.append(content.substring(i * t));
- } else {
- sb.append(content.substring(i * t, i * t + t)).append("\n");
- }
- }
- return sb.toString();
- }
- });
+ }
+ return sb.toString();
+ }
+ });
}
public void initAnchorSay() {
@@ -5724,10 +5736,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public void showAnchorSayAndCallAnchor() {
isHinde = false;
- if (mAnchorSay.getVisibility() != View.VISIBLE &&
- sayModel != null && sayModel.getLivePreview() != null &&
- sayModel.getLivePreview().getIsShow() == 1
- ) {
+ if (mAnchorSay.getVisibility() != View.VISIBLE && sayModel != null && sayModel.getLivePreview() != null && sayModel.getLivePreview().getIsShow() == 1) {
Log.i("女神说", "sayModel: " + sayModel);
mAnchorSay.setVisibility(View.VISIBLE);
}
@@ -5760,12 +5769,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
}
BannerBean bannerBean = new BannerBean();
- bannerBean.setWishlistIcon(wishListProgress.getWishlistIcon())
- .setWishlistName(wishListProgress.getWishlistName())
- .setWishlistNum(wishListProgress.getWishlistNum())
- .setWishlistProgress(wishListProgress.getWishlistProgress())
- .setmLink(CommonAppConfig.HOST + "/index.php")
- .setType(1);
+ bannerBean.setWishlistIcon(wishListProgress.getWishlistIcon()).setWishlistName(wishListProgress.getWishlistName()).setWishlistNum(wishListProgress.getWishlistNum()).setWishlistProgress(wishListProgress.getWishlistProgress()).setmLink(CommonAppConfig.HOST + "/index.php").setType(1);
bannerBean.setShow_type("2");
if (mTopBannerList.size() == 1 || mTopBannerList.size() == 0) {
mTopBannerList.add(bannerBean);
@@ -5787,197 +5791,142 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
return;
}
topBanner1.setVisibility(View.GONE);
- topBanner1.setAutoPlay(true)
- .setPages(mTopBannerList, new TopBannerCustomViewHolder())
- .setDelayTime(3000)
- .setBannerStyle(BannerConfig.NOT_INDICATOR)
- .setOnBannerClickListener(new OnBannerClickListener() {
- @Override
- public void onBannerClick(List datas, int position) {
- if (datas.size() > 0 && mTopBannerList != null && mTopBannerList.size() > 0) {
- if (mTopBannerList.get(position).getType() == TopBannerCustomViewHolder.TYPE_CALL_ANCHOR) {
- MobclickAgent.onEvent(mContext, "live_room_contact", "联系方式按钮");
- Dialog loading = DialogUitl.loadingDialog(mContext);
- loading.show();
- LiveNetManager.get(mContext)
- .getContactInfo(mLiveUid, new com.yunbao.common.http.base.HttpCallback() {
+ topBanner1.setAutoPlay(true).setPages(mTopBannerList, new TopBannerCustomViewHolder()).setDelayTime(3000).setBannerStyle(BannerConfig.NOT_INDICATOR).setOnBannerClickListener(new OnBannerClickListener() {
+ @Override
+ public void onBannerClick(List datas, int position) {
+ if (datas.size() > 0 && mTopBannerList != null && mTopBannerList.size() > 0) {
+ if (mTopBannerList.get(position).getType() == TopBannerCustomViewHolder.TYPE_CALL_ANCHOR) {
+ MobclickAgent.onEvent(mContext, "live_room_contact", "联系方式按钮");
+ Dialog loading = DialogUitl.loadingDialog(mContext);
+ loading.show();
+ LiveNetManager.get(mContext).getContactInfo(mLiveUid, new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(LiveAnchorCallMeModel data) {
- if (data.getIsGet() == 1) {
- new LiveUserAnchorMailBoxWebInfoPopDialog(mContext, mAnchorName, data.getLink())
- .setOnDismissListener(dialog -> {
- checkNewLetter();
- loading.dismiss();
- })
- .showDialog();
- return;
- }
- new LiveContactDetailsSendGiftDialog(mContext)
- .setGiftId(data.getGiftId())
- .setAnchorName(mAnchorName)
- .setStream(mStream)
- .setLiveUid(mLiveUid)
- .setOnDismissListener(dialog1 -> {
- checkNewLetter();
- })
- .showDialog();
- loading.dismiss();
- }
-
- @Override
- public void onError(String error) {
- loading.dismiss();
- }
- });
-
- } else {
- MobclickAgent.onEvent(mContext, "live_room_wish", "心愿单按钮");
- BannerBean bean = mTopBannerList.get(position);
- IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
- String type = "";
- StringBuffer htmlUrl = new StringBuffer();
- htmlUrl.append(bean.getLink())
- .append(bean.getLink().contains("?") ? "&uid=" : "?uid=")
- .append(userInfo.getId())
- .append("&token=")
- .append(userInfo.getToken())
- .append("&anchorUid=")
- .append(mLiveUid)
- .append("&liveUid=")
- .append(mLiveUid)
- .append("&t=")
- .append(System.currentTimeMillis())
- .append("&g=Appapi&m=Wish&a=index")
- .append("&isZh=")
- .append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
- if (TextUtils.equals(type, "1")) {
- ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false, 1);
- } else {
- Bundle bundle = new Bundle();
- bundle.putString("url", htmlUrl.toString());
- LiveHDDialogFragment fragment = new LiveHDDialogFragment();
- fragment.setArguments(bundle);
- fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
+ @Override
+ public void onSuccess(LiveAnchorCallMeModel data) {
+ if (data.getIsGet() == 1) {
+ new LiveUserAnchorMailBoxWebInfoPopDialog(mContext, mAnchorName, data.getLink()).setOnDismissListener(dialog -> {
+ checkNewLetter();
+ loading.dismiss();
+ }).showDialog();
+ return;
}
+ new LiveContactDetailsSendGiftDialog(mContext).setGiftId(data.getGiftId()).setAnchorName(mAnchorName).setStream(mStream).setLiveUid(mLiveUid).setOnDismissListener(dialog1 -> {
+ checkNewLetter();
+ }).showDialog();
+ loading.dismiss();
}
+
+ @Override
+ public void onError(String error) {
+ loading.dismiss();
+ }
+ });
+
+ } else {
+ MobclickAgent.onEvent(mContext, "live_room_wish", "心愿单按钮");
+ BannerBean bean = mTopBannerList.get(position);
+ IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
+ String type = "";
+ StringBuffer htmlUrl = new StringBuffer();
+ htmlUrl.append(bean.getLink()).append(bean.getLink().contains("?") ? "&uid=" : "?uid=").append(userInfo.getId()).append("&token=").append(userInfo.getToken()).append("&anchorUid=").append(mLiveUid).append("&liveUid=").append(mLiveUid).append("&t=").append(System.currentTimeMillis()).append("&g=Appapi&m=Wish&a=index").append("&isZh=").append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
+ if (TextUtils.equals(type, "1")) {
+ ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false, 1);
+ } else {
+ Bundle bundle = new Bundle();
+ bundle.putString("url", htmlUrl.toString());
+ LiveHDDialogFragment fragment = new LiveHDDialogFragment();
+ fragment.setArguments(bundle);
+ fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}
-
}
- })
- .start();
- topBanner2.setAutoPlay(true)
- .setPages(mTopBannerList, new TopBannerCustomViewHolder(false))
- .setDelayTime(3000)
- .setBannerStyle(BannerConfig.NOT_INDICATOR)
- .setOnBannerClickListener(new OnBannerClickListener() {
- @Override
- public void onBannerClick(List datas, int position) {
- if (datas.size() > 0) {
- if (position >= mTopBannerList.size()) {
- position = 0;
- }
- if (mTopBannerList.get(position).getType() == TopBannerCustomViewHolder.TYPE_CALL_ANCHOR) {
- MobclickAgent.onEvent(mContext, "live_room_contact", "联系方式按钮");
- Dialog loading = DialogUitl.loadingDialog(mContext);
- loading.show();
- LiveNetManager.get(mContext)
- .getContactInfo(mLiveUid, new com.yunbao.common.http.base.HttpCallback() {
+ }
- @Override
- public void onSuccess(LiveAnchorCallMeModel data) {
- if (data.getIsGet() == 1) {
- new LiveUserAnchorMailBoxWebInfoPopDialog(mContext, mAnchorName, data.getLink())
- .setOnDismissListener(dialog -> {
- checkNewLetter();
- loading.dismiss();
- })
- .showDialog();
- return;
- }
- new LiveContactDetailsSendGiftDialog(mContext)
- .setGiftId(data.getGiftId())
- .setAnchorName(mAnchorName)
- .setStream(mStream)
- .setLiveUid(mLiveUid)
- .setOnDismissListener(dialog1 -> {
- checkNewLetter();
- })
- .showDialog();
- loading.dismiss();
- }
+ }
+ }).start();
+ topBanner2.setAutoPlay(true).setPages(mTopBannerList, new TopBannerCustomViewHolder(false)).setDelayTime(3000).setBannerStyle(BannerConfig.NOT_INDICATOR).setOnBannerClickListener(new OnBannerClickListener() {
+ @Override
+ public void onBannerClick(List datas, int position) {
+ if (datas.size() > 0) {
+ if (position >= mTopBannerList.size()) {
+ position = 0;
+ }
+ if (mTopBannerList.get(position).getType() == TopBannerCustomViewHolder.TYPE_CALL_ANCHOR) {
+ MobclickAgent.onEvent(mContext, "live_room_contact", "联系方式按钮");
+ Dialog loading = DialogUitl.loadingDialog(mContext);
+ loading.show();
+ LiveNetManager.get(mContext).getContactInfo(mLiveUid, new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onError(String error) {
- loading.dismiss();
- }
- });
-
- } else {
- MobclickAgent.onEvent(mContext, "live_room_wish", "心愿单按钮");
- BannerBean bean = mTopBannerList.get(position);
- IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
- String type = "";
- StringBuffer htmlUrl = new StringBuffer();
- htmlUrl.append(bean.getLink())
- .append(bean.getLink().contains("?") ? "&uid=" : "?uid=")
- .append(userInfo.getId())
- .append("&token=")
- .append(userInfo.getToken())
- .append("&anchorUid=")
- .append(mLiveUid)
- .append("&liveUid=")
- .append(mLiveUid)
- .append("&t=")
- .append(System.currentTimeMillis())
- .append("&g=Appapi&m=Wish&a=index")
- .append("&isZh=")
- .append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
- if (TextUtils.equals(type, "1")) {
- ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false, 1);
- } else {
- Bundle bundle = new Bundle();
- bundle.putString("url", htmlUrl.toString());
- LiveHDDialogFragment fragment = new LiveHDDialogFragment();
- fragment.setArguments(bundle);
- fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
+ @Override
+ public void onSuccess(LiveAnchorCallMeModel data) {
+ if (data.getIsGet() == 1) {
+ new LiveUserAnchorMailBoxWebInfoPopDialog(mContext, mAnchorName, data.getLink()).setOnDismissListener(dialog -> {
+ checkNewLetter();
+ loading.dismiss();
+ }).showDialog();
+ return;
}
+ new LiveContactDetailsSendGiftDialog(mContext).setGiftId(data.getGiftId()).setAnchorName(mAnchorName).setStream(mStream).setLiveUid(mLiveUid).setOnDismissListener(dialog1 -> {
+ checkNewLetter();
+ }).showDialog();
+ loading.dismiss();
}
- }
+ @Override
+ public void onError(String error) {
+ loading.dismiss();
+ }
+ });
+
+ } else {
+ MobclickAgent.onEvent(mContext, "live_room_wish", "心愿单按钮");
+ BannerBean bean = mTopBannerList.get(position);
+ IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
+ String type = "";
+ StringBuffer htmlUrl = new StringBuffer();
+ htmlUrl.append(bean.getLink()).append(bean.getLink().contains("?") ? "&uid=" : "?uid=").append(userInfo.getId()).append("&token=").append(userInfo.getToken()).append("&anchorUid=").append(mLiveUid).append("&liveUid=").append(mLiveUid).append("&t=").append(System.currentTimeMillis()).append("&g=Appapi&m=Wish&a=index").append("&isZh=").append(((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
+ if (TextUtils.equals(type, "1")) {
+ ZhuangBanActivity.forward(mContext, htmlUrl.toString(), false, 1);
+ } else {
+ Bundle bundle = new Bundle();
+ bundle.putString("url", htmlUrl.toString());
+ LiveHDDialogFragment fragment = new LiveHDDialogFragment();
+ fragment.setArguments(bundle);
+ fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
+ }
}
- })
- .start();
+ }
+
+ }
+ }).start();
updateCallMe();
}
private void updateCallMe() {
- LiveNetManager.get(mContext)
- .getContactInfo(mLiveUid, new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(LiveAnchorCallMeModel data) {
- System.out.println(">>>>> 获取联系方式:" + data);
- if (data.getIsShow() == 1) {
- if (!isHinde) {
- topBanner1.setVisibility(View.VISIBLE);
- }
- BannerBean call = new BannerBean();
- call.setData(data);
- call.setType(TopBannerCustomViewHolder.TYPE_CALL_ANCHOR);
- mTopBannerList.add(0, call);
- topBanner1.update(mTopBannerList);
- topBanner2.update(mTopBannerList);
- }
-
-
+ LiveNetManager.get(mContext).getContactInfo(mLiveUid, new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(LiveAnchorCallMeModel data) {
+ System.out.println(">>>>> 获取联系方式:" + data);
+ if (data.getIsShow() == 1) {
+ if (!isHinde) {
+ topBanner1.setVisibility(View.VISIBLE);
}
+ BannerBean call = new BannerBean();
+ call.setData(data);
+ call.setType(TopBannerCustomViewHolder.TYPE_CALL_ANCHOR);
+ mTopBannerList.add(0, call);
+ topBanner1.update(mTopBannerList);
+ topBanner2.update(mTopBannerList);
+ }
- @Override
- public void onError(String error) {
- System.out.println("!>>>>> 获取联系方式:" + error);
- }
- });
+
+ }
+
+ @Override
+ public void onError(String error) {
+ System.out.println("!>>>>> 获取联系方式:" + error);
+ }
+ });
}
@@ -6021,19 +5970,18 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
public void updateFansMessageRed() {
if (mContext instanceof LiveAudienceActivity) {
- LiveNetManager.get(mContext)
- .getCheckFansLevelUpgrade(mLiveUid, new com.yunbao.common.http.base.HttpCallback() {
- @Override
- public void onSuccess(FansCheckRed data) {
- ((LiveAudienceActivity) mContext).setShowCrownRed(data.getStatus() == 1);
+ LiveNetManager.get(mContext).getCheckFansLevelUpgrade(mLiveUid, new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(FansCheckRed data) {
+ ((LiveAudienceActivity) mContext).setShowCrownRed(data.getStatus() == 1);
- }
+ }
- @Override
- public void onError(String error) {
+ @Override
+ public void onError(String error) {
- }
- });
+ }
+ });
}
}
}
diff --git a/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java
index d2be9d442..bf024bd45 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveRyAnchorViewHolder.java
@@ -1,8 +1,9 @@
package com.yunbao.live.views;
+import static com.yunbao.live.activity.LiveActivity.isSw;
import static com.yunbao.live.activity.LiveActivity.mLiveUid;
-import static com.yunbao.live.activity.LiveRyAnchorActivity.PKing;
-import static com.yunbao.live.activity.LiveRyAnchorActivity.pk_nub;
+import static com.yunbao.live.activity.LiveSwAnchorActivity.PKing;
+import static com.yunbao.live.activity.LiveSwAnchorActivity.pk_nub;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.START_MESSAGE;
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.WISH_LIST_UPDATE;
@@ -24,6 +25,7 @@ import androidx.core.content.ContextCompat;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils;
+import com.google.gson.Gson;
import com.ms.banner.Banner;
import com.ms.banner.BannerConfig;
import com.ms.banner.listener.OnBannerClickListener;
@@ -39,11 +41,13 @@ import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus;
+import com.yunbao.common.utils.L;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.activity.ZhuangBanActivity;
import com.yunbao.live.bean.WishlistModel;
import com.yunbao.live.dialog.LiveHDDialogFragment;
@@ -85,6 +89,25 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
private TextView mLiveTimeTextView;//主播的直播时长
private long mAnchorLiveTime;//主播直播时间
private LiveRoomHandler mLiveRoomHandler;
+ private static LinearLayout btn_end_pk_dr;
+ private String drpkRoomId; //多人 PK 房主 roomUid
+ public void setDrpkRoomId(String drpkRoomId) {
+ this.drpkRoomId = drpkRoomId;
+ }
+
+ public void showEndPkBt(){
+ if(btn_end_pk_dr!=null){
+ if(btn_start_dr_pk_view.getVisibility()==View.GONE){
+ btn_end_pk_dr.setVisibility(View.VISIBLE);
+ }
+ }
+ }
+
+ public void closeEndPkBt(){
+ if(btn_end_pk_dr!=null){
+ btn_end_pk_dr.setVisibility(View.GONE);
+ }
+ }
public LiveRyAnchorViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
@@ -106,6 +129,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
Bus.getOn(this);
mDrawable0 = ContextCompat.getDrawable(mContext, R.mipmap.icon_live_func_0);
mDrawable1 = ContextCompat.getDrawable(mContext, R.mipmap.icon_live_func_1);
+ btn_end_pk_dr = (LinearLayout) findViewById(R.id.btn_end_pk_dr);
mBtnFunction = (ImageView) findViewById(R.id.btn_function);
btn_dr = (TextView) findViewById(R.id.btn_dr);
mBanner = (Banner) findViewById(R.id.banner);
@@ -128,22 +152,25 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
btn_start_dr_pk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- if (pk_nub <= 0) return;
- //開始多人PK
- HttpClient.getInstance().post("live.startDRPK", "live.startDRPK")
- .params("roomid", CommonAppConfig.getInstance().getUid())
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- if (code == 0) {
- PKing = true;
- pk_nub = pk_nub - 1;
- btn_dr_pk_nub.setText("剩餘次數:" + pk_nub);
- } else {
- ToastUtil.show(msg);
+ if(pk_nub<= 0){
+ ToastUtil.show("多人PK次数已用完");
+ }else{
+ //開始多人PK
+ HttpClient.getInstance().get("live.startDRPK", "live.startDRPK")
+ .params("roomid", CommonAppConfig.getInstance().getUid())
+ .execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0) {
+ PKing = true;
+ pk_nub = pk_nub - 1;
+ btn_dr_pk_nub.setText("剩餘次數:" + pk_nub);
+ } else {
+ ToastUtil.show(msg);
+ }
}
- }
- });
+ });
+ }
}
});
@@ -166,6 +193,22 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
yaoqing.clear();
}
});
+ btn_end_pk_dr.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ closeEndPkBt();
+ HttpClient.getInstance().post("live.leaveDRPKroom", "live.leaveDRPKroom")
+ .params("roomid", drpkRoomId)
+ .params("uid", CommonAppConfig.getInstance().getUid())
+ .execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ L.eSw("live.leaveDRPKroom:code:" + code + " info" + new Gson().toJson(info));
+
+ }
+ });
+ }
+ });
btn_dr.setOnClickListener(new View.OnClickListener() {
@Override
@@ -173,7 +216,11 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
if (yaoqing.size() < 3) {
if (PKing == false) {
- ((LiveRyAnchorActivity) mContext).openLinkMicAnchorWindow(true);
+ if(isSw){
+ ((LiveSwAnchorActivity) mContext).openLinkMicAnchorWindow(true);
+ }else{
+ ((LiveRyAnchorActivity) mContext).openLinkMicAnchorWindow(true);
+ }
} else {
ToastUtil.show(WordUtil.isNewZh() ? "您已在PK中" : "You are already in the PK");
}
@@ -195,6 +242,10 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
yaoqing.put(numinda, numinda);
}
+ public void removeYaoqing(String numinda){
+ yaoqing.remove(numinda);
+ }
+
@Override
public void onClick(View v) {
if (!canClick()) {
@@ -241,7 +292,11 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
* 关闭直播
*/
private void close() {
- ((LiveRyAnchorActivity) mContext).closeLive();
+ if(isSw){
+ ((LiveSwAnchorActivity) mContext).closeLive();
+ }else{
+ ((LiveRyAnchorActivity) mContext).closeLive();
+ }
}
@Override
@@ -257,7 +312,11 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
if (mBtnFunction != null) {
mBtnFunction.setImageDrawable(mDrawable1);
}
- ((LiveRyAnchorActivity) mContext).showFunctionDialog();
+ if(isSw){
+ ((LiveSwAnchorActivity) mContext).showFunctionDialog();
+ }else{
+ ((LiveRyAnchorActivity) mContext).showFunctionDialog();
+ }
}
/**
@@ -290,7 +349,11 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
* 发起主播连麦pk
*/
private void applyLinkMicPk() {
- ((LiveRyAnchorActivity) mContext).applyLinkMicPk();
+ if(isSw){
+ ((LiveSwAnchorActivity) mContext).applyLinkMicPk();
+ }else{
+ ((LiveRyAnchorActivity) mContext).applyLinkMicPk();
+ }
}
public void setLinkMicEnable(boolean linkMicEnable) {
@@ -516,7 +579,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
bundle.putString("url", htmlUrl.toString());
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
fragment.setArguments(bundle);
- fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
+ fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}
}
}
@@ -577,7 +640,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
bundle.putString("url", htmlUrl.toString());
LiveHDDialogFragment fragment = new LiveHDDialogFragment();
fragment.setArguments(bundle);
- fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
+ fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
}
}
}
diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
index 8edf8597d..58c55fb47 100644
--- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
+++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
@@ -15,6 +15,7 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -27,6 +28,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils;
import com.lzf.easyfloat.EasyFloat;
+import com.lzf.easyfloat.enums.ShowPattern;
import com.lzf.easyfloat.permission.PermissionUtils;
import com.lzf.easyfloat.utils.LifecycleUtils;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
@@ -39,6 +41,7 @@ import com.yunbao.common.bean.BannerBean;
import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.EnterRoomNewModel;
import com.yunbao.common.bean.LiveBean;
+import com.yunbao.common.bean.LivePkMicModel;
import com.yunbao.common.bean.LiveRoomActivityModel;
import com.yunbao.common.bean.LiveUserGiftBean;
import com.yunbao.common.bean.MsgModel;
@@ -74,6 +77,7 @@ import com.yunbao.common.manager.OpenAdManager;
import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.DialogUitl;
+import com.yunbao.common.utils.L;
import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.RandomUtil;
import com.yunbao.common.utils.RouteUtil;
@@ -81,10 +85,10 @@ import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.utils.formatBigNum;
-import com.yunbao.common.views.weight.LiveFloatView;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
+import com.yunbao.live.bean.DrPkbean;
import com.yunbao.live.bean.LiveBuyGuardMsgBean;
import com.yunbao.live.bean.LiveChatBean;
import com.yunbao.live.bean.LiveDanMuBean;
@@ -100,15 +104,20 @@ import com.yunbao.live.dialog.BlowkissDialog;
import com.yunbao.live.dialog.NewUserDialog;
import com.yunbao.live.event.LinkMicTxAccEvent;
import com.yunbao.live.event.LiveAudienceEvent;
+import com.yunbao.live.event.LiveOpenSuccessEvent;
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
import com.yunbao.live.presenter.LiveLinkMicPresenter;
import com.yunbao.live.presenter.LiveRyLinkMicPkPresenter;
+import com.yunbao.live.presenter.LiveSwLinkMicPkPresenter;
import com.yunbao.live.socket.SocketClient;
import com.yunbao.live.socket.SocketMessageListener;
import com.yunbao.live.socket.SocketRyChatUtil;
import com.yunbao.live.socket.SocketRyClient;
+import com.yunbao.live.socket.SocketSwChatUtil;
+import com.yunbao.live.socket.SocketSwClient;
import com.yunbao.live.socket.SocketSendBean;
import com.yunbao.live.utils.LiveImDeletUtil;
+import com.yunbao.live.utils.LiveTextRender;
import org.greenrobot.eventbus.EventBus;
@@ -119,6 +128,8 @@ import cn.rongcloud.rtc.api.RCRTCEngine;
import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.api.callback.IRCRTCSwitchRoleCallback;
import cn.rongcloud.rtc.base.RTCErrorCode;
+import io.agora.beautyapi.faceunity.agora.LiveFloatView;
+import io.agora.beautyapi.faceunity.agora.SWAuManager;
import io.rong.imlib.IRongCallback;
import io.rong.imlib.IRongCoreCallback;
import io.rong.imlib.IRongCoreEnum;
@@ -151,7 +162,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//侧滑布局
// private DrawerLayout drawerLayout;
//直播间拆分布局
- private LivePlayRyViewHolder mLivePlayViewHolder;
+ public LiveRoomPlayViewHolder mLivePlayViewHolder;
+
//头部布局
public LiveRoomViewHolder mLiveRoomViewHolder;
//底部布局
@@ -165,14 +177,20 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//主播与主播连麦逻辑
private LiveLinkMicAnchorPresenter mLiveLinkMicAnchorPresenter;
//主播与主播PK逻辑
+ private LiveSwLinkMicPkPresenter mLiveSwLinkMicPkPresenter;
+
private LiveRyLinkMicPkPresenter mLiveRyLinkMicPkPresenter;
+
+
//直播间的类型 普通 密码 门票 计时等
private int mLiveType;
//收费价格,计时收费每次扣费的值
private int mLiveTypeVal;
//直播结束页面
private LiveEndViewHolder mLiveEndViewHolder;
+ private SocketSwClient mSocketSwClient;
private SocketRyClient mSocketRyClient;
+
private SocketClient mSocketClient;
private String mDanmuPrice;//弹幕价格
private int mSocketUserType;//socket用户类型 30 普通用户 40 管理员 50 主播 60超管
@@ -211,6 +229,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
public static PortraitLiveManager portraitLiveManager;
private static int waitShowTopBannerTime = 6000;
+ private boolean isSw;
+
public PortraitLiveManager setQuitF(boolean quitF) {
isQuitF = quitF;
return this;
@@ -261,13 +281,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
public PortraitLiveManager(Activity context, Intent intent) {
this.mContext = context;
this.mIntent = intent;
+ isSw = intent.getBooleanExtra(Constants.LIVE_SDK_IS_SW, false);
liveImDeletUtil = new LiveImDeletUtil();
portraitLiveManager = this;
ininView();
AppManager.runDebugCode(() -> waitShowTopBannerTime = 1000);
}
-
/**
* 初始化布局
*/
@@ -316,6 +336,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
loading.setVisibility(View.GONE);
enterRoomLeaveHandler.post(enterRoomLeaveRunnable);
OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE, LiveGuardInfo.isGuard(mLiveGuardInfo));
+
}
};
final Runnable loadTimeoutRunnableGone = new Runnable() {
@@ -323,13 +344,14 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
public void run() {
loading.setVisibility(View.GONE);
enterRoomLeaveHandler.post(enterRoomLeaveRunnable);
- ToastUtil.show(mContext.getString(R.string.net_error) + " :500");//异常下播,等待加载时间过了后弹出
+ //ToastUtil.show(mContext.getString(R.string.net_error) + " :500");//异常下播,等待加载时间过了后弹出
+ OpenAdManager.getInstance().show(OpenAdManager.TYPE_LIVE, LiveGuardInfo.isGuard(mLiveGuardInfo));
}
};
-
@Override
- public synchronized void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) {
+ public synchronized void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk, boolean isSw) {
+ Log.e("直播间接口调用排查", "onAdd onAdd onAdd onAdd");
isEnterRoom = false;
MobclickAgent.onEvent(mContext, "live_room_chat_list", "滑动直播间聊天列表");
openParametersModel = new OpenParametersModel();
@@ -347,6 +369,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRyLinkMicPkPresenter.release();
mLiveRyLinkMicPkPresenter = null;
}
+
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.clearData();
+ mLiveSwLinkMicPkPresenter.release();
+ mLiveSwLinkMicPkPresenter = null;
+ }
OpenAdManager.getInstance().dismiss();
mLiveBean = data;
mLiveSDK = liveSdk;
@@ -365,12 +393,22 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
liveHandler.removeCallbacks(loadRunnableGone);
liveHandler.removeCallbacks(loadTimeoutRunnableGone);
if (mLivePlayViewHolder == null) {
- mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, 1);
- mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager());
+ if (isSw) {
+ mLivePlayViewHolder = new LivePlaySwViewHolder(mContext, playContainer, mLiveBean.getLandscape());
+ } else {
+ mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, 1);
+ }
+
+ mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager(), isSw);
mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer);
mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView());
mLiveLinkMicAnchorPresenter = new LiveLinkMicAnchorPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, null);
- mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
+ if (isSw) {
+ mLiveSwLinkMicPkPresenter = new LiveSwLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
+ } else {
+ mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
+ }
+ mLivePlayViewHolder.initSwEngine(mLiveBean.getUid());
mLivePlayViewHolder.addToParent();
mLivePlayViewHolder.subscribeActivityLifeCycle();
mLivePlayViewHolder.setLoadViewListener(new LiveRoomPlayViewHolder.LoadingListener() {
@@ -385,21 +423,28 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.addToParent();
mLiveAudienceViewHolder.subscribeActivityLifeCycle();
} else {
- mLivePlayViewHolder.setLiveBeanLandscape(1);
+ mLivePlayViewHolder.initSwEngine(liveID);
+ mLivePlayViewHolder.setLiveBeanLandscape(mLiveBean.getLandscape());
mLiveLinkMicPresenter.setLiveSdk(mLiveSDK);
mLiveLinkMicAnchorPresenter.setLiveSdk(mLiveSDK);
}
+ if (isSw) {
+ if (mLiveSwLinkMicPkPresenter == null) {
+ mLiveSwLinkMicPkPresenter = new LiveSwLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
+ }
+ } else {
+ if (mLiveRyLinkMicPkPresenter == null) {
+ mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
+ }
+ }
- if (mLiveRyLinkMicPkPresenter == null) {
- mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null);
- }
//去除主播离开画面
- if (LivePlayKsyViewHolder.leave != null) {
- LivePlayKsyViewHolder.leave.setVisibility(View.GONE);
- }
if (LivePlayRyViewHolder.leave != null) {
LivePlayRyViewHolder.leave.setVisibility(View.GONE);
}
+ if (LivePlaySwViewHolder.leave != null) {
+ LivePlaySwViewHolder.leave.setVisibility(View.GONE);
+ }
//直播间背景
ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600);
@@ -433,13 +478,22 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.clearGuardIcon();
mLiveRoomViewHolder.clearChat();
mLiveRoomViewHolder.releaseGift();
- mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), "");
- mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this, mContext);
+ if (isSw) {
+ mLiveSwLinkMicPkPresenter.setLiveUid(data.getUid(), "");
+ } else {
+ mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), "");
+ }
+
+ if (isSw) {
+ mSocketSwClient = new SocketSwClient(mLiveBean.getUid(), PortraitLiveManager.this, mContext);
+ } else {
+ mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this, mContext);
+ }
if (mLiveLinkMicPresenter != null) {
mLiveLinkMicPresenter.setSocketClient(mSocketClient);
}
enterRoomNew();
-
+ Bus.get().post(new LiveOpenSuccessEvent());
} catch (Exception e) {
e.printStackTrace();
}
@@ -611,8 +665,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
if (leave == 1) {
- if (LivePlayRyViewHolder.leave != null) {
- LivePlayRyViewHolder.leave.setVisibility(View.VISIBLE);
+ if (LivePlaySwViewHolder.leave != null) {
+ LivePlaySwViewHolder.leave.setVisibility(View.VISIBLE);
}
}
//判断是否有连麦,要显示连麦窗口
@@ -639,18 +693,40 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
}
-
if (mLivePlayViewHolder != null && data.getEnterRoomInfo().getIsconnection() != null && data.getEnterRoomInfo().getIsconnection().equals("1")) {
-
- mLivePlayViewHolder.setViewUP(1);
-
+ JSONArray array = pkInfo.getJSONArray("userlist");
+ //判断是否是多人连麦
+ if (array.size() > 0) {//多人連麥
+ if (mLivePlayViewHolder != null) {
+ List drPkbeans = new ArrayList<>();
+ for (int j = 0; j < array.size(); j++) {
+ UserBean drPkbean = new UserBean();
+ DrPkbean drPkbean1 = new DrPkbean();
+ JSONObject da = array.getJSONObject(j);
+ if (!String.valueOf(da.getIntValue("id")).equals(String.valueOf(data.getLiveInfo().getUid()))) {
+ drPkbean.setId(String.valueOf(da.getIntValue("id")));
+ drPkbean1.setId(da.getIntValue("id"));
+ drPkbean1.setUser_nicename(da.getString("user_nicename"));
+ drPkbeans.add(drPkbean1);
+ mLivePlayViewHolder.setDrMicInfo(drPkbean);
+ }
+ }
+ //mLivePlayViewHolder.setDrPkView(drPkbeans);
+ }
+ } else {//单人连麦
+ LivePkMicModel connection_info = data.getEnterRoomInfo().getConnectionInfo();
+ if (!StringUtil.isEmpty(connection_info.getPkuid())) {
+ mPkUid = connection_info.getPkuid();
+ mLivePlayViewHolder.setPkView(connection_info.getPkuid());
+ }
+ }
}
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.pkHandler = false;
}
if (mLivePlayViewHolder != null && pkInfo.getIntValue("ifpk") == 1 && pkInfo.getString("end_pk_time").equals("0")) {//pk开始了
- mLivePlayViewHolder.setViewUP(2);
+ mLivePlayViewHolder.setPkView(data.getEnterRoomInfo().getPkinfo().getPkuid());
//pk排名数据
LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class);
@@ -662,13 +738,15 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (mLiveRoomViewHolder != null && pkInfo != null && pkInfo.containsKey("pkuid") && pkInfo.containsKey("pkuimg") && pkInfo.containsKey("pkuname")) {
mLiveRoomViewHolder.setOtherInfo(pkInfo.getString("pkuid"), pkInfo.getString("pkuimg"), pkInfo.getString("pkuname"));
}
-
}
};
linkMicPkStartHandler.postDelayed(linkMicPkStartRunnable, 4000);
-
}
- mLiveRyLinkMicPkPresenter.onEnterRoomPkStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("pk_time"), livePKUserListBean);
+ if (isSw) {
+ mLiveSwLinkMicPkPresenter.onEnterRoomPkStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("pk_time"), livePKUserListBean);
+ } else {
+ mLiveRyLinkMicPkPresenter.onEnterRoomPkStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("pk_time"), livePKUserListBean);
+ }
} else if (!pkInfo.getString("end_pk_time").equals("0")) {
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.pkHandler = true;
@@ -676,12 +754,17 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.initPkRank(null);
}
if (mLivePlayViewHolder != null) {
- mLivePlayViewHolder.setViewUP(3);
+ //mLivePlayViewHolder.setViewUP(3);
+ mLivePlayViewHolder.setPkView(data.getEnterRoomInfo().getPkinfo().getPkuid());
}
//pk排名数据
LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class);
- mLiveRyLinkMicPkPresenter.onEnterRoomCFStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("end_pk_time"), livePKUserListBean);
+ if (isSw) {
+ mLiveSwLinkMicPkPresenter.onEnterRoomCFStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("end_pk_time"), livePKUserListBean);
+ } else {
+ mLiveRyLinkMicPkPresenter.onEnterRoomCFStart(pkUid, pkInfo.getLongValue("pk_gift_liveuid"), pkInfo.getLongValue("pk_gift_pkuid"), pkInfo.getIntValue("end_pk_time"), livePKUserListBean);
+ }
} else {
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.initPkRank(null);
@@ -698,7 +781,21 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
if (mLivePlayViewHolder != null) {
- mLivePlayViewHolder.setViewUP(4);
+ JSONArray array = pkInfo.getJSONArray("userlist");
+ List drPkbeans = new ArrayList<>();
+ for (int j = 0; j < array.size(); j++) {
+ UserBean userBean = new UserBean();
+ DrPkbean drPkbean = new DrPkbean();
+ JSONObject da = array.getJSONObject(j);
+ if (!String.valueOf(da.getIntValue("id")).equals(String.valueOf(data.getLiveInfo().getUid()))) {
+ userBean.setId(String.valueOf(da.getIntValue("id")));
+ drPkbean.setId(da.getIntValue("id"));
+ drPkbean.setUser_nicename(da.getString("user_nicename"));
+ drPkbeans.add(drPkbean);
+ mLivePlayViewHolder.setDrMicInfo(userBean);
+ }
+ }
+ //mLivePlayViewHolder.setDrPkView(drPkbeans);
}
upDataPkScore(pkInfo.getJSONArray("userlist"), pkInfo.getIntValue("drpk_time"));
@@ -755,8 +852,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.showPrizePoolLevel(String.valueOf(giftPrizePoolLevel));
}
}
+ //liveHandler.postDelayed(loadTimeoutRunnableGone, 15_000);
AppManager.runDebugCode(() -> {
- // liveHandler.postDelayed(loadTimeoutRunnableGone, 1_000);
+ liveHandler.postDelayed(loadTimeoutRunnableGone, 1_000);
});
liveHandler.postDelayed(loadTimeoutRunnableGone, 4_000);
if (TextUtils.equals(data.getEnterRoomInfo().getIsconnection(), "1")) {
@@ -801,6 +899,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
+ public void loadTimeoutRunnableGone() {
+ if (liveHandler != null) {
+ liveHandler.postDelayed(loadTimeoutRunnableGone, 1_000);
+ }
+ }
public void removeLiveEnd() {
if (mLiveEndViewHolder != null) {
@@ -828,11 +931,17 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRyLinkMicPkPresenter.clearData();
mLiveRyLinkMicPkPresenter.release();
}
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.clearData();
+ mLiveSwLinkMicPkPresenter.release();
+ }
+
mLiveAudienceViewHolder = null;
mLiveRoomViewHolder = null;
mLiveLinkMicPresenter = null;
mLiveLinkMicAnchorPresenter = null;
mLiveRyLinkMicPkPresenter = null;
+ mLiveSwLinkMicPkPresenter = null;
mLivePlayViewHolder = null;
}
@@ -854,11 +963,19 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (mLiveAudienceViewHolder != null) {
mLiveAudienceViewHolder.removeCallbacks();
}
+ if (mLivePlayViewHolder != null) {
+ mLivePlayViewHolder.stopPlay2();
+ mLiveRoomViewHolder.cancelAllAnim();
+ }
//断开socket
if (mSocketRyClient != null) {
mSocketRyClient.disConnect();
mSocketRyClient = null;
}
+ if (mSocketSwClient != null) {
+ mSocketSwClient.disConnect();
+ mSocketSwClient = null;
+ }
if (mSocketClient != null) {
mSocketClient.disConnect();
mSocketClient = null;
@@ -876,6 +993,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRyLinkMicPkPresenter.release();
mLiveRyLinkMicPkPresenter = null;
}
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.clearData();
+ mLiveSwLinkMicPkPresenter.release();
+ mLiveSwLinkMicPkPresenter = null;
+ }
+
if (mLiveEndViewHolder != null) {
removeLiveEnd();
}
@@ -898,7 +1021,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.removeFromParent();
mLiveRoomViewHolder.countDownTimerTrickery = null;
}
-
mLiveAudienceViewHolder = null;
mLivePlayViewHolder = null;
mLiveRoomViewHolder = null;
@@ -907,7 +1029,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRyLinkMicPkPresenter = null;
if (PermissionUtils.checkPermission(mContext) && !kick) {
LiveFloatView.getInstance()
- .cacheLiveData(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal)
+ .cacheLiveData(mLiveBean, mLiveType, isSw, mLiveTypeVal)
.builderSystemFloat(mContext, mLiveBean.getPull());
mContext.finish();
} else {
@@ -915,7 +1037,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
EventBus.getDefault()
.post(new LiveFloatEvent()
.setmLiveBean(mLiveBean)
- .setmLiveSDK(mLiveSDK)
+ .setmLiveSDK(isSw ? 2 : mLiveSDK)
.setmLiveType(mLiveType)
.setmLiveTypeVal(mLiveTypeVal));
}
@@ -954,7 +1076,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
boolean floatPermission = PermissionUtils.checkPermission(mContext);
if (mLiveBean != null && !isQuitF && !isForeground && floatPermission) {
LiveFloatView.getInstance()
- .cacheLiveData(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal)
+ .cacheLiveData(mLiveBean, mLiveType, isSw, mLiveTypeVal)
.builderSystemFloat(mContext, mLiveBean.getPull());
mContext.finish();
}
@@ -1051,37 +1173,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
* 正处于连麦中
*/
public void micIngTypeTwo(LiveBean bean, int liveType, int liveTypeVal) {
- String content="連麥中,退出將斷開語音連麥!";
- if(!WordUtil.isNewZh()){
- content="Connect, exit will disconnect voice connect!";
- }
- DialogUitl.showSimpleDialog(mContext, null, content, false, new DialogUitl.SimpleCallback3() {
+ DialogUitl.showSimpleDialog(mContext, null, "連麥中,退出將斷開語音連麥!", false, new DialogUitl.SimpleCallback3() {
@Override
public void onConfirmClick(Dialog dialog) {
- if (RCRTCEngine.getInstance().getRoom() == null || RCRTCEngine.getInstance().getRoom().getLocalUser() == null) {
- return;
- }
- String _tmp="下麥中,稍等.....";
- if(!WordUtil.isNewZh()){
- _tmp="Disconnecting the live connection, please wait a moment.....";
- }
- ToastUtil.show(_tmp);
- RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() {
-
- /**
- * 当切换失败且SDK处于无法回退状态时回调,该角色已经无法使用当前角色继续进行音视频。
- * SDK内部会退出房间并清理所有资源,该用户只能重新加入房间才能继续音视频。
- */
- @Override
- public void onKicked() {
-
- }
-
- @Override
- public void onSuccess() {
- Log.e("ry", "下麦成功");
- // 该用户切换为观众成功,可以以观众身份进行音视频
- //退出多人房间
+ if (isSw) {
+ if (mLivePlayViewHolder != null) {
+ mLivePlayViewHolder.endLiveMic();
HttpClient.getInstance().get("live.leaveDrLm", "live.leaveDrLm")
.params("roomid", liveID)
.execute(new HttpCallback() {
@@ -1091,39 +1188,77 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
});
- //退出rtc播放
- RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
- @Override
- public void onSuccess() {
- Log.e("ry", "退出多人房间成功");
+ if (isBackPressed) {
+ MicStatusManager.getInstance().clear();
+ ((LiveAudienceActivity) mContext).closeRoom();
+ } else {
+ EventBus.getDefault().post(new LiveRoomChangeEvent(bean, liveType, liveTypeVal));
+ }
+ }
+ } else {
+ if (RCRTCEngine.getInstance().getRoom() == null || RCRTCEngine.getInstance().getRoom().getLocalUser() == null) {
+ return;
+ }
+ ToastUtil.show("下麥中,稍等.....");
+ RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() {
- if (isBackPressed) {
- MicStatusManager.getInstance().clear();
- ((LiveAudienceActivity) mContext).closeRoom();
- } else {
- EventBus.getDefault().post(new LiveRoomChangeEvent(bean, liveType, liveTypeVal));
+ /**
+ * 当切换失败且SDK处于无法回退状态时回调,该角色已经无法使用当前角色继续进行音视频。
+ * SDK内部会退出房间并清理所有资源,该用户只能重新加入房间才能继续音视频。
+ */
+ @Override
+ public void onKicked() {
+
+ }
+
+ @Override
+ public void onSuccess() {
+ Log.e("ry", "下麦成功");
+ // 该用户切换为观众成功,可以以观众身份进行音视频
+ //退出多人房间
+ HttpClient.getInstance().get("live.leaveDrLm", "live.leaveDrLm")
+ .params("roomid", liveID)
+ .execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ Log.e("ry", code + "退出多人");
+
+ }
+ });
+ //退出rtc播放
+ RCRTCEngine.getInstance().leaveRoom(new IRCRTCResultCallback() {
+ @Override
+ public void onSuccess() {
+ Log.e("ry", "退出多人房间成功");
+
+ if (isBackPressed) {
+ MicStatusManager.getInstance().clear();
+ ((LiveAudienceActivity) mContext).closeRoom();
+ } else {
+ EventBus.getDefault().post(new LiveRoomChangeEvent(bean, liveType, liveTypeVal));
+ }
}
- }
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", errorCode + "退出多人房间失敗");
+ @Override
+ public void onFailed(RTCErrorCode errorCode) {
+ Log.e("ry", errorCode + "退出多人房间失敗");
- }
- });
+ }
+ });
- }
+ }
- /**
- * 当切换失败且不影响当前角色继续音视频时回调
- * @param errorCode 失败错误码
- */
- @Override
- public void onFailed(RTCErrorCode errorCode) {
- Log.e("ry", "下麦失败" + errorCode);
+ /**
+ * 当切换失败且不影响当前角色继续音视频时回调
+ * @param errorCode 失败错误码
+ */
+ @Override
+ public void onFailed(RTCErrorCode errorCode) {
+ Log.e("ry", "下麦失败" + errorCode);
- }
- });
+ }
+ });
+ }
}
@Override
@@ -1148,11 +1283,17 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (!mFirstConnectSocket) {
mFirstConnectSocket = true;
if (mLiveType == Constants.LIVE_TYPE_PAY || mLiveType == Constants.LIVE_TYPE_TIME) {
-
- SocketRyChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal, 1);
-
+ if (isSw) {
+ SocketSwChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal, 1);
+ } else {
+ SocketRyChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal, 1);
+ }
+ }
+ if (isSw) {
+ SocketSwChatUtil.getFakeFans(mLiveBean.getUid());
+ } else {
+ SocketRyChatUtil.getFakeFans(mLiveBean.getUid());
}
- SocketRyChatUtil.getFakeFans(mLiveBean.getUid());
}
}
}
@@ -1326,7 +1467,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
public void showAllServerNotifyFFGGGD(AllServerNotifyFFGGGDJANEvent notifyFFGGGDJANEvent) {
if (mLiveRoomViewHolder != null) {
- mLiveRoomViewHolder.showAllServerNotifyFFGGGD(notifyFFGGGDJANEvent,true);
+ mLiveRoomViewHolder.showAllServerNotifyFFGGGD(notifyFFGGGDJANEvent, true);
}
}
@@ -1358,20 +1499,34 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override
public void onSendGiftPk(long leftGift, long rightGift, LivePKUserListBean bean) {
-
- if (mLiveRyLinkMicPkPresenter != null) {
- mLiveRyLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean);
-
+ if (isSw) {
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean);
+ }
+ } else {
+ if (mLiveRyLinkMicPkPresenter != null) {
+ mLiveRyLinkMicPkPresenter.onPkProgressChanged(leftGift, rightGift, bean);
+ }
}
}
@Override
public void onEndPk(long leftUid, long rightUid, long left, long right, LivePKUserListBean bean) {
- if (mLiveRyLinkMicPkPresenter != null) {
- if (mLiveUid.equals(leftUid + "")) {
- mLiveRyLinkMicPkPresenter.onPkProgressEnd(left, right, bean);
- } else {
- mLiveRyLinkMicPkPresenter.onPkProgressEnd(right, left, bean);
+ if (isSw) {
+ if (mLiveSwLinkMicPkPresenter != null) {
+ if (mLiveUid.equals(leftUid + "")) {
+ mLiveSwLinkMicPkPresenter.onPkProgressEnd(left, right, bean);
+ } else {
+ mLiveSwLinkMicPkPresenter.onPkProgressEnd(right, left, bean);
+ }
+ }
+ } else {
+ if (mLiveRyLinkMicPkPresenter != null) {
+ if (mLiveUid.equals(leftUid + "")) {
+ mLiveRyLinkMicPkPresenter.onPkProgressEnd(left, right, bean);
+ } else {
+ mLiveRyLinkMicPkPresenter.onPkProgressEnd(right, left, bean);
+ }
}
}
}
@@ -1484,7 +1639,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override
public void onAudienceApplyLinkMic(UserBean u) {
-
+ L.eSw("onAudienceApplyLinkMic(2)");
}
@Override
@@ -1573,10 +1728,32 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
@Override
- public void onLinkDRMicPkApplyOk(UserBean u) {
-
+ public void onLinkDRMicPKToUser(UserBean u) {
+ L.eSw("onLinkDRMicPKToUser(UserBean u)PortraitLiveManager");
+ mLivePlayViewHolder.setDrMicInfo(u);
}
+ @Override
+ public void onLinkDRMicPkApplyOk(UserBean u) {
+ L.eSw("onLinkDRMicPkApplyOk(UserBean u)PortraitLiveManager");
+ //mLivePlayViewHolder.setDrMicInfo(u);
+ }
+
+ @Override
+ public void onLinkDRMicPkQuit(String uid) {
+ L.eSw("onLinkDRMicPkQuit:" + uid);
+ mLivePlayViewHolder.removeLiveUid(uid);
+ int removeUid = 0;
+ for (int k = 0; k < pkScores.size(); k++) {
+ JSONObject score = pkScores.getJSONObject(k);
+ String userID = score.getString("id");
+ if (userID.equals(uid)) {
+ removeUid = k;
+ }
+ }
+ pkScores.remove(removeUid);
+ upDataPkScore(pkScores, -1);
+ }
/**
* 主播与主播PK 所有人收到PK开始的回调
@@ -1603,12 +1780,20 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
};
-
- if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) {
- mLiveRoomViewHolder.pkHandler = true;
- mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1);
- linkMicPkStartHandler.postDelayed(linkMicPkStartRunnable, 4000);//3秒后执行Runnable中的run方法
+ if (isSw) {
+ if (mLiveSwLinkMicPkPresenter != null && mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.pkHandler = true;
+ mLiveSwLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1);
+ linkMicPkStartHandler.postDelayed(linkMicPkStartRunnable, 4000);//3秒后执行Runnable中的run方法
+ }
+ } else {
+ if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.pkHandler = true;
+ mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1);
+ linkMicPkStartHandler.postDelayed(linkMicPkStartRunnable, 4000);//3秒后执行Runnable中的run方法
+ }
}
+
if (mLivePlayViewHolder != null) {
mLivePlayViewHolder.setLiveBeanLandscape(1);
}
@@ -1631,15 +1816,24 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override
public void onLinkMicPkClose(int i) {
-
- if (mLiveRyLinkMicPkPresenter != null) {
- mLiveRyLinkMicPkPresenter.onLinkMicPkClose(i);
- if (mLiveRoomViewHolder != null) {
- mLiveRoomViewHolder.resetViewGone();
+ if (isSw) {
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onLinkMicPkClose(i);
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.resetViewGone();
+ }
+ }
+ } else {
+ if (mLiveRyLinkMicPkPresenter != null) {
+ mLiveRyLinkMicPkPresenter.onLinkMicPkClose(i);
+ if (mLiveRoomViewHolder != null) {
+ mLiveRoomViewHolder.resetViewGone();
+ }
}
}
if (mLiveRoomViewHolder != null) {
mLivePlayViewHolder.setLiveBeanLandscape(landscape);
+ mLivePlayViewHolder.endpk(mPkUid);
}
if (mContext instanceof LiveAudienceActivity) {
((LiveAudienceActivity) mContext).setPkStatus(false);
@@ -1663,9 +1857,16 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override
public void onLinkMicPkEnd(String winUid) {
- if (mLiveRyLinkMicPkPresenter != null) {
- mLiveRyLinkMicPkPresenter.onLinkMicPkEnd(winUid);
- //mLiveRoomViewHolder.setDelOtherInfo();
+ if (isSw) {
+ if (mLiveSwLinkMicPkPresenter != null) {
+ mLiveSwLinkMicPkPresenter.onLinkMicPkEnd(winUid);
+ //mLiveRoomViewHolder.setDelOtherInfo();
+ }
+ } else {
+ if (mLiveRyLinkMicPkPresenter != null) {
+ mLiveRyLinkMicPkPresenter.onLinkMicPkEnd(winUid);
+ //mLiveRoomViewHolder.setDelOtherInfo();
+ }
}
}
@@ -1857,9 +2058,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (mSocketRyClient != null) {
mSocketRyClient.disConnect();
+ mSocketRyClient = null;
}
- mSocketRyClient = null;
+ if (mSocketSwClient != null) {
+ mSocketSwClient.disConnect();
+ mSocketSwClient = null;
+ }
//结束播放
if (mLivePlayViewHolder != null) {
@@ -1897,6 +2102,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (!isEnterRoom) {
return;
}
+ SWAuManager.get().exitChannelAll();
LiveNetManager.get(mContext)
.leaveRoomNew(leaveStream, leaveGroupId, new com.yunbao.common.http.base.HttpCallback() {
@Override
@@ -1976,8 +2182,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
MobclickAgent.onEvent(mContext, "live_room_light", "直播间点亮");
mLighted = true;
int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE;
- SocketRyChatUtil.sendLightMessage(mLiveBean.getUid(), 1 + RandomUtil.nextInt(6), guardType);
-
+ if (isSw) {
+ SocketSwChatUtil.sendLightMessage(mLiveBean.getUid(), 1 + RandomUtil.nextInt(6), guardType);
+ } else {
+ SocketRyChatUtil.sendLightMessage(mLiveBean.getUid(), 1 + RandomUtil.nextInt(6), guardType);
+ }
}
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.playLightAnim();
@@ -2035,9 +2244,11 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
* 更新主播映票数
*/
public void sendUpdateVotesMessage() {
-
- SocketRyChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal);
-
+ if (isSw) {
+ SocketSwChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal);
+ } else {
+ SocketRyChatUtil.sendUpdateVotesMessage(mLiveBean.getUid(), mLiveTypeVal);
+ }
}
public void onFollowEvent(FollowEvent e) {
@@ -2159,6 +2370,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mViewPager.setCanScroll(enableScroll);
}
+ public JSONArray pkScores;
+
/**
* 用户端多人Pk
*
@@ -2166,6 +2379,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
* @param time
*/
public void upDataPkScore(JSONArray pkScores, int time) {
+ L.eSw("upDataPkScore" + time);
+ this.pkScores = pkScores;
if (mLiveRoomViewHolder != null) {
String liveId = mLiveBean.getUid();
JSONObject liveModel = null;
@@ -2180,7 +2395,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
pkScores.remove(index);
pkScores.add(0, liveModel);
- mLiveRoomViewHolder.upDataPkScore(pkScores, time);
+ if (time == -1) {
+ mLiveRoomViewHolder.upDataPkScore(pkScores);
+ } else {
+ mLiveRoomViewHolder.upDataPkScore(pkScores, time);
+ mLivePlayViewHolder.claerDrPkInfoView();
+ }
setPkStatus(true);
}
//通知心愿单位置换地方
diff --git a/live/src/main/java/com/yunbao/live/views/SidebarViewHoler.java b/live/src/main/java/com/yunbao/live/views/SidebarViewHoler.java
index 78561638b..4e3a49980 100644
--- a/live/src/main/java/com/yunbao/live/views/SidebarViewHoler.java
+++ b/live/src/main/java/com/yunbao/live/views/SidebarViewHoler.java
@@ -102,8 +102,8 @@ public class SidebarViewHoler extends RecyclerView.ViewHolder {
}
new LiveRoomCheckLivePresenter(itemView.getContext(), liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
}
@Override
diff --git a/live/src/main/res/layout/anchor_open_mic_view.xml b/live/src/main/res/layout/anchor_open_mic_view.xml
index 8141f4e93..5f7709c16 100644
--- a/live/src/main/res/layout/anchor_open_mic_view.xml
+++ b/live/src/main/res/layout/anchor_open_mic_view.xml
@@ -33,7 +33,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:layout_marginTop="8dp"
+ android:layout_marginTop="6dp"
android:text="打開語音連麥權限"
android:textColor="#FFFFFF"
android:textSize="12sp" />
@@ -43,8 +43,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
- android:layout_marginTop="3dp"
- android:layout_marginBottom="8dp"
+ android:layout_marginTop="2dp"
android:text="粉絲等級5以上的用戶可向您發起申請"
android:textColor="#259484"
android:textSize="8sp" />
diff --git a/live/src/main/res/layout/item_anchor_mic_info.xml b/live/src/main/res/layout/item_anchor_mic_info.xml
index 1c254dd47..fade3f7a3 100644
--- a/live/src/main/res/layout/item_anchor_mic_info.xml
+++ b/live/src/main/res/layout/item_anchor_mic_info.xml
@@ -19,7 +19,6 @@
android:gravity="center_vertical"
android:orientation="horizontal">
-
-
@@ -65,8 +64,11 @@
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:maxLines="1"
+ android:ellipsize="end"
android:text="用户名称"
android:textColor="#F6F7FB"
+ tools:textColor="@color/gray1"
android:textSize="14sp" />
@@ -130,7 +132,7 @@
android:id="@+id/mic_btn"
android:layout_width="wrap_content"
android:layout_height="28dp"
- android:layout_marginEnd="36dp"
+ android:layout_marginEnd="10dp"
android:background="@drawable/bg_anchor_mic_info_btn_ok"
android:text="同意"
android:textColor="#FFFFFF"
diff --git a/live/src/main/res/layout/item_live_chat.xml b/live/src/main/res/layout/item_live_chat.xml
index c4d360d8c..a6e5fddfb 100644
--- a/live/src/main/res/layout/item_live_chat.xml
+++ b/live/src/main/res/layout/item_live_chat.xml
@@ -10,13 +10,15 @@
diff --git a/live/src/main/res/layout/view_live_pk_details.xml b/live/src/main/res/layout/view_live_pk_details.xml
index 1fa312eb6..981fa2f64 100644
--- a/live/src/main/res/layout/view_live_pk_details.xml
+++ b/live/src/main/res/layout/view_live_pk_details.xml
@@ -16,7 +16,6 @@
android:layout_height="wrap_content"
android:layout_marginStart="5.33dp"
android:layout_marginTop="4.67dp"
- android:background="@drawable/background_pk_time"
android:gravity="center_vertical"
android:orientation="horizontal">
diff --git a/live/src/main/res/layout/view_live_play_sw.xml b/live/src/main/res/layout/view_live_play_sw.xml
new file mode 100644
index 000000000..64cb1c25f
--- /dev/null
+++ b/live/src/main/res/layout/view_live_play_sw.xml
@@ -0,0 +1,169 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/live/src/main/res/layout/view_live_push_sw.xml b/live/src/main/res/layout/view_live_push_sw.xml
new file mode 100644
index 000000000..bbe8f0a50
--- /dev/null
+++ b/live/src/main/res/layout/view_live_push_sw.xml
@@ -0,0 +1,239 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml
index 94c376c3e..64345b088 100644
--- a/live/src/main/res/layout/view_live_room.xml
+++ b/live/src/main/res/layout/view_live_room.xml
@@ -691,7 +691,7 @@
android:layout_height="27dp"
android:layout_below="@id/open_sidebar"
android:layout_alignParentRight="true"
- android:layout_marginTop="16dp"
+ android:layout_marginTop="20dp"
android:layout_marginRight="9dp"
android:background="@drawable/bg_live_other_ico"
android:gravity="center">
@@ -744,9 +744,8 @@
layout="@layout/view_red_packet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_below="@+id/live_rank_pk"
android:layout_marginStart="12dp"
- android:layout_marginTop="15dp"
+ android:layout_marginTop="100dp"
android:visibility="gone" />
-
+ android:layout_alignParentBottom="true"
+ android:layout_height="wrap_content">
+
+
+
+
+
+
() {
+ @Override
+ public void onSuccess(SwTokenModel data) {
+ CommonAppConfig.SWToken = data.getToken();
+ }
+
+ @Override
+ public void onError(String error) {
+
+ }
+ });
+ }
+
+
private void requestNotReadMessage() {
}
@@ -689,6 +708,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
}
if (data.getShowWarOrder() == 0) {
floatWarOrder.setVisibility(View.GONE);
+ floatWarOrder.setTag(null);
//战令关闭情况下,在判断一次Banner是否足够
if (data.getListShow() == 1 && data.getList().size() > 2) {
floatBanner.setVisibility(View.VISIBLE);
@@ -701,8 +721,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
} else {
if (mainHomeComViewHolder != null && mainHomeComViewHolder.isFloatWarOrder()) {
floatWarOrder.setVisibility(View.GONE);
+ floatWarOrder.setTag(null);
} else {
floatWarOrder.setVisibility(View.VISIBLE);
+ floatWarOrder.setTag(data);
}
floatBanner.setVisibility(View.GONE);
@@ -850,18 +872,17 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
private void showStartDialog() {
- if (isReady == true) {
- MainStartDialogFragment dialogFragment = new MainStartDialogFragment();
- dialogFragment.setMainStartChooseCallback(true, this);
- dialogFragment.show(getSupportFragmentManager(), "MainStartDialogFragment");
- } else {
- ToastUtil.show("正在初始化,請稍等....");
- }
+ if (isReady == true) {
+ MainStartDialogFragment dialogFragment = new MainStartDialogFragment();
+ dialogFragment.setMainStartChooseCallback(true, this);
+ dialogFragment.show(getSupportFragmentManager(), "MainStartDialogFragment");
+ } else {
+ ToastUtil.show("正在初始化,請稍等....");
+ }
}
-
/**
* 检查版本更新
*/
@@ -877,7 +898,15 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
if (!APKManager.get().getApkVerNew()) {
new XPopup.Builder(mContext).isDestroyOnDismiss(true).dismissOnBackPressed(false) // 按返回键是否关闭弹窗,默认为true
.dismissOnTouchOutside(false) // 点击外部是否关闭弹窗,默认为true
- .asCustom(new APKUpdateCustomPopup(mContext, false)).show();
+ .asCustom(
+ new APKUpdateCustomPopup(mContext, false)
+ .setOnDismissListener(new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialogInterface) {
+ requestBonus();
+ }
+ })
+ ).show();
}
} else {
requestBonus();
@@ -887,6 +916,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
});
}
+ private void initAdOpenWindows() {
+ OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false);
+ }
+
/**
* 填写邀请码
*/
@@ -917,14 +950,21 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
* 签到奖励
*/
SigninDialog fragment;
+ boolean isRequestBonus = false;
private void requestBonus() {
fragment = new SigninDialog();
MainHttpUtil.requestNewBonus(new HttpCallback() {
@Override
- public void onSuccess(int code, String msg, String[] info) {
+ public void onError() {
+ super.onError();
+ isRequestBonus = true;
+ }
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ isRequestBonus = true;
if (info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
if (code == 0) {
@@ -933,14 +973,24 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
bundle.putString("send_exp", obj.getString("send_exp"));
bundle.putString("sign_day", obj.getString("sign_day"));
fragment.setArguments(bundle);
+ fragment.setOnDismissListener(new DialogInterface.OnDismissListener() {
+ @Override
+ public void onDismiss(DialogInterface dialogInterface) {
+ initAdOpenWindows();
+ }
+ });
if (!getSupportFragmentManager().isStateSaved()) {
fragment.show(getSupportFragmentManager(), "SigninDialog");
}
+ } else {
+ initAdOpenWindows();
}
if (obj != null && obj.containsKey("msg_zdy_send") && obj.containsKey("msg_zdy_send_text")) {
Log.e("MainActivity333", info[0]);
NoviceInstructorManager.get(mContext).getNetNoviceInstructor(info[0]);
}
+ } else {
+ initAdOpenWindows();
}
}
});
@@ -976,6 +1026,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
floatWarOrder.setVisibility(View.GONE);
findViewById(R.id.banner_click).setVisibility(View.GONE);
isfloatBannernet = false;
+ initAnchorRecommendBanner();
+ if (isRequestBonus) {
+ initAdOpenWindows();
+ }
}
/**
@@ -1106,9 +1160,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
public void watchLive(LiveBean liveBean, String key, int position) {
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
MobclickAgent.onEvent(mContext, "home_page_enter_room", "首页点击直播间");
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
}
@Override
@@ -1171,7 +1225,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
if (EasyFloat.isShow("LiveFloatView")) {
EasyFloat.dismiss("LiveFloatView", true);
}
- OpenAdManager.getInstance().reset();
+ OpenAdManager.getInstance().close();
super.onBackPressed();
}
}
@@ -1546,18 +1600,23 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Subscribe(threadMode = ThreadMode.MAIN)
public void onLiveFloatEvent(LiveFloatEvent event) {
if (event != null && event.getmLiveBean() != null && !TextUtils.isEmpty(event.getmLiveBean().getPull())) {
- new Handler().post(() -> LiveFloatView.getInstance().cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK(), event.getmLiveTypeVal()).builderFloat(mContext, event.getmLiveBean().getPull(), LiveAudienceActivity.class));
+ new Handler().post(() -> LiveFloatView.getInstance().cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK() ==Constants.LIVE_SDK_SW, event.getmLiveTypeVal()).builderFloat(mContext, event.getmLiveBean().getPull(), LiveAudienceActivity.class));
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onFloatWarOrderEvent(FloatWarOrderEvent event) {
- if (event.isFloatWarOrder()) {
+ /* if (event.isFloatWarOrder()) {
floatWarOrder.setVisibility(View.GONE);
} else {
if (anchorRecommendModel != null && anchorRecommendModel.getShowWarOrder() == 1) {
floatWarOrder.setVisibility(View.VISIBLE);
}
+ }*/
+ if(floatWarOrder.getTag()!=null){
+ floatWarOrder.setVisibility(View.VISIBLE);
+ }else{
+ floatWarOrder.setVisibility(View.GONE);
}
}
diff --git a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java
index 1a8cd0880..3f9271639 100644
--- a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity.java
@@ -262,7 +262,7 @@ public class MyWebViewActivity extends AbsActivity {
}
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (LiveRoomViewHolder.mHandler != null) {
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
@@ -275,7 +275,7 @@ public class MyWebViewActivity extends AbsActivity {
}
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)).setLiveEnd(true));
} else {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk),isSw);
}
}
diff --git a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java
index 04dc87b49..f9e312065 100644
--- a/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java
+++ b/main/src/main/java/com/yunbao/main/activity/MyWebViewActivity2.java
@@ -230,7 +230,7 @@ public class MyWebViewActivity2 extends AbsActivity {
}
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (LiveRoomViewHolder.mHandler != null) {
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
@@ -243,7 +243,7 @@ public class MyWebViewActivity2 extends AbsActivity {
}
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)));
} else {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk),isSw);
}
}
diff --git a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java
index 482daed48..aa9ed9314 100644
--- a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java
@@ -331,8 +331,8 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
liveBean.setParams(new HashMap<>());
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk, boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal), isSw);
}
@Override
diff --git a/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java b/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java
index 423f00ed0..70768fd69 100644
--- a/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java
@@ -529,8 +529,8 @@ public class RegisterActivity extends AbsActivity {
}
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
NoviceInstructorManager.get(mContext).setFrist(false);
}
diff --git a/main/src/main/java/com/yunbao/main/activity/SearchActivity.java b/main/src/main/java/com/yunbao/main/activity/SearchActivity.java
index 7ccea01cb..82104fa30 100644
--- a/main/src/main/java/com/yunbao/main/activity/SearchActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/SearchActivity.java
@@ -176,8 +176,8 @@ public class SearchActivity extends AbsActivity {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
}
@Override
diff --git a/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java b/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java
index b53248063..6415edf00 100644
--- a/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/UserHomeActivity.java
@@ -628,7 +628,7 @@ public class UserHomeActivity extends AbsActivity {
liveBean.setParams(gotoRoomKey);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (StringUtil.isEmpty(liveUid)) {
return;
}
@@ -636,7 +636,7 @@ public class UserHomeActivity extends AbsActivity {
if (AppManager.getInstance().getLiveActivity() != null) {
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)).setLiveEnd(true));
} else {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk),isSw);
}
}
diff --git a/main/src/main/java/com/yunbao/main/activity/WeekWebViewActivity.java b/main/src/main/java/com/yunbao/main/activity/WeekWebViewActivity.java
index cd1fb5682..f0096f634 100644
--- a/main/src/main/java/com/yunbao/main/activity/WeekWebViewActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/WeekWebViewActivity.java
@@ -154,8 +154,8 @@ public class WeekWebViewActivity extends AbsActivity {
}
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
}
@Override
diff --git a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java
index 81c65ad64..9b3bc4e02 100644
--- a/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/ZhuangBanActivity.java
@@ -396,7 +396,7 @@ public class ZhuangBanActivity extends AbsActivity {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (liveBean == null) {
return;
}
@@ -405,7 +405,7 @@ public class ZhuangBanActivity extends AbsActivity {
return;
}
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk),isSw);
finish();
}
diff --git a/main/src/main/java/com/yunbao/main/adapter/SearchAdapter.java b/main/src/main/java/com/yunbao/main/adapter/SearchAdapter.java
index d3ff13be0..a371e3f93 100644
--- a/main/src/main/java/com/yunbao/main/adapter/SearchAdapter.java
+++ b/main/src/main/java/com/yunbao/main/adapter/SearchAdapter.java
@@ -203,8 +203,8 @@ public class SearchAdapter extends RefreshAdapter {
}
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
}
@Override
diff --git a/main/src/main/java/com/yunbao/main/dialog/AnchorStartLiveNotifyDialog.java b/main/src/main/java/com/yunbao/main/dialog/AnchorStartLiveNotifyDialog.java
index a1237951c..c0177c0cb 100644
--- a/main/src/main/java/com/yunbao/main/dialog/AnchorStartLiveNotifyDialog.java
+++ b/main/src/main/java/com/yunbao/main/dialog/AnchorStartLiveNotifyDialog.java
@@ -77,8 +77,8 @@ public class AnchorStartLiveNotifyDialog extends AbsDialogPositionPopupWindow {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk),isSw);
}
@Override
diff --git a/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java b/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java
index e48687b28..755fcf47b 100644
--- a/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java
+++ b/main/src/main/java/com/yunbao/main/dialog/MainStartDialogFragment.java
@@ -33,6 +33,7 @@ import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.DialogUitl;
+import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.utils.PluginManager;
import com.yunbao.common.utils.ProcessResultUtil;
import com.yunbao.common.utils.RouteUtil;
@@ -41,6 +42,7 @@ import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.LiveConfig;
import com.yunbao.live.activity.LiveAnchorActivity;
import com.yunbao.live.activity.LiveRyAnchorActivity;
+import com.yunbao.live.activity.LiveSwAnchorActivity;
import com.yunbao.live.bean.LiveKsyConfigBean;
import com.yunbao.main.R;
import com.yunbao.main.activity.CommunitySendActivity;
@@ -230,13 +232,22 @@ public class MainStartDialogFragment extends AbsDialogFragment implements View.O
@Override
public void onSuccess(int code, String msg, String[] info1) {
try {
- JSONObject obj = JSON.parseObject(info[0]);
- JSONObject obj1 = JSON.parseObject(info1[0]);
- if (obj1.getString("is_rong").equals("1")) {
- LiveRyAnchorActivity.forward(mContext, obj.getIntValue("live_sdk"), JSON.parseObject(obj.getString("android"), LiveKsyConfigBean.class));
- } else {
- LiveAnchorActivity.forward(mContext, obj.getIntValue("live_sdk"), JSON.parseObject(obj.getString("android"), LiveKsyConfigBean.class));
- }
+ LiveHttpUtil.getIsSw(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] infos) {
+ JSONObject obj = JSON.parseObject(info[0]);
+ JSONObject obj1 = JSON.parseObject(info1[0]);
+ try {
+ if(code==201){ //声网
+ LiveSwAnchorActivity.forward(mContext, Constants.LIVE_SDK_SW, JSON.parseObject(obj.getString("android"), LiveKsyConfigBean.class));
+ }else if(code==200){//融云
+ LiveRyAnchorActivity.forward(mContext, obj.getIntValue("live_sdk"), JSON.parseObject(obj.getString("android"), LiveKsyConfigBean.class));
+ }
+ } catch (Exception e) {
+
+ }
+ }
+ });
} catch (Exception e) {
}
diff --git a/main/src/main/java/com/yunbao/main/dialog/OneLoginDialog.java b/main/src/main/java/com/yunbao/main/dialog/OneLoginDialog.java
index 46bd068f6..fc6406056 100644
--- a/main/src/main/java/com/yunbao/main/dialog/OneLoginDialog.java
+++ b/main/src/main/java/com/yunbao/main/dialog/OneLoginDialog.java
@@ -150,11 +150,11 @@ public class OneLoginDialog extends AbsDialogFragment {
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
NoviceInstructorManager.get(mContext).setFrist(false);
}
diff --git a/main/src/main/java/com/yunbao/main/dialog/SigninDialog.java b/main/src/main/java/com/yunbao/main/dialog/SigninDialog.java
index 219ede7e6..85c3969fb 100644
--- a/main/src/main/java/com/yunbao/main/dialog/SigninDialog.java
+++ b/main/src/main/java/com/yunbao/main/dialog/SigninDialog.java
@@ -3,6 +3,7 @@ package com.yunbao.main.dialog;
import static com.yunbao.common.utils.RouteUtil.PATH_REWARD;
import android.annotation.SuppressLint;
+import android.content.DialogInterface;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
@@ -20,12 +21,18 @@ import com.yunbao.main.R;
public class SigninDialog extends AbsDialogFragment {
TextView gold, sign_day;
+ private DialogInterface.OnDismissListener onDismissListener;
@Override
protected int getLayoutId() {
return R.layout.signin_dialog;
}
+ public SigninDialog setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
+ this.onDismissListener = onDismissListener;
+ return this;
+ }
+
@Override
protected int getDialogStyle() {
return R.style.dialog;
@@ -58,7 +65,7 @@ public class SigninDialog extends AbsDialogFragment {
goto_sign.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- ARouter.getInstance().build(PATH_REWARD).withString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=task&a=index" + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0")).navigation();
+ ARouter.getInstance().build(PATH_REWARD).withString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=task&a=index" + "&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0")).navigation();
dismiss();
}
@@ -79,4 +86,12 @@ public class SigninDialog extends AbsDialogFragment {
sign_day.setText(String.format(getString(R.string.this_month), bundle.getString("sign_day")));
}
+
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ super.onDismiss(dialog);
+ if (onDismissListener != null) {
+ onDismissListener.onDismiss(dialog);
+ }
+ }
}
diff --git a/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityFragment.java b/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityFragment.java
index 1a3110bc7..4cd029aff 100644
--- a/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityFragment.java
+++ b/main/src/main/java/com/yunbao/main/fragment/MainHomeCommunityFragment.java
@@ -264,8 +264,8 @@ public class MainHomeCommunityFragment extends BaseFragment {
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
}
@Override
diff --git a/main/src/main/java/com/yunbao/main/views/AbsMainListChildViewHolder.java b/main/src/main/java/com/yunbao/main/views/AbsMainListChildViewHolder.java
index 410000ee8..6b8d7226b 100644
--- a/main/src/main/java/com/yunbao/main/views/AbsMainListChildViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/AbsMainListChildViewHolder.java
@@ -170,8 +170,8 @@ public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder imple
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
}
@Override
@@ -406,8 +406,8 @@ public abstract class AbsMainListChildViewHolder extends AbsMainViewHolder imple
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
}
@Override
diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeFollLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeFollLiveViewHolder.java
index 1a0c9b5af..92a160d22 100644
--- a/main/src/main/java/com/yunbao/main/views/MainHomeFollLiveViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/MainHomeFollLiveViewHolder.java
@@ -15,6 +15,7 @@ import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.custom.ItemDecoration;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.OnItemClickListener;
+import com.yunbao.common.utils.L;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.main.R;
@@ -32,6 +33,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import io.agora.beautyapi.faceunity.agora.SWAuManager;
+
public class MainHomeFollLiveViewHolder extends AbsMainHomeChildViewHolder implements OnItemClickListener {
private CommonRefreshView mRefreshView;
private MainHomeRemFollLiveAdapter mAdapter;
@@ -56,7 +59,7 @@ public class MainHomeFollLiveViewHolder extends AbsMainHomeChildViewHolder imple
mRefreshView.showRefreshBar();
mRefreshView.mRecyclerView.scrollToPosition(0);
}
- }else if ("blacklist".equals(str)) {
+ } else if ("blacklist".equals(str)) {
if (mRefreshView != null) {
mRefreshView.showRefreshBar();
}
@@ -99,6 +102,7 @@ public class MainHomeFollLiveViewHolder extends AbsMainHomeChildViewHolder imple
@Override
public void onRefreshSuccess(List list, int count) {
+ SWAuManager.get().preloadChannel(list);
EventBus.getDefault().post(new AnchorRecommendModel());
}
@@ -115,6 +119,7 @@ public class MainHomeFollLiveViewHolder extends AbsMainHomeChildViewHolder imple
new_data.add(loadItemList.get(j));
}
}
+ SWAuManager.get().preloadChannel(new_data);
mAdapter.insertList(new_data);
}
@@ -147,6 +152,9 @@ public class MainHomeFollLiveViewHolder extends AbsMainHomeChildViewHolder imple
// if (mRefreshView != null) {
// mRefreshView.initData();
// }
+ if (mAdapter != null) {
+ SWAuManager.get().preloadChannel(mAdapter.getList());
+ }
}
@Override
@@ -164,6 +172,6 @@ public class MainHomeFollLiveViewHolder extends AbsMainHomeChildViewHolder imple
@Override
public void onResume() {
super.onResume();
-
+ L.eSw("onResume");
}
}
diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeFollowViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeFollowViewHolder.java
index 0dfd0bc0f..88fc09831 100644
--- a/main/src/main/java/com/yunbao/main/views/MainHomeFollowViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/MainHomeFollowViewHolder.java
@@ -23,6 +23,8 @@ import com.yunbao.main.http.MainHttpUtil;
import java.util.List;
+import io.agora.beautyapi.faceunity.agora.SWAuManager;
+
/**
* Created by cxf on 2018/9/22.
* 首页 关注
@@ -70,7 +72,9 @@ public class MainHomeFollowViewHolder extends AbsMainHomeChildViewHolder impleme
public List processData(String[] info) {
if (info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
- return JSON.parseArray(obj.getString("list"), LiveBean.class);
+ List liveBeanList = JSON.parseArray(obj.getString("list"), LiveBean.class);
+ SWAuManager.get().preloadChannel(liveBeanList);
+ return liveBeanList;
}
return null;
}
diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java
index 97345b408..605e2e89f 100644
--- a/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java
@@ -17,7 +17,7 @@ import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.enums.PopupPosition;
import com.yunbao.common.activity.AbsActivity;
-import com.yunbao.live.activity.SudGameActivity;
+import com.yunbao.live.activity.SudSwGameActivity;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.adapter.SudGameListAdapter;
import com.yunbao.common.bean.CreateSudRoomModel;
@@ -158,7 +158,7 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement
@Override
public void onSuccess(CreateSudRoomModel data) {
if (data != null) {
- Intent intent = new Intent(context, SudGameActivity.class);
+ Intent intent = new Intent(context, SudSwGameActivity.class);
intent.putExtra("CreateSudRoom", new Gson().toJson(data));
context.startActivity(intent);
} else {
diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java
index db9a1933b..a4f390768 100644
--- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java
@@ -74,6 +74,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import io.agora.beautyapi.faceunity.agora.SWAuManager;
+
/**
* Created by cxf on 2018/9/22.
* MainActivity 首页 直播
@@ -242,6 +244,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
if (liveModel != null) {
old_data.remove(liveModel);
}
+ SWAuManager.get().preloadChannel(old_data);
new_data.addAll(old_data);
}
@@ -271,6 +274,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
}
}
if (loadItemList.size() > 0) {
+ SWAuManager.get().preloadChannel(new_data);
mAdapter.insertList(new_data);
}
}
@@ -402,8 +406,8 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
liveBean.setParams(gotoRoomKey);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
}
@Override
@@ -497,7 +501,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
}
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (LiveRoomViewHolder.mHandler != null) {
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
@@ -509,7 +513,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
}
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)));
} else {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk),isSw);
}
}
@@ -533,6 +537,9 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
@Override
public void loadData() {
+ if (mAdapter != null) {
+ SWAuManager.get().preloadChannel(mAdapter.getList());
+ }
}
@Override
@@ -560,7 +567,6 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
@Override
public void onResume() {
super.onResume();
- OpenAdManager.getInstance().show(OpenAdManager.TYPE_HOME, false);
}
@Override
diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeRecomLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeRecomLiveViewHolder.java
index d86234c2f..ec5025544 100644
--- a/main/src/main/java/com/yunbao/main/views/MainHomeRecomLiveViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/MainHomeRecomLiveViewHolder.java
@@ -31,6 +31,8 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.Arrays;
import java.util.List;
+import io.agora.beautyapi.faceunity.agora.SWAuManager;
+
/**
* 首页推荐
*/
@@ -104,6 +106,7 @@ public class MainHomeRecomLiveViewHolder extends AbsMainHomeChildViewHolder impl
@Override
public void onRefreshSuccess(List list, int count) {
+ SWAuManager.get().preloadChannel(list);
EventBus.getDefault().post(new AnchorRecommendModel());
}
@@ -149,6 +152,9 @@ public class MainHomeRecomLiveViewHolder extends AbsMainHomeChildViewHolder impl
// if (mRefreshView != null) {
// mRefreshView.initData();
// }
+ if (mAdapter != null) {
+ SWAuManager.get().preloadChannel(mAdapter.getList());
+ }
}
@Override
diff --git a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java
index f2c2119d7..21ef7593d 100644
--- a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java
@@ -682,8 +682,8 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal),isSw);
}
@Override
diff --git a/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java b/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java
index 63ca5a45c..0e6f32caa 100644
--- a/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java
+++ b/main/src/main/java/com/yunbao/main/views/UserHomeViewHolder2.java
@@ -787,7 +787,7 @@ public class UserHomeViewHolder2 extends AbsLivePageViewHolder implements LiveSh
}
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk,boolean isSw) {
if (mFromLiveRoom) {
if (MicStatusManager.getInstance().isMic(liveUid)) {
@@ -797,7 +797,7 @@ public class UserHomeViewHolder2 extends AbsLivePageViewHolder implements LiveSh
((UserHomeActivityOld) mContext).onBackPressed();
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)));
} else {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk),isSw);
}
}
diff --git a/pluginsForAnchor/build.gradle b/pluginsForAnchor/build.gradle
index 136dc36ff..50eb0c37d 100644
--- a/pluginsForAnchor/build.gradle
+++ b/pluginsForAnchor/build.gradle
@@ -85,7 +85,7 @@ android {
doLast {
delete(fileTree(dir: outputDir, includes: [
'model/ai_bgseg_green.bundle',
- 'model/ai_face_processor.bundle',
+ //'model/ai_face_processor.bundle',
//'model/ai_face_processor_lite.bundle',
'model/ai_hairseg.bundle',
'model/ai_hand_processor.bundle',
@@ -119,7 +119,7 @@ android {
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
- abiFilters "armeabi-v7a", "arm64-v8a"
+ abiFilters "armeabi-v7a", "arm64-v8a","x86","x86_64"
}
}
aaptOptions {
diff --git a/settings.gradle b/settings.gradle
index c0913d2fb..bc9277453 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -7,3 +7,4 @@ include ':pluginsForAnchor'
//include ':lib_huawei'
include ':lib_google'
//include ':IAP6Helper'
+include ':lib_faceunity'
\ No newline at end of file
diff --git a/video/build.gradle b/video/build.gradle
index 920bc844f..64d86bea7 100644
--- a/video/build.gradle
+++ b/video/build.gradle
@@ -31,7 +31,7 @@ android {
versionName rootProject.ext.android.versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
ndk {
- abiFilters "armeabi-v7a","arm64-v8a"
+ abiFilters "armeabi-v7a","arm64-v8a","x86","x86_64"
}
javaCompileOptions {
annotationProcessorOptions {