From 1548b6f252132b71bc8ffa0c9bcbeee91b13d297 Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 29 Nov 2022 17:45:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E5=8F=8D?= =?UTF-8?q?=E9=A6=88=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9A=E4=B8=8A=E4=B8=8B?= =?UTF-8?q?=E6=BB=91=E5=8A=A8=E7=9B=B4=E6=92=AD=E9=97=B4=E4=BC=9A=E5=B8=A6?= =?UTF-8?q?=E7=9D=80PK=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/http/live/LiveNetManager.java | 25 +++- .../yunbao/live/views/LiveRoomViewHolder.java | 123 +++++++++--------- .../live/views/PortraitLiveManager.java | 9 +- 3 files changed, 95 insertions(+), 62 deletions(-) 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 ff618e38d..27e34daf1 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 @@ -17,6 +17,7 @@ import com.yunbao.common.bean.LiveInfoModel; import com.yunbao.common.bean.LiveRoomActivityBanner; import com.yunbao.common.bean.NobleRankHideUserListModel; import com.yunbao.common.bean.NobleTrumpetModel; +import com.yunbao.common.bean.PkRankBean; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.VipModel; @@ -459,7 +460,7 @@ public class LiveNetManager { .subscribe(new Consumer>>() { @Override public void accept(ResponseModel> listResponseModel) throws Exception { - List list=new ArrayList<>(); + List list = new ArrayList<>(); for (LinkMicUserBeanV2 bean : listResponseModel.getData().getInfo()) { list.addAll(bean.getUserlist()); for (LinkMicUserBean userBean : bean.getUserlist()) { @@ -481,6 +482,25 @@ public class LiveNetManager { }).isDisposed(); } + private Disposable randomPkApi; + + public void getRandomPk(String mLiveUid, String pkUid, HttpCallback callback) { + randomPkApi = API.get().pdLiveApi(mContext) + .getPkRanksList(mLiveUid, pkUid) + .observeOn(AndroidSchedulers.mainThread()) + .subscribeOn(Schedulers.io()) + .subscribe(listResponseModel -> { + callback.onSuccess(listResponseModel.getData().getInfo()); + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(throwable.getMessage()); + } + } + }); + } + /** * 直播间取消网络请求 */ @@ -491,5 +511,8 @@ public class LiveNetManager { if (enterRoomDisposable != null) { enterRoomDisposable.dispose(); } + if (randomPkApi != null) { + randomPkApi.dispose(); + } } } 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 6641899aa..35bd9f9be 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1626,66 +1626,68 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } public void initPkRank(String isLadders) { - API.get().pdLiveApi(mContext) - .getPkRanksList(mLiveUid, pkUid) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(listResponseModel -> { - PkRankBean bean = listResponseModel.getData().getInfo(); - if (bean != null) { - Log.i("PK", bean.toString() + " | " + isLadders); - initPkRankView(bean); - if (!StringUtil.isEmpty(bean.getClickUrl())) { - pkRankVf.setOnClickListener(v -> { - 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; - bundle.putString("url", url); - //bundle.putInt("height", DpUtil.dp2px(600)); - bundle.putInt("show_type", 0); - bundle.putString("roomId", mLiveUid); - LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment(); - liveHDDialogFragment.setArguments(bundle); - liveHDDialogFragment.show(((AbsActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); - }); + 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 -> { + 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; + bundle.putString("url", url); + //bundle.putInt("height", DpUtil.dp2px(600)); + 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); + mPkRankText.setText(bean.getName()); + ImgLoader.display(mContext, bean.getImg(), mPkRankIcon); + 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() + "連勝"); + } + if (Integer.parseInt(bean.getBlueVal()) > 2) { + mBlueVal.setVisibility(View.VISIBLE); + mBlueVal.setText(bean.getBlueVal() + "連勝"); + } + mPkRankTopIcon.setVisibility(View.VISIBLE); + ImgLoader.display(mContext, bean.getPkTopImgUrl(), mPkRankTopIcon); } - - mPkRankText.setText(bean.getName()); - ImgLoader.display(mContext, bean.getImg(), mPkRankIcon); - 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() + "連勝"); - } - if (Integer.parseInt(bean.getBlueVal()) > 2) { - mBlueVal.setVisibility(View.VISIBLE); - mBlueVal.setText(bean.getBlueVal() + "連勝"); - } - mPkRankTopIcon.setVisibility(View.VISIBLE); - ImgLoader.display(mContext, bean.getPkTopImgUrl(), mPkRankTopIcon); } - }, Throwable::printStackTrace) - .isDisposed(); + + @Override + public void onError(String error) { + + } + }); } @@ -1996,13 +1998,16 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } } - + public boolean pkHandler=true; //左上角显示对方主播头像及昵称 public void setOtherInfo(String touids, String url, String name) { Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { + if(!pkHandler){ + return; + } goto_room_view.setVisibility(View.VISIBLE); touid = touids; pkUid = touids; 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 97a9b76e5..fb83f8566 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -241,7 +241,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe .setmLiveType(mLiveType) .setmLiveTypeVal(mLiveTypeVal))); if (mLivePlayViewHolder == null) { - mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer,1); + 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()); mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer); mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView()); @@ -357,7 +357,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe bannerModel.setStart(false); bannerModel.setLink(model.getLink()); bannerModel.setImageUrl(model.getImg()); - if (TextUtils.equals(model.getIsHidden(),"0")){ + if (TextUtils.equals(model.getIsHidden(), "0")) { bannerBeans.add(bannerModel); } @@ -466,6 +466,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe LivePlayRyViewHolder.setViewUP(1); } + if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.pkHandler = false; + } if (pkInfo.getIntValue("ifpk") == 1 && pkInfo.getString("end_pk_time").equals("0")) {//pk开始了 LivePlayRyViewHolder.setViewUP(2); @@ -473,11 +476,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe //pk排名数据 LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class); if (mLiveRoomViewHolder != null) { + mLiveRoomViewHolder.pkHandler = true; mLiveRoomViewHolder.setOtherInfo(pkInfo.getString("pkuid"), pkInfo.getString("pkuimg"), pkInfo.getString("pkuname")); } 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; mLiveRoomViewHolder.initPkRank(null); } LivePlayRyViewHolder.setViewUP(3);