Merge remote-tracking branch 'origin/语音房_6.6.4_'
# Conflicts: # common/src/main/res/values-en-rUS/string.xml # common/src/main/res/values-zh-rHK/strings.xml # common/src/main/res/values-zh-rTW/strings.xml # common/src/main/res/values-zh/strings.xml # common/src/main/res/values/strings.xml
This commit is contained in:
@@ -84,6 +84,9 @@
|
||||
<activity
|
||||
android:name=".activity.WebViewActivityMedal"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.SudGameActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MedalQuestionWebViewActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
633
live/src/main/java/com/yunbao/live/activity/SudGameActivity.java
Normal file
633
live/src/main/java/com/yunbao/live/activity/SudGameActivity.java
Normal file
@@ -0,0 +1,633 @@
|
||||
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.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.google.gson.Gson;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
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.SudGameChatImModel;
|
||||
import com.yunbao.common.bean.SudGameUserModel;
|
||||
import com.yunbao.common.dialog.SudGameInputPopupWindow;
|
||||
import com.yunbao.common.event.CheckRemainingBalanceEvent;
|
||||
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.GameMicManager;
|
||||
import com.yunbao.common.sud.QuickStartGameViewModel;
|
||||
import com.yunbao.common.sud.model.GameConfigModel;
|
||||
import com.yunbao.common.sud.model.GameViewInfoModel;
|
||||
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;
|
||||
|
||||
@Route(path = RouteUtil.PATH_SudGameActivity)
|
||||
public class SudGameActivity extends AbsActivity implements GameMicManager.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 GameMicManager 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<String> muteUser = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_sud_game;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
super.main();
|
||||
initView();
|
||||
initDate();
|
||||
}
|
||||
|
||||
private List<CustomSidebarChildModel> customSidebarChildModels = new ArrayList<>();
|
||||
|
||||
private void initDate() {
|
||||
|
||||
LiveNetManager.get(mContext)
|
||||
.getCustomSidebarInfo("1", new HttpCallback<List<CustomSidebarInfoModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<CustomSidebarInfoModel> data) {
|
||||
for (CustomSidebarInfoModel datum : data) {
|
||||
if (datum.getType().equals("6")) {
|
||||
customSidebarChildModels = datum.getChild();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
gameMicManager = new GameMicManager();
|
||||
gameMicManager.attachView(this);
|
||||
gameMicManager.config(this);
|
||||
gameMicManager.joinRoom(mLiveUid);
|
||||
// 设置禁用麦克风采集
|
||||
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
|
||||
ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
|
||||
gameCloseWheat.setVisibility(View.INVISIBLE);
|
||||
|
||||
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);
|
||||
mProcessResultUtil = new ProcessResultUtil(this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
LiveNetManager.get(mContext)
|
||||
.leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
Bus.getOff(this);
|
||||
gameMicManager.leaveRoom();
|
||||
gameMicManager.detachView();
|
||||
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)) {
|
||||
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)) {
|
||||
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(((SudGameActivity) 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 (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
|
||||
if (publishDefault) {
|
||||
disable = true;
|
||||
// 设置禁用麦克风采集
|
||||
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 {
|
||||
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 (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
|
||||
if (disable) {
|
||||
disable = false;
|
||||
// 设置禁用麦克风采集
|
||||
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
|
||||
ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat);
|
||||
LiveNetManager.get(mContext)
|
||||
.onMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "麥克風已開啟" : "Microphone turned on");
|
||||
} else {
|
||||
disable = true;
|
||||
// 设置禁用麦克风采集
|
||||
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
|
||||
ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
|
||||
LiveNetManager.get(mContext)
|
||||
.offMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "麥克風已關閉" : "Microphone turned off");
|
||||
}
|
||||
|
||||
} else {
|
||||
mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
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<View>() {
|
||||
@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<CheckRemainingBalance>() {
|
||||
@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("Shortage of money");
|
||||
}
|
||||
|
||||
}
|
||||
// ToastUtil.show(data.toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
|
||||
ToastUtil.show("貨幣数量不足 ");
|
||||
} else {
|
||||
ToastUtil.show("Shortage of money");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
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<CheckRemainingBalance>() {
|
||||
@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<List<SudGameUserModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<SudGameUserModel> 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<HttpCallbackModel>() {
|
||||
@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<RCRTCInputStream> 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<SudGameUserModel> 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<HttpCallbackModel>() {
|
||||
@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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.yunbao.live.custom;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffXfermode;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.Xfermode;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/1/27.
|
||||
* RecyclerView顶部渐变的itemDecoration
|
||||
*/
|
||||
|
||||
public class TopGradual extends RecyclerView.ItemDecoration {
|
||||
|
||||
private Paint mPaint;
|
||||
private Xfermode mXfermode;
|
||||
private LinearGradient mLinearGradient;
|
||||
private int mLayerId;
|
||||
|
||||
public TopGradual() {
|
||||
mPaint = new Paint();
|
||||
mXfermode = new PorterDuffXfermode(PorterDuff.Mode.DST_IN);
|
||||
mLinearGradient = new LinearGradient(0.0f, 0.0f, 0.0f, 50.0f, new int[]{0, Color.BLACK}, null, Shader.TileMode.CLAMP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawOver(Canvas canvas, RecyclerView parent, RecyclerView.State state) {
|
||||
super.onDrawOver(canvas, parent, state);
|
||||
mPaint.setXfermode(mXfermode);
|
||||
mPaint.setShader(mLinearGradient);
|
||||
canvas.drawRect(0.0f, 0.0f, parent.getRight(), 100.0f, mPaint);
|
||||
mPaint.setXfermode(null);
|
||||
canvas.restoreToCount(mLayerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
|
||||
super.onDraw(c, parent, state);
|
||||
mLayerId = c.saveLayer(0.0f, 0.0f, (float) parent.getWidth(), (float) parent.getHeight(), mPaint, Canvas.ALL_SAVE_FLAG);
|
||||
}
|
||||
}
|
||||
@@ -24,9 +24,7 @@ import com.opensource.svgaplayer.SVGADrawable;
|
||||
import com.opensource.svgaplayer.SVGAImageView;
|
||||
import com.opensource.svgaplayer.SVGAParser;
|
||||
import com.opensource.svgaplayer.SVGAVideoEntity;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.LevelBean;
|
||||
import com.yunbao.common.dialog.AbsDialogFragment;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
@@ -36,7 +34,7 @@ import com.yunbao.common.utils.SVGAViewUtils;
|
||||
import com.yunbao.live.R;
|
||||
import com.yunbao.live.activity.LiveActivity;
|
||||
import com.yunbao.live.bean.HotBean;
|
||||
import com.yunbao.live.custom.TopGradual;
|
||||
import com.yunbao.common.views.TopGradual;
|
||||
import com.yunbao.common.http.LiveHttpUtil;
|
||||
import com.yunbao.live.utils.LiveTextRender;
|
||||
|
||||
|
||||
@@ -554,6 +554,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.ai_te), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
if (!TextUtils.isEmpty(mUserBean.getId()) && !TextUtils.isEmpty(mUserBean.getUserNiceName())) {
|
||||
Bus.get().post(new LiveAudienceEvent()
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.INPUT_DIALOG)
|
||||
@@ -630,7 +631,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
* 跳转到个人主页
|
||||
*/
|
||||
private void forwardHomePage() {
|
||||
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
dismiss();
|
||||
Constants.mStream = mStream;
|
||||
RouteUtil.forwardUserHome(mContext, mToUid, true, mLiveUid, 0);
|
||||
@@ -640,11 +641,13 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
* 举报
|
||||
*/
|
||||
private void report() {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
LiveReportActivity.forward(mContext, mToUid);
|
||||
}
|
||||
|
||||
|
||||
private void gotoLive(String live_id) {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
dismiss();
|
||||
DialogUitl.showSimpleDialog(mContext, mContext.getString(R.string.party_studio), new DialogUitl.SimpleCallback() {
|
||||
@Override
|
||||
@@ -698,6 +701,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
}
|
||||
setAttention();
|
||||
} else if (i == R.id.btn_home_page) {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
if (isAnchor) {
|
||||
MobclickAgent.onEvent(mContext, "anchor_avatar_index", "点主播主页");
|
||||
} else {
|
||||
@@ -705,18 +709,22 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
}
|
||||
forwardHomePage();
|
||||
} else if (i == R.id.btn_report) {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
report();
|
||||
} else if (i == R.id.avatar) {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
if (isAnchor) {
|
||||
MobclickAgent.onEvent(mContext, "anchor_avatar_btn", "点主播头像");
|
||||
}
|
||||
forwardHomePage();
|
||||
} 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);
|
||||
} else if (i == R.id.btn_live) {
|
||||
gotoLive(mToUid);
|
||||
} else if (i == R.id.noble_icon_layout) {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
if (isAnchor) {
|
||||
dismiss();
|
||||
((LiveActivity) mContext).openFansWindow(mToUid);
|
||||
@@ -726,6 +734,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
.setType(LiveAudienceEvent.LiveAudienceType.NOBLE));
|
||||
}
|
||||
} else if (i == R.id.btn_setting) {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
setting();
|
||||
}
|
||||
}
|
||||
@@ -782,6 +791,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
private DialogUitl.StringArrayDialogCallback mArrayDialogCallback = new DialogUitl.StringArrayDialogCallback() {
|
||||
@Override
|
||||
public void onItemClick(String text, int tag) {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
if (tag == R.string.live_setting_kick) {
|
||||
kick();
|
||||
|
||||
@@ -815,6 +825,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
* 查看管理员列表
|
||||
*/
|
||||
private void adminList() {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
dismiss();
|
||||
((LiveActivity) mContext).openAdminListWindow();
|
||||
}
|
||||
@@ -823,6 +834,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
* 踢人
|
||||
*/
|
||||
private void kick() {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
LiveHttpUtil.kicking(mLiveUid, mToUid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
@@ -839,6 +851,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
* 永久禁言->改成三天禁言
|
||||
*/
|
||||
private void setShutUp() {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
LiveHttpUtil.setShutUp(mLiveUid, "0", 0, mToUid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
@@ -855,6 +868,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
* 本场禁言
|
||||
*/
|
||||
private void setShutUp2() {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
LiveHttpUtil.setShutUp(mLiveUid, mStream, 1, mToUid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
@@ -872,6 +886,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
* 设置或取消管理员
|
||||
*/
|
||||
private void setAdmin() {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
LiveHttpUtil.setAdmin(mLiveUid, mToUid, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
@@ -893,6 +908,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
* 超管关闭直播间
|
||||
*/
|
||||
private void closeLive() {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
dismiss();
|
||||
LiveHttpUtil.superCloseRoom(mLiveUid, 0, mSuperCloseRoomCallback);
|
||||
}
|
||||
@@ -901,11 +917,13 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
* 超管关闭直播间并禁止主播直播
|
||||
*/
|
||||
private void closeLive2() {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
dismiss();
|
||||
LiveHttpUtil.superCloseRoom(mLiveUid, 1, mSuperCloseRoomCallback);
|
||||
}
|
||||
|
||||
private void setShutUp3() {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
new LiveSettingSilenceDialog(mContext)
|
||||
.setItemClickListener((bean, position) -> {
|
||||
LiveHttpUtil.setShutUp(mLiveUid, mStream, 1, mToUid, bean + "", new HttpCallback() {
|
||||
@@ -927,6 +945,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On
|
||||
* 超管关闭直播间并禁用主播账户
|
||||
*/
|
||||
private void forbidAccount() {
|
||||
if (TextUtils.equals(mLiveUid, "uid")) return;
|
||||
dismiss();
|
||||
LiveHttpUtil.superCloseRoom(mLiveUid, 2, mSuperCloseRoomCallback);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.target.CustomTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.NinePatchChunk;
|
||||
import com.yunbao.live.activity.LiveActivity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
package com.yunbao.live.utils;
|
||||
|
||||
import android.graphics.Rect;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
public class NinePatchChunk {
|
||||
public static final int NO_COLOR = 0x00000001;
|
||||
public static final int TRANSPARENT_COLOR = 0x00000000;
|
||||
|
||||
public final Rect mPaddings = new Rect();
|
||||
|
||||
public int mDivX[];
|
||||
public int mDivY[];
|
||||
public int mColor[];
|
||||
|
||||
private static void readIntArray(final int[] data, final ByteBuffer buffer) {
|
||||
for (int i = 0, n = data.length; i < n; ++i)
|
||||
data[i] = buffer.getInt();
|
||||
}
|
||||
|
||||
private static void checkDivCount(final int length) {
|
||||
if (length == 0 || (length & 0x01) != 0)
|
||||
throw new RuntimeException("invalid nine-patch: " + length);
|
||||
}
|
||||
|
||||
public static NinePatchChunk deserialize(final byte[] data, int position) {
|
||||
final ByteBuffer byteBuffer =
|
||||
ByteBuffer.wrap(data).order(ByteOrder.nativeOrder());
|
||||
|
||||
if (byteBuffer.get() == 0) return null; // is not serialized
|
||||
|
||||
final NinePatchChunk chunk = new NinePatchChunk();
|
||||
chunk.mDivX = new int[byteBuffer.get()];
|
||||
chunk.mDivY = new int[byteBuffer.get()];
|
||||
chunk.mColor = new int[byteBuffer.get()];
|
||||
|
||||
checkDivCount(chunk.mDivX.length);
|
||||
checkDivCount(chunk.mDivY.length);
|
||||
|
||||
// skip 8 bytes
|
||||
byteBuffer.getInt();
|
||||
byteBuffer.getInt();
|
||||
|
||||
chunk.mPaddings.left = byteBuffer.getInt();
|
||||
chunk.mPaddings.right = byteBuffer.getInt();
|
||||
chunk.mPaddings.top = byteBuffer.getInt();
|
||||
chunk.mPaddings.bottom = byteBuffer.getInt();
|
||||
|
||||
// skip 4 bytes
|
||||
byteBuffer.getInt();
|
||||
|
||||
readIntArray(chunk.mDivX, byteBuffer);
|
||||
readIntArray(chunk.mDivY, byteBuffer);
|
||||
readIntArray(chunk.mColor, byteBuffer);
|
||||
|
||||
if (position == 1) {
|
||||
chunk.mPaddings.left = 9;
|
||||
chunk.mPaddings.right = 15;
|
||||
chunk.mPaddings.top = 33;
|
||||
chunk.mPaddings.bottom = 9;
|
||||
} else if (position == 0) {
|
||||
chunk.mPaddings.left = 48;
|
||||
chunk.mPaddings.right = 18;
|
||||
chunk.mPaddings.top = 9;
|
||||
chunk.mPaddings.bottom = 12;
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ import com.yunbao.live.bean.LiveWishlistBean;
|
||||
import com.yunbao.live.bean.WishlistItemModel;
|
||||
import com.yunbao.live.custom.LiveLightView;
|
||||
import com.yunbao.live.custom.RightGradual;
|
||||
import com.yunbao.live.custom.TopGradual;
|
||||
import com.yunbao.common.views.TopGradual;
|
||||
import com.yunbao.live.dialog.GiftWallDialog;
|
||||
import com.yunbao.live.dialog.LiveContactDetailsSendGiftDialog;
|
||||
import com.yunbao.live.dialog.LiveFaceUnityDialogFragment;
|
||||
|
||||
@@ -76,7 +76,7 @@ import com.yunbao.live.adapter.YouLikeMessageAdapter;
|
||||
import com.yunbao.live.bean.SearchUserBean;
|
||||
import com.yunbao.live.bean.SystemMessageBean;
|
||||
import com.yunbao.live.bean.YouLikeBean;
|
||||
import com.yunbao.live.custom.TopGradual;
|
||||
import com.yunbao.common.views.TopGradual;
|
||||
import com.yunbao.live.http.ImHttpConsts;
|
||||
import com.yunbao.live.http.ImHttpUtil;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user