小時榜進入直播間問題

This commit is contained in:
18401019693 2022-09-01 17:56:40 +08:00
parent bb81bd380d
commit c25de1d25e
5 changed files with 85 additions and 75 deletions

View File

@ -869,4 +869,5 @@ Limited ride And limited avatar frame</string>
<string name="effects_settings">Effect settings</string> <string name="effects_settings">Effect settings</string>
<string name="shield_gift_effect">Shield gift effect</string> <string name="shield_gift_effect">Shield gift effect</string>
<string name="shield_mount_effect">Shield car effect</string> <string name="shield_mount_effect">Shield car effect</string>
<string name="current_live_room">You are in the current live room</string>
</resources> </resources>

View File

@ -243,7 +243,7 @@
<string name="live_votes">收穫</string> <string name="live_votes">收穫</string>
<string name="live_watch_num">觀看人數</string> <string name="live_watch_num">觀看人數</string>
<string name="live_end_ing">關播中</string> <string name="live_end_ing">關播中</string>
<string name="live_say_something">一起聊聊天吧~</string> <string name="live_say_something">一起聊聊天吧~</string>
<string name="live_open_alba">開啟彈幕,</string> <string name="live_open_alba">開啟彈幕,</string>
<string name="live_tiao"></string> <string name="live_tiao"></string>
<string name="live_input_password">請輸入房間密碼</string> <string name="live_input_password">請輸入房間密碼</string>
@ -882,4 +882,5 @@
<string name="effects_settings">特效設置</string> <string name="effects_settings">特效設置</string>
<string name="shield_gift_effect">屏蔽禮物特效</string> <string name="shield_gift_effect">屏蔽禮物特效</string>
<string name="shield_mount_effect">屏蔽座駕特效</string> <string name="shield_mount_effect">屏蔽座駕特效</string>
<string name="current_live_room">您已在當前直播間</string>
</resources> </resources>

View File

@ -293,7 +293,7 @@ public class LiveAudienceActivity extends LiveActivity {
mStream = liveBean1.getStream(); mStream = liveBean1.getStream();
mAncherName = liveBean1.getUserNiceName(); mAncherName = liveBean1.getUserNiceName();
mAncherIcon = liveBean1.getAvatar(); mAncherIcon = liveBean1.getAvatar();
Log.e("收到socket--->", "mLiveUid--------------------------->" + mLiveUid); Log.e(TAG, "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) {
@ -796,8 +796,8 @@ public class LiveAudienceActivity extends LiveActivity {
intent.putExtra(Constants.LIVE_SDK, liveSdk); intent.putExtra(Constants.LIVE_SDK, liveSdk);
intent.putExtra(Constants.LIVE_SDK, liveSdk); intent.putExtra(Constants.LIVE_SDK, liveSdk);
intent.putExtra("landscape", liveBean.getLandscape()); intent.putExtra("landscape", liveBean.getLandscape());
// intent.putExtra("isry", true);
context.startActivity(intent); context.startActivity(intent);
} }
/** /**

View File

@ -1,9 +1,5 @@
package com.yunbao.live.dialog; 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.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.os.Build; import android.os.Build;
@ -34,19 +30,27 @@ import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.utils.L; import com.yunbao.common.utils.L;
import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R; import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.LiveAudienceActivity;
import com.yunbao.live.activity.ZhuangBanActivity; import com.yunbao.live.activity.ZhuangBanActivity;
import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.LiveBean;
import com.yunbao.live.event.LiveRoomChangeEvent;
import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.http.LiveHttpUtil;
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
import org.greenrobot.eventbus.EventBus;
import static com.yunbao.common.CommonAppContext.logger;
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
import static com.yunbao.common.utils.RouteUtil.PATH_COIN;
public class LiveHDDialogFragment extends AbsDialogFragment { public class LiveHDDialogFragment extends AbsDialogFragment {
private WebView mWebView; private WebView mWebView;
private int showType = 0; private int showType = 0;
private boolean isFullWindow=false; private boolean isFullWindow = false;
private String roomId; private String roomId;
public LiveHDDialogFragment() { public LiveHDDialogFragment() {
@ -55,6 +59,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
/** /**
* 弹出全屏对话框 * 弹出全屏对话框
*
* @param isFullWindow 是否为全屏模式 * @param isFullWindow 是否为全屏模式
*/ */
public LiveHDDialogFragment(boolean isFullWindow) { public LiveHDDialogFragment(boolean isFullWindow) {
@ -82,48 +87,32 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
window.setWindowAnimations(R.style.bottomToTopAnim); window.setWindowAnimations(R.style.bottomToTopAnim);
WindowManager.LayoutParams params = window.getAttributes(); WindowManager.LayoutParams params = window.getAttributes();
params.width = WindowManager.LayoutParams.MATCH_PARENT; params.width = WindowManager.LayoutParams.MATCH_PARENT;
if(isFullWindow){ if (isFullWindow) {
Display display=null; Display display = null;
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.MATCH_PARENT); window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
display= requireContext().getDisplay(); display = requireContext().getDisplay();
window.getInsetsController().hide(WindowInsets.Type.statusBars()); window.getInsetsController().hide(WindowInsets.Type.statusBars());
window.getInsetsController().hide(WindowInsets.Type.navigationBars()); window.getInsetsController().hide(WindowInsets.Type.navigationBars());
}else { } else {
display=window.getWindowManager().getDefaultDisplay(); display = window.getWindowManager().getDefaultDisplay();
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
} }
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT); window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
window.getDecorView().setBackgroundColor(Color.parseColor("#10000000")); window.getDecorView().setBackgroundColor(Color.parseColor("#10000000"));
params.height = WindowManager.LayoutParams.MATCH_PARENT; params.height = WindowManager.LayoutParams.MATCH_PARENT;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
window.getDecorView().setMinimumHeight(display.getMode().getPhysicalHeight()); window.getDecorView().setMinimumHeight(display.getMode().getPhysicalHeight());
window.getDecorView().setMinimumWidth(display.getMode().getPhysicalWidth()); window.getDecorView().setMinimumWidth(display.getMode().getPhysicalWidth());
} }
window.getDecorView().setPadding(10,-10,0,0); window.getDecorView().setPadding(10, -10, 0, 0);
}else { } else {
params.height = WindowManager.LayoutParams.WRAP_CONTENT; params.height = WindowManager.LayoutParams.WRAP_CONTENT;
} }
params.gravity = Gravity.BOTTOM; params.gravity = Gravity.BOTTOM;
window.setAttributes(params); window.setAttributes(params);
} }
// @Override
// public void onStart() {
// super.onStart();
//// Window window = getDialog().getWindow();
//// window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//// WindowManager.LayoutParams windowParams = window.getAttributes();
//// windowParams.dimAmount = 0.0f;
//// windowParams.y = 100;
//// window.setAttributes(windowParams);
//// Dialog dialog = getDialog();
//// if (dialog != null) {
//// DisplayMetrics dm = new DisplayMetrics();
//// getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
//// dialog.getWindow().setLayout((int) (dm.widthPixels), (int) (dm.heightPixels * (showType == 0 ? 0.5 : 1)));
//// }
// }
@Override @Override
public void onActivityCreated(Bundle savedInstanceState) { public void onActivityCreated(Bundle savedInstanceState) {
@ -146,19 +135,19 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
if (bundle == null) { if (bundle == null) {
return; return;
} }
roomId=bundle.getString("roomId",null); roomId = bundle.getString("roomId", null);
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
} }
showType = bundle.getInt("show_type"); showType = bundle.getInt("show_type");
if (showType==0){ if (showType == 0) {
findViewById(R.id.title_laout).setVisibility(View.GONE); findViewById(R.id.title_laout).setVisibility(View.GONE);
}else { } else {
findViewById(R.id.title_laout).setVisibility(View.VISIBLE); findViewById(R.id.title_laout).setVisibility(View.VISIBLE);
} }
if(bundle.getInt("height",-1)!=-1) { if (bundle.getInt("height", -1) != -1) {
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, bundle.getInt("height",-1)); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, bundle.getInt("height", -1));
mWebView.setLayoutParams(params); mWebView.setLayoutParams(params);
} }
mWebView.loadUrl(bundle.getString("url")); mWebView.loadUrl(bundle.getString("url"));
@ -182,7 +171,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
@JavascriptInterface @JavascriptInterface
public void androidGoTopUp() { public void androidGoTopUp() {
ARouter.getInstance().build(PATH_COIN).withInt("p", 0).withString("tag", "&first_page=1").navigation(); ARouter.getInstance().build(PATH_COIN).withInt("p", 0).withString("tag", "&first_page=1").navigation();
dismiss(); dismiss();
} }
@ -224,19 +213,34 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
dismiss(); dismiss();
((LiveAudienceActivity) mContext).openGiftWindow(); ((LiveAudienceActivity) mContext).openGiftWindow();
} }
@JavascriptInterface @JavascriptInterface
public void androidGoBack(){ public void androidGoBack() {
dismiss(); dismiss();
} }
@JavascriptInterface @JavascriptInterface
public void androidMethodLookToLive(String liveId) { public void androidMethodLookToLive(String liveId) {
//看直播
gotoLive(liveId); mWebView.post(new Runnable() {
@Override
public void run() {
if (TextUtils.equals(roomId, liveId)) {
ToastUtil.show(R.string.current_live_room);
dismiss();
} else {
//看直播
gotoLive(liveId);
}
}
});
} }
@JavascriptInterface @JavascriptInterface
public void androidClickToNewH5PageView(String url){ public void androidClickToNewH5PageView(String url) {
url = CommonAppConfig.HOST + url; url = CommonAppConfig.HOST + url;
url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token="
+ CommonAppConfig.getInstance().getToken(); + CommonAppConfig.getInstance().getToken();
@ -248,36 +252,38 @@ public class LiveHDDialogFragment extends AbsDialogFragment {
} }
} }
private LiveRoomCheckLivePresenter mCheckLivePresenter;
private void gotoLive(final String live_id) {
if(roomId!=null&&roomId.equals(live_id)){
return;
}
LiveHttpUtil.getLiveInfo(live_id, new 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);
LiveRoomCheckLivePresenter.isRoom = false;
if (mCheckLivePresenter == null) {
mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, new LiveRoomCheckLivePresenter.ActionListener() {
@Override
public void onLiveRoomChanged(LiveBean liveBean, int liveType, int liveTypeVal, int liveSdk) {
if (liveBean == null) {
return;
}
((LiveAudienceActivity) mContext).finish(); private LiveRoomCheckLivePresenter mCheckLivePresenter;
LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk);
} private void gotoLive(final String live_id) {
}); if (!TextUtils.equals(roomId, live_id)) {
LiveHttpUtil.getLiveInfo(live_id, new 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 (mCheckLivePresenter == null) {
LiveRoomCheckLivePresenter.isRoom = false;
mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, new LiveRoomCheckLivePresenter.ActionListener() {
@Override
public void onLiveRoomChanged(LiveBean liveBean, int liveType, int liveTypeVal, int liveSdk) {
if (liveBean == null) {
return;
}
dismiss();
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, liveTypeVal));
}
});
}
mCheckLivePresenter.checkLive(liveBean);
} else {
RouteUtil.forwardUserHome(mContext, live_id, 0);
} }
mCheckLivePresenter.checkLive(liveBean);
} else {
RouteUtil.forwardUserHome(mContext, live_id, 0);
} }
} });
}); }
} }
/** /**

View File

@ -166,7 +166,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
private LiveImDeletUtil liveImDeletUtil; private LiveImDeletUtil liveImDeletUtil;
private List<String> greetings = new ArrayList<>(); private List<String> greetings = new ArrayList<>();
private Handler liveHandler = new Handler(); private Handler liveHandler = new Handler();
//公共參數
private OpenParametersModel openParametersModel = null;
public PortraitLiveManager(Activity context, Intent intent) { public PortraitLiveManager(Activity context, Intent intent) {
this.mContext = context; this.mContext = context;
@ -204,6 +205,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override @Override
public void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) { public void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) {
openParametersModel = new OpenParametersModel();
mContext.runOnUiThread(new Runnable() { mContext.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -217,7 +219,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
liveID = data.getUid(); liveID = data.getUid();
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS) .setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS)
.setParametersModel(new OpenParametersModel() .setParametersModel(openParametersModel
.setmLiveType(mLiveType) .setmLiveType(mLiveType)
.setmLiveTypeVal(mLiveTypeVal))); .setmLiveTypeVal(mLiveTypeVal)));
@ -1031,7 +1033,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
//回传参数 //回传参数
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS) .setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS)
.setParametersModel(new OpenParametersModel().setmDanmuPrice(mDanmuPrice) .setParametersModel(openParametersModel.setmDanmuPrice(mDanmuPrice)
.setmSocketUserType(mSocketUserType) .setmSocketUserType(mSocketUserType)
.setmChatLevel(mChatLevel) .setmChatLevel(mChatLevel)
.setmDanMuLevel(mDanMuLevel) .setmDanMuLevel(mDanMuLevel)
@ -1209,7 +1211,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
} }
Bus.get().post(new LiveAudienceEvent() Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS) .setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS)
.setParametersModel(new OpenParametersModel().setmLiveGuardInfo(mLiveGuardInfo) .setParametersModel(openParametersModel.setmLiveGuardInfo(mLiveGuardInfo)
.setFansNum(fansNum) .setFansNum(fansNum)
.setIs_fans(is_fans))); .setIs_fans(is_fans)));
if (mLiveRoomViewHolder != null) { if (mLiveRoomViewHolder != null) {