直播间的滚动修复直播间聊天问题

This commit is contained in:
18401019693 2022-08-22 14:31:30 +08:00
parent e102ea7899
commit 42a0440e6f
6 changed files with 56 additions and 26 deletions

View File

@ -6,6 +6,7 @@ import android.content.Context;
import android.net.http.HttpResponseCache;
import android.os.Bundle;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
@ -26,20 +27,19 @@ import com.tencent.imsdk.v2.V2TIMUserInfo;
import com.yunbao.common.BuildConfig;
import com.yunbao.common.CommonAppContext;
import com.yunbao.common.Constants;
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.L;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.utils.LiveImDeletUtil;
import com.yunbao.live.views.PortraitLiveManager;
import java.io.File;
import java.io.IOException;
import io.rong.imlib.IRongCoreListener;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
import io.rong.message.TextMessage;
import io.rong.push.RongPushClient;
import io.rong.push.pushconfig.PushConfig;
@ -178,7 +178,9 @@ public class AppContext extends CommonAppContext {
TextMessage content = (TextMessage) message.getContent();
if (content.getContent().contains("_method_")) {
msg.obj = content.getContent();
if (SocketRyClient.mSocketHandler != null) {
if (SocketRyClient.mSocketHandler != null
&& (TextUtils.equals("__system__", message.getTargetId())
|| (TextUtils.equals("g" + PortraitLiveManager.liveID, message.getTargetId())))) {
SocketRyClient.mSocketHandler.sendMessage(msg);
}
}

View File

@ -281,6 +281,7 @@ public class LiveAudienceActivity extends LiveActivity {
mLiveUid = mLiveBean.getUid();
mStream = mLiveBean.getStream();
mAncherName = liveBean.getUserNiceName();
Log.e("收到socket--->","mLiveUid--------------------------->"+mLiveUid);
//加载当前页面数据
View rootView = manager.getRootView();
if (rootView.getParent() != null && rootView.getParent() instanceof ViewGroup) {
@ -294,18 +295,13 @@ public class LiveAudienceActivity extends LiveActivity {
mCheckLivePresenter.checkLive(liveBean);
} else {
//直播间未直播
//主播未直播时自动下滑至下一个直播间
verticalViewPager.setCurrentItem(mCurrentPage + 1);
}
}
};
private void clearRoomData() {
}
/**
* 打开礼物窗口
*/
@ -649,7 +645,7 @@ public class LiveAudienceActivity extends LiveActivity {
LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE);
LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM);
LiveHttpUtil.cancel(LiveHttpConsts.ROOM_CHARGE);
clearRoomData();
manager.onRemove();
mLiveType = e.getLiveType();
mLiveTypeVal = e.getLiveTypeVal();
manager.onAdd(liveBean, mLiveType, mLiveTypeVal, mLiveSDK);

View File

@ -90,6 +90,7 @@ public class SocketRyClient {
// V2TIMManager.getInstance().
mLiveUid = null;
mStream = null;
mSocketHandler = null;
}
public static class SocketHandler extends Handler {
@ -103,6 +104,7 @@ public class SocketRyClient {
public void setLiveUid(String liveUid) {
mLiveUid = liveUid;
}
@Override

View File

@ -330,6 +330,12 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
public static Handler handler1 = new Handler();
public static Runnable runnable1;
public void removeCallbacks() {
handler .removeCallbacks(runnable);
handler .removeCallbacks(runnable1);
}
public void setLiveInfo(String liveUid, String stream, String urls, int isattention) {
mLiveUid = liveUid;
mStream = stream;

View File

@ -41,6 +41,7 @@ import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.custom.ItemDecoration;
import com.yunbao.common.custom.MyViewPager;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.main.MainNetManager;
@ -72,6 +73,7 @@ import com.yunbao.live.bean.WishlistModel;
import com.yunbao.live.dialog.BlowkissDialog;
import com.yunbao.live.dialog.NewUserDialog;
import com.yunbao.live.event.LinkMicTxAccEvent;
import com.yunbao.live.http.LiveHttpConsts;
import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
import com.yunbao.live.presenter.LiveLinkMicPkPresenter;
@ -102,6 +104,7 @@ import static com.yunbao.live.views.LiveRoomViewHolder.isStayRoomfive;
* 竖屏直播间UI逻辑
*/
public class PortraitLiveManager implements LivePlayListener, SocketMessageListener {
public static String liveID;
private Activity mContext;
private DrawerLayout mRootContainer;
//直播间插件父布局
@ -235,7 +238,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveSDK = liveSdk;
mLiveType = liveType;
mLiveTypeVal = liveTypeVal;
liveID = data.getUid();
if (mIntent.getIntExtra("isry", 0) == 1) {
mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0));
} else {
@ -331,6 +334,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (info.length > 0) {
String json = info[0];
WishlistModel model = GsonUtils.fromJson(json, WishlistModel.class);
if (mLiveRoomViewHolder != null && model != null)
mLiveRoomViewHolder.initWishList(model.getWishlist());
}
}
@ -345,16 +349,36 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override
public void onRemove() {
mLiveAudienceViewHolder.removeCallbacks();
//断开socket
if (!(mIntent.getIntExtra("isry", 0) == 1)) {
if (mSocketClient != null) {
mSocketClient.disConnect();
}
mSocketClient = null;
} else {
if (mSocketRyClient != null) {
mSocketRyClient.disConnect();
}
mSocketRyClient = null;
}
//结束播放
if (mLivePlayViewHolder != null) {
mLivePlayViewHolder.release();
}
mLivePlayViewHolder = null;
LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE);
LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM);
LiveHttpUtil.cancel(LiveHttpConsts.ROOM_CHARGE);
CommonHttpUtil.cancel(CommonHttpConsts.GET_BALANCE);
CommonHttpUtil.cancel(LiveHttpConsts.GET_WISH_LIST);
if (mSocketClient != null) {
mSocketClient.disConnect();
mSocketClient = null;
}
if (mSocketRyClient != null) {
mSocketRyClient.disConnect();
mSocketRyClient = null;
}
if (mLivePlayViewHolder != null) {
mLivePlayViewHolder.stopPlay();
@ -994,7 +1018,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
}
}
if (obj.getString("isleave").equals("1")) {
if (TextUtils.equals(obj.getString("isleave"), "1")) {
if (LivePlayKsyViewHolder.leave != null) {
LivePlayKsyViewHolder.leave.setVisibility(View.VISIBLE);
}

View File

@ -20,7 +20,7 @@
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#60000000" />
android:background="#70000000" />
<FrameLayout
android:id="@+id/play_container"