diff --git a/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java b/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java index 5b2f9db7d..2d0d7045c 100644 --- a/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java +++ b/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java @@ -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; + } + 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 (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 { } - } diff --git a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java index 06d20ecdb..9a3416d8e 100644 --- a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationActivity.java @@ -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>() { + @Override + public void onSuccess(List 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