修复测试反馈的问题:上下滑动直播间会带着PK提示

This commit is contained in:
zlzw 2022-11-29 17:45:08 +08:00
parent 0c6b62ed1a
commit 1548b6f252
3 changed files with 95 additions and 62 deletions

View File

@ -17,6 +17,7 @@ import com.yunbao.common.bean.LiveInfoModel;
import com.yunbao.common.bean.LiveRoomActivityBanner; import com.yunbao.common.bean.LiveRoomActivityBanner;
import com.yunbao.common.bean.NobleRankHideUserListModel; import com.yunbao.common.bean.NobleRankHideUserListModel;
import com.yunbao.common.bean.NobleTrumpetModel; import com.yunbao.common.bean.NobleTrumpetModel;
import com.yunbao.common.bean.PkRankBean;
import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.SetAttentsModel;
import com.yunbao.common.bean.StarChallengeStatusModel; import com.yunbao.common.bean.StarChallengeStatusModel;
import com.yunbao.common.bean.VipModel; import com.yunbao.common.bean.VipModel;
@ -459,7 +460,7 @@ public class LiveNetManager {
.subscribe(new Consumer<ResponseModel<List<LinkMicUserBeanV2>>>() { .subscribe(new Consumer<ResponseModel<List<LinkMicUserBeanV2>>>() {
@Override @Override
public void accept(ResponseModel<List<LinkMicUserBeanV2>> listResponseModel) throws Exception { public void accept(ResponseModel<List<LinkMicUserBeanV2>> listResponseModel) throws Exception {
List<LinkMicUserBean> list=new ArrayList<>(); List<LinkMicUserBean> list = new ArrayList<>();
for (LinkMicUserBeanV2 bean : listResponseModel.getData().getInfo()) { for (LinkMicUserBeanV2 bean : listResponseModel.getData().getInfo()) {
list.addAll(bean.getUserlist()); list.addAll(bean.getUserlist());
for (LinkMicUserBean userBean : bean.getUserlist()) { for (LinkMicUserBean userBean : bean.getUserlist()) {
@ -481,6 +482,25 @@ public class LiveNetManager {
}).isDisposed(); }).isDisposed();
} }
private Disposable randomPkApi;
public void getRandomPk(String mLiveUid, String pkUid, HttpCallback<PkRankBean> callback) {
randomPkApi = API.get().pdLiveApi(mContext)
.getPkRanksList(mLiveUid, pkUid)
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(listResponseModel -> {
callback.onSuccess(listResponseModel.getData().getInfo());
}, new Consumer<Throwable>() {
@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) { if (enterRoomDisposable != null) {
enterRoomDisposable.dispose(); enterRoomDisposable.dispose();
} }
if (randomPkApi != null) {
randomPkApi.dispose();
}
} }
} }

View File

@ -1626,66 +1626,68 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
} }
public void initPkRank(String isLadders) { public void initPkRank(String isLadders) {
API.get().pdLiveApi(mContext) LiveNetManager.get(mContext)
.getPkRanksList(mLiveUid, pkUid) .getRandomPk(mLiveUid, pkUid, new com.yunbao.common.http.base.HttpCallback<PkRankBean>() {
.observeOn(AndroidSchedulers.mainThread()) @Override
.subscribeOn(Schedulers.io()) public void onSuccess(PkRankBean bean) {
.subscribe(listResponseModel -> { if (bean != null) {
PkRankBean bean = listResponseModel.getData().getInfo(); initPkRankView(bean);
if (bean != null) { if (!StringUtil.isEmpty(bean.getClickUrl())) {
Log.i("PK", bean.toString() + " | " + isLadders); pkRankVf.setOnClickListener(v -> {
initPkRankView(bean); Bundle bundle = new Bundle();
if (!StringUtil.isEmpty(bean.getClickUrl())) { String path = bean.getClickUrl();
pkRankVf.setOnClickListener(v -> { if (!path.startsWith("/") && !path.startsWith("http")) {
Bundle bundle = new Bundle(); path = "/" + path;
String path = bean.getClickUrl(); }
if (!path.startsWith("/") && !path.startsWith("http")) { String url = null;
path = "/" + path; if (path.startsWith("http") || path.startsWith("/http")) {
} url = path;
String url = null; } else {
if (path.startsWith("http") || path.startsWith("/http")) { url = CommonAppConfig.HOST + path;
url = path; }
} else { if (!url.contains("?")) {
url = CommonAppConfig.HOST + path; url += "?";
} } else {
if (!url.contains("?")) { url += "&";
url += "?"; }
} else { url += "uid=" + CommonAppConfig.getInstance().getUid() + "&token="
url += "&"; + CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid;
} bundle.putString("url", url);
url += "uid=" + CommonAppConfig.getInstance().getUid() + "&token=" //bundle.putInt("height", DpUtil.dp2px(600));
+ CommonAppConfig.getInstance().getToken() + "&anchorUid=" + mLiveUid; bundle.putInt("show_type", 0);
bundle.putString("url", url); bundle.putString("roomId", mLiveUid);
//bundle.putInt("height", DpUtil.dp2px(600)); LiveHDDialogFragment liveHDDialogFragment = new LiveHDDialogFragment();
bundle.putInt("show_type", 0); liveHDDialogFragment.setArguments(bundle);
bundle.putString("roomId", mLiveUid); liveHDDialogFragment.show(((AbsActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment");
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) { public void setOtherInfo(String touids, String url, String name) {
Handler handler = new Handler(); Handler handler = new Handler();
handler.postDelayed(new Runnable() { handler.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
if(!pkHandler){
return;
}
goto_room_view.setVisibility(View.VISIBLE); goto_room_view.setVisibility(View.VISIBLE);
touid = touids; touid = touids;
pkUid = touids; pkUid = touids;

View File

@ -241,7 +241,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
.setmLiveType(mLiveType) .setmLiveType(mLiveType)
.setmLiveTypeVal(mLiveTypeVal))); .setmLiveTypeVal(mLiveTypeVal)));
if (mLivePlayViewHolder == null) { 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()); 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); mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer);
mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView()); mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView());
@ -357,7 +357,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
bannerModel.setStart(false); bannerModel.setStart(false);
bannerModel.setLink(model.getLink()); bannerModel.setLink(model.getLink());
bannerModel.setImageUrl(model.getImg()); bannerModel.setImageUrl(model.getImg());
if (TextUtils.equals(model.getIsHidden(),"0")){ if (TextUtils.equals(model.getIsHidden(), "0")) {
bannerBeans.add(bannerModel); bannerBeans.add(bannerModel);
} }
@ -466,6 +466,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
LivePlayRyViewHolder.setViewUP(1); LivePlayRyViewHolder.setViewUP(1);
} }
if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.pkHandler = false;
}
if (pkInfo.getIntValue("ifpk") == 1 && pkInfo.getString("end_pk_time").equals("0")) {//pk开始了 if (pkInfo.getIntValue("ifpk") == 1 && pkInfo.getString("end_pk_time").equals("0")) {//pk开始了
LivePlayRyViewHolder.setViewUP(2); LivePlayRyViewHolder.setViewUP(2);
@ -473,11 +476,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//pk排名数据 //pk排名数据
LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class); LivePKUserListBean livePKUserListBean = JSON.parseObject(pkInfo.getString("pk_top_users"), LivePKUserListBean.class);
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.pkHandler = true;
mLiveRoomViewHolder.setOtherInfo(pkInfo.getString("pkuid"), pkInfo.getString("pkuimg"), pkInfo.getString("pkuname")); 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); 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")) { } else if (!pkInfo.getString("end_pk_time").equals("0")) {
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {
mLiveRoomViewHolder.pkHandler = true;
mLiveRoomViewHolder.initPkRank(null); mLiveRoomViewHolder.initPkRank(null);
} }
LivePlayRyViewHolder.setViewUP(3); LivePlayRyViewHolder.setViewUP(3);