直播间的滚动修复直播间聊天问题
This commit is contained in:
parent
e102ea7899
commit
42a0440e6f
@ -6,6 +6,7 @@ import android.content.Context;
|
|||||||
import android.net.http.HttpResponseCache;
|
import android.net.http.HttpResponseCache;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -26,20 +27,19 @@ import com.tencent.imsdk.v2.V2TIMUserInfo;
|
|||||||
import com.yunbao.common.BuildConfig;
|
import com.yunbao.common.BuildConfig;
|
||||||
import com.yunbao.common.CommonAppContext;
|
import com.yunbao.common.CommonAppContext;
|
||||||
import com.yunbao.common.Constants;
|
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.CommonHttpUtil;
|
||||||
import com.yunbao.common.http.HttpCallback;
|
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.common.utils.L;
|
||||||
import com.yunbao.live.socket.SocketRyClient;
|
import com.yunbao.live.socket.SocketRyClient;
|
||||||
import com.yunbao.live.utils.LiveImDeletUtil;
|
import com.yunbao.live.utils.LiveImDeletUtil;
|
||||||
|
import com.yunbao.live.views.PortraitLiveManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import io.rong.imlib.IRongCoreListener;
|
|
||||||
import io.rong.imlib.RongIMClient;
|
import io.rong.imlib.RongIMClient;
|
||||||
import io.rong.imlib.model.Conversation;
|
|
||||||
import io.rong.message.TextMessage;
|
import io.rong.message.TextMessage;
|
||||||
import io.rong.push.RongPushClient;
|
import io.rong.push.RongPushClient;
|
||||||
import io.rong.push.pushconfig.PushConfig;
|
import io.rong.push.pushconfig.PushConfig;
|
||||||
@ -178,12 +178,14 @@ public class AppContext extends CommonAppContext {
|
|||||||
TextMessage content = (TextMessage) message.getContent();
|
TextMessage content = (TextMessage) message.getContent();
|
||||||
if (content.getContent().contains("_method_")) {
|
if (content.getContent().contains("_method_")) {
|
||||||
msg.obj = content.getContent();
|
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);
|
SocketRyClient.mSocketHandler.sendMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -281,6 +281,7 @@ public class LiveAudienceActivity extends LiveActivity {
|
|||||||
mLiveUid = mLiveBean.getUid();
|
mLiveUid = mLiveBean.getUid();
|
||||||
mStream = mLiveBean.getStream();
|
mStream = mLiveBean.getStream();
|
||||||
mAncherName = liveBean.getUserNiceName();
|
mAncherName = liveBean.getUserNiceName();
|
||||||
|
Log.e("收到socket--->","mLiveUid--------------------------->"+mLiveUid);
|
||||||
//加载当前页面数据
|
//加载当前页面数据
|
||||||
View rootView = manager.getRootView();
|
View rootView = manager.getRootView();
|
||||||
if (rootView.getParent() != null && rootView.getParent() instanceof ViewGroup) {
|
if (rootView.getParent() != null && rootView.getParent() instanceof ViewGroup) {
|
||||||
@ -294,18 +295,13 @@ public class LiveAudienceActivity extends LiveActivity {
|
|||||||
|
|
||||||
mCheckLivePresenter.checkLive(liveBean);
|
mCheckLivePresenter.checkLive(liveBean);
|
||||||
} else {
|
} 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.CHECK_LIVE);
|
||||||
LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM);
|
LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM);
|
||||||
LiveHttpUtil.cancel(LiveHttpConsts.ROOM_CHARGE);
|
LiveHttpUtil.cancel(LiveHttpConsts.ROOM_CHARGE);
|
||||||
clearRoomData();
|
manager.onRemove();
|
||||||
mLiveType = e.getLiveType();
|
mLiveType = e.getLiveType();
|
||||||
mLiveTypeVal = e.getLiveTypeVal();
|
mLiveTypeVal = e.getLiveTypeVal();
|
||||||
manager.onAdd(liveBean, mLiveType, mLiveTypeVal, mLiveSDK);
|
manager.onAdd(liveBean, mLiveType, mLiveTypeVal, mLiveSDK);
|
||||||
|
@ -90,6 +90,7 @@ public class SocketRyClient {
|
|||||||
// V2TIMManager.getInstance().
|
// V2TIMManager.getInstance().
|
||||||
mLiveUid = null;
|
mLiveUid = null;
|
||||||
mStream = null;
|
mStream = null;
|
||||||
|
mSocketHandler = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SocketHandler extends Handler {
|
public static class SocketHandler extends Handler {
|
||||||
@ -103,6 +104,7 @@ public class SocketRyClient {
|
|||||||
|
|
||||||
public void setLiveUid(String liveUid) {
|
public void setLiveUid(String liveUid) {
|
||||||
mLiveUid = liveUid;
|
mLiveUid = liveUid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -260,7 +262,7 @@ public class SocketRyClient {
|
|||||||
}
|
}
|
||||||
//創建了多人房間
|
//創建了多人房間
|
||||||
} else if (action3 == 3) {
|
} else if (action3 == 3) {
|
||||||
if ( LiveAudienceActivity.getmLivePlayViewHolder() != null) {
|
if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
|
||||||
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
|
||||||
}
|
}
|
||||||
isDRPK = 1;
|
isDRPK = 1;
|
||||||
@ -309,7 +311,7 @@ public class SocketRyClient {
|
|||||||
int action = map.getIntValue("action");
|
int action = map.getIntValue("action");
|
||||||
if (action == 18) {
|
if (action == 18) {
|
||||||
mListener.onLiveEnd();
|
mListener.onLiveEnd();
|
||||||
LiveEndViewHolder.upData(map.getString("votes"), map.getString("length"), map.getIntValue("nums"),map.getString("uname"));
|
LiveEndViewHolder.upData(map.getString("votes"), map.getString("length"), map.getIntValue("nums"), map.getString("uname"));
|
||||||
} else if (action == 19) {
|
} else if (action == 19) {
|
||||||
mListener.onAnchorInvalid();
|
mListener.onAnchorInvalid();
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
|||||||
private TextView goToRomm;
|
private TextView goToRomm;
|
||||||
private int icon = 0;
|
private int icon = 0;
|
||||||
private String nobleName, nobleTtext;
|
private String nobleName, nobleTtext;
|
||||||
private ImageView giftImage,liveNewPeople;
|
private ImageView giftImage, liveNewPeople;
|
||||||
|
|
||||||
public LiveAudienceViewHolder(Context context, ViewGroup parentView) {
|
public LiveAudienceViewHolder(Context context, ViewGroup parentView) {
|
||||||
super(context, parentView);
|
super(context, parentView);
|
||||||
@ -321,7 +321,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
|||||||
Locale locale = mContext.getResources().getConfiguration().locale;
|
Locale locale = mContext.getResources().getConfiguration().locale;
|
||||||
String language = locale.getLanguage();
|
String language = locale.getLanguage();
|
||||||
|
|
||||||
ImgLoader.display(mContext,TextUtils.equals(language, "zh")?R.mipmap.live_icon_new_people_cn:R.mipmap.live_icon_newpeople_en,liveNewPeople);
|
ImgLoader.display(mContext, TextUtils.equals(language, "zh") ? R.mipmap.live_icon_new_people_cn : R.mipmap.live_icon_newpeople_en, liveNewPeople);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Handler handler = new Handler();
|
public static Handler handler = new Handler();
|
||||||
@ -330,6 +330,12 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
|
|||||||
public static Handler handler1 = new Handler();
|
public static Handler handler1 = new Handler();
|
||||||
public static Runnable runnable1;
|
public static Runnable runnable1;
|
||||||
|
|
||||||
|
|
||||||
|
public void removeCallbacks() {
|
||||||
|
handler .removeCallbacks(runnable);
|
||||||
|
handler .removeCallbacks(runnable1);
|
||||||
|
}
|
||||||
|
|
||||||
public void setLiveInfo(String liveUid, String stream, String urls, int isattention) {
|
public void setLiveInfo(String liveUid, String stream, String urls, int isattention) {
|
||||||
mLiveUid = liveUid;
|
mLiveUid = liveUid;
|
||||||
mStream = stream;
|
mStream = stream;
|
||||||
|
@ -41,6 +41,7 @@ import com.yunbao.common.custom.CommonRefreshView;
|
|||||||
import com.yunbao.common.custom.ItemDecoration;
|
import com.yunbao.common.custom.ItemDecoration;
|
||||||
import com.yunbao.common.custom.MyViewPager;
|
import com.yunbao.common.custom.MyViewPager;
|
||||||
import com.yunbao.common.glide.ImgLoader;
|
import com.yunbao.common.glide.ImgLoader;
|
||||||
|
import com.yunbao.common.http.CommonHttpConsts;
|
||||||
import com.yunbao.common.http.CommonHttpUtil;
|
import com.yunbao.common.http.CommonHttpUtil;
|
||||||
import com.yunbao.common.http.HttpCallback;
|
import com.yunbao.common.http.HttpCallback;
|
||||||
import com.yunbao.common.http.main.MainNetManager;
|
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.BlowkissDialog;
|
||||||
import com.yunbao.live.dialog.NewUserDialog;
|
import com.yunbao.live.dialog.NewUserDialog;
|
||||||
import com.yunbao.live.event.LinkMicTxAccEvent;
|
import com.yunbao.live.event.LinkMicTxAccEvent;
|
||||||
|
import com.yunbao.live.http.LiveHttpConsts;
|
||||||
import com.yunbao.live.http.LiveHttpUtil;
|
import com.yunbao.live.http.LiveHttpUtil;
|
||||||
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
|
import com.yunbao.live.presenter.LiveLinkMicAnchorPresenter;
|
||||||
import com.yunbao.live.presenter.LiveLinkMicPkPresenter;
|
import com.yunbao.live.presenter.LiveLinkMicPkPresenter;
|
||||||
@ -102,6 +104,7 @@ import static com.yunbao.live.views.LiveRoomViewHolder.isStayRoomfive;
|
|||||||
* 竖屏直播间UI逻辑
|
* 竖屏直播间UI逻辑
|
||||||
*/
|
*/
|
||||||
public class PortraitLiveManager implements LivePlayListener, SocketMessageListener {
|
public class PortraitLiveManager implements LivePlayListener, SocketMessageListener {
|
||||||
|
public static String liveID;
|
||||||
private Activity mContext;
|
private Activity mContext;
|
||||||
private DrawerLayout mRootContainer;
|
private DrawerLayout mRootContainer;
|
||||||
//直播间插件父布局
|
//直播间插件父布局
|
||||||
@ -235,7 +238,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
|||||||
mLiveSDK = liveSdk;
|
mLiveSDK = liveSdk;
|
||||||
mLiveType = liveType;
|
mLiveType = liveType;
|
||||||
mLiveTypeVal = liveTypeVal;
|
mLiveTypeVal = liveTypeVal;
|
||||||
|
liveID = data.getUid();
|
||||||
if (mIntent.getIntExtra("isry", 0) == 1) {
|
if (mIntent.getIntExtra("isry", 0) == 1) {
|
||||||
mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0));
|
mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0));
|
||||||
} else {
|
} else {
|
||||||
@ -331,7 +334,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
|||||||
if (info.length > 0) {
|
if (info.length > 0) {
|
||||||
String json = info[0];
|
String json = info[0];
|
||||||
WishlistModel model = GsonUtils.fromJson(json, WishlistModel.class);
|
WishlistModel model = GsonUtils.fromJson(json, WishlistModel.class);
|
||||||
mLiveRoomViewHolder.initWishList(model.getWishlist());
|
if (mLiveRoomViewHolder != null && model != null)
|
||||||
|
mLiveRoomViewHolder.initWishList(model.getWishlist());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,16 +349,36 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemove() {
|
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) {
|
if (mSocketClient != null) {
|
||||||
|
|
||||||
mSocketClient.disConnect();
|
mSocketClient.disConnect();
|
||||||
mSocketClient = null;
|
mSocketClient = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (mSocketRyClient != null) {
|
|
||||||
mSocketRyClient.disConnect();
|
|
||||||
mSocketRyClient = null;
|
|
||||||
}
|
|
||||||
if (mLivePlayViewHolder != null) {
|
if (mLivePlayViewHolder != null) {
|
||||||
|
|
||||||
mLivePlayViewHolder.stopPlay();
|
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) {
|
if (LivePlayKsyViewHolder.leave != null) {
|
||||||
LivePlayKsyViewHolder.leave.setVisibility(View.VISIBLE);
|
LivePlayKsyViewHolder.leave.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#60000000" />
|
android:background="#70000000" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/play_container"
|
android:id="@+id/play_container"
|
||||||
|
Loading…
Reference in New Issue
Block a user