fix [卡片内的头像需要加直播状态&直播状态点击直播间]

This commit is contained in:
zlzw 2024-03-28 15:48:29 +08:00
parent c4117b80ee
commit df996435ec
2 changed files with 76 additions and 2 deletions

View File

@ -11,8 +11,13 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import com.alibaba.fastjson.JSON;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.message.content.MessageChatTipsContent;
import com.yunbao.common.utils.DateFormatUtil;
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.live.R;
import com.yunbao.live.event.InputPanelViewHolderEvent;
@ -21,6 +26,7 @@ import org.greenrobot.eventbus.EventBus;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import io.rong.common.RLog;
import io.rong.imkit.R.string;
@ -103,8 +109,33 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
} else if (!isSender) {
holder.getView(R.id.left_liveStatus).setVisibility(View.GONE);
}
holder.getView(R.id.left_liveStatus).setOnClickListener(view -> {
LiveHttpUtil.getLiveInfo(mDataList.get(position).getTargetId(), new com.yunbao.common.http.HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
if (liveBean == null) {
return;
}
if (holder.getView(R.id.right_liveStatus)!=null) {
liveBean.setParams(new HashMap<>());
new LiveRoomCheckLivePresenter(view.getContext(), liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
}
@Override
public void onCheckError(String contextError) {
}
});
}
}
});
});
}
if (holder.getView(R.id.right_liveStatus) != null) {
if (isRightLive && isSender) {
holder.getView(R.id.right_liveStatus).setVisibility(View.VISIBLE);
} else {
@ -114,5 +145,4 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
}
}

View File

@ -25,6 +25,7 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.GsonUtils;
@ -32,17 +33,20 @@ import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.activity.SelectImageActivity;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.ImageEntity;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.MessageUserInfoBean;
import com.yunbao.common.bean.NoviceInstructorModel;
import com.yunbao.common.bean.SetAttentsModel;
import com.yunbao.common.event.PDChatInputModeEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.LiveHttpUtil;
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.NoviceInstructorManager;
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
@ -66,6 +70,7 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import io.rong.imkit.IMCenter;
@ -301,6 +306,45 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
ViewUtils.findViewById(card, R.id.follow, Button.class).setVisibility(View.INVISIBLE);
}
getRemarkName();
LiveNetManager.get(mContext)
.getUserLiveStatus(targetId, new HttpCallback<List<Integer>>() {
@Override
public void onSuccess(List<Integer> data) {
if (data.contains(Integer.parseInt(targetId))) {
ViewUtils.findViewById(card, R.id.liveStatus).setVisibility(View.VISIBLE);
ViewUtils.findViewById(card, R.id.liveStatus).setOnClickListener(view -> {
LiveHttpUtil.getLiveInfo(targetId, new com.yunbao.common.http.HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
if (liveBean == null) {
return;
}
liveBean.setParams(new HashMap<>());
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
}
@Override
public void onCheckError(String contextError) {
}
});
}
}
});
});
}
}
@Override
public void onError(String error) {
}
});
}
@Override