fix[声望升级-修复BUG]

This commit is contained in:
Martin 2024-05-31 20:59:16 +08:00
parent efa698ebfa
commit c4d378daba
9 changed files with 1002 additions and 945 deletions

View File

@ -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");
}
});
}

View File

@ -165,6 +165,7 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
private boolean mPaused;
String mBeautySdkType;
public static int isDRPK = 0;
public static int DRPKing = 0; // 0 多人PK前 1 多人PK中 2多人PK后
public static boolean PKing = false;
public static int pk_nub;
public static int backIndex = 0;//0=未判断1=已判断
@ -405,6 +406,7 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
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)
@ -872,6 +874,7 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
MicUserManager.get().removeAllMicUserList();
PKing = false;
isDRPK = 0;
DRPKing = 0;
endLive();
RandomPkManager.getInstance().release();
}
@ -1345,7 +1348,7 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
Log.e("tx", "aaa" + errorCode.toString());
ToastUtil.show(errorCode.code + ":" + errorCode.msg);
//ToastUtil.show(errorCode.code + ":" + errorCode.msg);
}
});
} else {

View File

@ -3,6 +3,7 @@ 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;
@ -158,6 +159,8 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
private List<DrPkbean> drPkbeans = new ArrayList<>();
private JSONArray pkScores; //PK分数
public LiveSwLinkMicPkPresenter setDRInitiator(boolean DRInitiator) {
this.DRInitiator = DRInitiator;
return this;
@ -475,6 +478,98 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
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);
}
}, 1000);
}
SWManager.get().setDrPkNumClarity(drPkbeans.size());
if (drPkbeans.size() == 1) {
mLiveAnchorViewHolder.closeEndPkBt();
@ -520,7 +615,6 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
dRjoinOtherRoom(u);
//展示结束连麦按钮
mLiveAnchorViewHolder.showEndPkBt();
mLiveAnchorViewHolder.setDrpkRoomId(CommonAppConfig.getInstance().getUid());
}
/**
@ -578,6 +672,9 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
/*---------------------------------------------------------------- */
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");
@ -711,6 +808,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
EventBus.getDefault().post(new AnchorInfoEvent(true, "", "", ""));
Log.e("ry", "退出多人OKKK" + inputStreamList.size());
isDRPK = 0;
DRPKing = 1;
runOnUiThread(new Runnable() {
@Override
public void run() {
@ -1159,6 +1257,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
//多人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
@ -1601,11 +1700,13 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
* 更新Pk分数
*/
public void upDataPkScore(JSONArray pkScores, String uid, int time) {
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) {
if (livePushSwViewHolder.timeTitle.getVisibility() == View.GONE &&!"-1".equals(uid)) {
mHandler.removeMessages(WHAT_PK_TIME2);
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) livePushSwViewHolder.timeTitle.getLayoutParams();
layoutParams.topMargin = DpUtil.dp2px(123);
@ -1699,7 +1800,7 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
}
}
}
} else {
} else if(pkScoreSize == 4){
String userID3 = (String) imageGrade3.getTag();
detailsLinearLayout1.setVisibility(View.VISIBLE);
@ -1803,6 +1904,61 @@ public class LiveSwLinkMicPkPresenter implements View.OnClickListener {
}
}
}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")) {
ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade1);
} else {
int ranking = score.getIntValue("paiming");
switch (ranking) {
case 1:
ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade1);
break;
case 2:
ImgLoader.display(mContext, R.mipmap.icon_livepk_no2, imageGrade1);
break;
case 3:
ImgLoader.display(mContext, R.mipmap.icon_livepk_no3, imageGrade1);
break;
case 4:
ImgLoader.display(mContext, R.mipmap.icon_livepk_no4, imageGrade1);
break;
}
}
} else if (TextUtils.equals(userID, userID2)) {
textGrade2.setText(String.valueOf(userScore));
if (!score.containsKey("paiming")) {
ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade2);
} else {
int ranking = score.getIntValue("paiming");
switch (ranking) {
case 1:
ImgLoader.display(mContext, R.mipmap.icon_livepk_no1, imageGrade2);
break;
case 2:
ImgLoader.display(mContext, R.mipmap.icon_livepk_no2, imageGrade2);
break;
case 3:
ImgLoader.display(mContext, R.mipmap.icon_livepk_no3, imageGrade2);
break;
case 4:
ImgLoader.display(mContext, R.mipmap.icon_livepk_no4, imageGrade2);
break;
}
}
}
}
}
}

View File

@ -3,6 +3,7 @@ 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;
@ -314,14 +315,12 @@ public class SocketSwClient {
mListener.onLinkDRMicPkApply(u);
} else if (action3 == 2) {
//收到对方同意多人PK邀请
if ("0".equals(map.getString("msgtype"))) {
return;
}
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) {
@ -333,6 +332,7 @@ public class SocketSwClient {
// 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);
@ -353,6 +353,7 @@ public class SocketSwClient {
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
}*/
isDRPK = 1;
DRPKing = 0;
if (livePushSwViewHolder == null) {
if ("4".equals(map.getString("msgtype"))) {
return;

View File

@ -8,9 +8,11 @@ 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;
@ -356,6 +358,7 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
if (detailsView1 != null) {
dr1_preview.removeView(detailsView1);
}
}
/**
@ -415,6 +418,7 @@ public class LivePlaySwViewHolder extends LiveRoomPlayViewHolder {
}
});
}
@Override
public void endLiveMic() {
L.eSw("endLiveMic");

View File

@ -197,7 +197,7 @@ public class LivePushSwViewHolder extends AbsRyLivePushViewHolder implements ITX
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());

View File

@ -1737,6 +1737,16 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
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);
}
/**
@ -2354,6 +2364,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mViewPager.setCanScroll(enableScroll);
}
public JSONArray pkScores;
/**
* 用户端多人Pk
*
@ -2362,6 +2374,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
*/
public void upDataPkScore(JSONArray pkScores, int time) {
L.eSw("upDataPkScore" + time);
this.pkScores = pkScores;
if (mLiveRoomViewHolder != null) {
String liveId = mLiveBean.getUid();
JSONObject liveModel = null;
@ -2376,8 +2389,12 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
pkScores.remove(index);
pkScores.add(0, liveModel);
if (time == -1) {
mLiveRoomViewHolder.upDataPkScore(pkScores);
} else {
mLiveRoomViewHolder.upDataPkScore(pkScores, time);
mLivePlayViewHolder.claerDrPkInfoView();
}
setPkStatus(true);
}
//通知心愿单位置换地方

View File

@ -49,7 +49,7 @@
<FrameLayout
android:id="@+id/pk_container"
android:layout_width="match_parent"
android:layout_height="270dp"
android:layout_height="280dp"
android:layout_marginTop="130dp">
<com.yunbao.live.custom.MyFrameLayout4
@ -69,7 +69,7 @@
<LinearLayout
android:id="@+id/dr_pk_view"
android:layout_width="match_parent"
android:layout_height="270dp"
android:layout_height="280dp"
android:layout_marginTop="130dp"
android:orientation="horizontal"
android:visibility="gone">