diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java
index 2c9571b8b..d08d84b24 100644
--- a/app/src/main/java/com/shayu/phonelive/AppContext.java
+++ b/app/src/main/java/com/shayu/phonelive/AppContext.java
@@ -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,12 +178,14 @@ 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);
}
}
}
- }catch (Exception e){
+ } catch (Exception e) {
}
return false;
diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
index 1ec5d9e1c..c0bdf86c8 100644
--- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
+++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java
@@ -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);
diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
index a8128dc89..a5751c5fb 100644
--- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
+++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java
@@ -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
@@ -260,7 +262,7 @@ public class SocketRyClient {
}
//創建了多人房間
} else if (action3 == 3) {
- if ( LiveAudienceActivity.getmLivePlayViewHolder() != null) {
+ if (LiveAudienceActivity.getmLivePlayViewHolder() != null) {
LiveAudienceActivity.getmLivePlayViewHolder().setPkview();
}
isDRPK = 1;
@@ -309,7 +311,7 @@ public class SocketRyClient {
int action = map.getIntValue("action");
if (action == 18) {
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) {
mListener.onAnchorInvalid();
}
diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java
index 47a5243d2..f7e4e2ed5 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java
@@ -77,7 +77,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
private TextView goToRomm;
private int icon = 0;
private String nobleName, nobleTtext;
- private ImageView giftImage,liveNewPeople;
+ private ImageView giftImage, liveNewPeople;
public LiveAudienceViewHolder(Context context, ViewGroup parentView) {
super(context, parentView);
@@ -321,7 +321,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder {
Locale locale = mContext.getResources().getConfiguration().locale;
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();
@@ -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;
diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
index ce3e93217..93258a0a3 100644
--- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
+++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java
@@ -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,7 +334,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (info.length > 0) {
String json = info[0];
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
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);
}
diff --git a/live/src/main/res/layout/activity_live_audience.xml b/live/src/main/res/layout/activity_live_audience.xml
index 7dd19fd7d..dd32068e3 100644
--- a/live/src/main/res/layout/activity_live_audience.xml
+++ b/live/src/main/res/layout/activity_live_audience.xml
@@ -20,7 +20,7 @@
+ android:background="#70000000" />