修复测试反馈的问题:上下滑动直播间会带着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.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;
@ -481,6 +482,25 @@ public class LiveNetManager {
}).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) {
enterRoomDisposable.dispose();
}
if (randomPkApi != null) {
randomPkApi.dispose();
}
}
}

View File

@ -1626,14 +1626,11 @@ 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();
LiveNetManager.get(mContext)
.getRandomPk(mLiveUid, pkUid, new com.yunbao.common.http.base.HttpCallback<PkRankBean>() {
@Override
public void onSuccess(PkRankBean bean) {
if (bean != null) {
Log.i("PK", bean.toString() + " | " + isLadders);
initPkRankView(bean);
if (!StringUtil.isEmpty(bean.getClickUrl())) {
pkRankVf.setOnClickListener(v -> {
@ -1664,7 +1661,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
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())) {
@ -1684,8 +1681,13 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
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;

View File

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