Js调用原生整改,主播踢人不退出房间问题修改
This commit is contained in:
@@ -2,7 +2,6 @@ package com.yunbao.live.dialog;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.logger;
|
||||
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
|
||||
import static com.yunbao.common.utils.RouteUtil.PATH_COIN;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
@@ -26,16 +25,20 @@ import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.adjust.sdk.Adjust;
|
||||
import com.adjust.sdk.AdjustEvent;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.JsWishBean;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.dialog.AbsDialogFragment;
|
||||
import com.yunbao.common.event.JavascriptInterfaceEvent;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
@@ -45,12 +48,13 @@ import com.yunbao.live.activity.LiveActivity;
|
||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||
import com.yunbao.live.activity.LiveRyAnchorActivity;
|
||||
import com.yunbao.live.activity.ZhuangBanActivity;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.live.event.LiveRoomChangeEvent;
|
||||
import com.yunbao.live.http.LiveHttpUtil;
|
||||
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
public class LiveHDDialogFragment extends AbsDialogFragment {
|
||||
|
||||
@@ -124,6 +128,17 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
|
||||
window.setAttributes(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
Bus.getOff(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Bus.getOn(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
@@ -199,21 +214,8 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
@JavascriptInterface
|
||||
public void androidGoTopUp() {
|
||||
|
||||
ARouter.getInstance().build(PATH_COIN).withInt("p", 0).withString("tag", "&first_page=1").navigation();
|
||||
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public String androidMethod(String data) {
|
||||
if (data != null && !data.isEmpty()) {
|
||||
onTrickerySendGiftInto(new JsWishBean(data));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void AndroidAdjustPrank() {
|
||||
@@ -383,4 +385,17 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
|
||||
mWebView.destroy();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onJavascriptInterfaceEvent(JavascriptInterfaceEvent event) {
|
||||
if (!TextUtils.isEmpty(event.getMethod())) {
|
||||
if (TextUtils.equals(event.getMethod(), "androidGoTopUp")) {
|
||||
dismiss();
|
||||
} else if (TextUtils.equals(event.getMethod(), "androidMethod")) {
|
||||
if (event.getData() != null && !event.getData().isEmpty()) {
|
||||
onTrickerySendGiftInto(new JsWishBean(event.getData()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -185,6 +185,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
|
||||
//是否成功调用进入房间接口
|
||||
private boolean isEnterRoom = false;
|
||||
private boolean kick = false;
|
||||
|
||||
public PortraitLiveManager setQuitF(boolean quitF) {
|
||||
isQuitF = quitF;
|
||||
@@ -319,7 +320,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
CommonHttpUtil.cancel(LiveHttpConsts.GET_WISH_LIST);
|
||||
IMLoginManager.get(mContext).setisNewUserOne(false);
|
||||
//子线程执行退出操作
|
||||
exitLiveRoom();
|
||||
exitLiveRoom(false);
|
||||
if (mLiveAudienceViewHolder != null) {
|
||||
mLiveAudienceViewHolder.removeFromParent();
|
||||
mLiveAudienceViewHolder.removeCallbacks();
|
||||
@@ -371,13 +372,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
}
|
||||
if (isQuit) {
|
||||
isQuitF = true;
|
||||
if (PermissionUtils.checkPermission(mContext)) {
|
||||
if (PermissionUtils.checkPermission(mContext) && !kick) {
|
||||
LiveFloatView.getInstance()
|
||||
.cacheLiveData(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal)
|
||||
.builderSystemFloat(mContext, mLiveBean.getPull());
|
||||
mContext.finish();
|
||||
} else {
|
||||
if (IMLoginManager.get(mContext).isFloat()) {
|
||||
if (IMLoginManager.get(mContext).isFloat() && !kick) {
|
||||
EventBus.getDefault()
|
||||
.post(new LiveFloatEvent()
|
||||
.setmLiveBean(mLiveBean)
|
||||
@@ -772,7 +773,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
@Override
|
||||
public void onKick(String touid) {
|
||||
if (!TextUtils.isEmpty(touid) && touid.equals(CommonAppConfig.getInstance().getUid())) {//被踢的是自己
|
||||
exitLiveRoom();
|
||||
kick = true;
|
||||
exitLiveRoom(true);
|
||||
ToastUtil.show(WordUtil.getString(R.string.live_kicked_2));
|
||||
}
|
||||
}
|
||||
@@ -1414,7 +1416,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
}
|
||||
}
|
||||
} else {
|
||||
exitLiveRoom();
|
||||
exitLiveRoom(false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1422,7 +1424,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
/**
|
||||
* 退出直播间
|
||||
*/
|
||||
public void exitLiveRoom() {
|
||||
public void exitLiveRoom(boolean isQuitF) {
|
||||
if (mLiveBean == null && !isEnterRoom) {
|
||||
return;
|
||||
}
|
||||
@@ -1434,6 +1436,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
LiveHttpUtil.qBackRoom(mLiveBean.getUid(), mLiveBean.getStream(), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (isQuitF) {
|
||||
onRemove(true);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
@@ -1471,9 +1476,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
}
|
||||
}
|
||||
|
||||
// public void openDrawer() {
|
||||
// drawerLayout.openDrawer(GravityCompat.END);
|
||||
// }
|
||||
|
||||
public void onLinkMicTxAccEvent(LinkMicTxAccEvent e) {
|
||||
if (mLivePlayViewHolder != null && mLivePlayViewHolder instanceof LivePlayTxViewHolder) {
|
||||
@@ -1543,7 +1545,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
||||
|
||||
@Override
|
||||
public void onCancelClick() {
|
||||
exitLiveRoom();
|
||||
exitLiveRoom(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user