From c25de1d25ee372eaeb4eac1de7e120a23a19cbc6 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 1 Sep 2022 17:56:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E6=99=82=E6=A6=9C=E9=80=B2=E5=85=A5?= =?UTF-8?q?=E7=9B=B4=E6=92=AD=E9=96=93=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/main/res/values-en/strings.xml | 1 + common/src/main/res/values/strings.xml | 3 +- .../live/activity/LiveAudienceActivity.java | 4 +- .../live/dialog/LiveHDDialogFragment.java | 142 +++++++++--------- .../live/views/PortraitLiveManager.java | 10 +- 5 files changed, 85 insertions(+), 75 deletions(-) diff --git a/common/src/main/res/values-en/strings.xml b/common/src/main/res/values-en/strings.xml index 2125c90dd..5c3cc7452 100644 --- a/common/src/main/res/values-en/strings.xml +++ b/common/src/main/res/values-en/strings.xml @@ -869,4 +869,5 @@ Limited ride And limited avatar frame Effect settings Shield gift effect Shield car effect + You are in the current live room diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 749000e2d..8748fdc6a 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -243,7 +243,7 @@ 收穫 觀看人數 關播中 - 一起来聊聊天吧~ + 一起來聊聊天吧~ 開啟彈幕, 請輸入房間密碼 @@ -882,4 +882,5 @@ 特效設置 屏蔽禮物特效 屏蔽座駕特效 + 您已在當前直播間 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 eca917db9..0d4f75635 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -293,7 +293,7 @@ public class LiveAudienceActivity extends LiveActivity { mStream = liveBean1.getStream(); mAncherName = liveBean1.getUserNiceName(); mAncherIcon = liveBean1.getAvatar(); - Log.e("收到socket--->", "mLiveUid--------------------------->" + mLiveUid); + Log.e(TAG, "mLiveUid--------------------------->" + mLiveUid); //加载当前页面数据 View rootView = manager.getRootView(); 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("landscape", liveBean.getLandscape()); -// intent.putExtra("isry", true); context.startActivity(intent); + } /** diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java index b53d052ee..f3a4d06d2 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveHDDialogFragment.java @@ -1,9 +1,5 @@ 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.graphics.Color; import android.os.Build; @@ -34,19 +30,27 @@ import com.yunbao.common.dialog.AbsDialogFragment; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.utils.L; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.ZhuangBanActivity; import com.yunbao.live.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 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 { private WebView mWebView; private int showType = 0; - private boolean isFullWindow=false; + private boolean isFullWindow = false; private String roomId; public LiveHDDialogFragment() { @@ -55,6 +59,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment { /** * 弹出全屏对话框 + * * @param isFullWindow 是否为全屏模式 */ public LiveHDDialogFragment(boolean isFullWindow) { @@ -82,48 +87,32 @@ public class LiveHDDialogFragment extends AbsDialogFragment { window.setWindowAnimations(R.style.bottomToTopAnim); WindowManager.LayoutParams params = window.getAttributes(); params.width = WindowManager.LayoutParams.MATCH_PARENT; - if(isFullWindow){ - Display display=null; - window.setLayout(WindowManager.LayoutParams.MATCH_PARENT,WindowManager.LayoutParams.MATCH_PARENT); - if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.R) { - display= requireContext().getDisplay(); + if (isFullWindow) { + Display display = null; + window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + display = requireContext().getDisplay(); window.getInsetsController().hide(WindowInsets.Type.statusBars()); window.getInsetsController().hide(WindowInsets.Type.navigationBars()); - }else { - display=window.getWindowManager().getDefaultDisplay(); + } else { + display = window.getWindowManager().getDefaultDisplay(); 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")); params.height = WindowManager.LayoutParams.MATCH_PARENT; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { window.getDecorView().setMinimumHeight(display.getMode().getPhysicalHeight()); window.getDecorView().setMinimumWidth(display.getMode().getPhysicalWidth()); } - window.getDecorView().setPadding(10,-10,0,0); - }else { + window.getDecorView().setPadding(10, -10, 0, 0); + } else { params.height = WindowManager.LayoutParams.WRAP_CONTENT; } params.gravity = Gravity.BOTTOM; 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 public void onActivityCreated(Bundle savedInstanceState) { @@ -146,19 +135,19 @@ public class LiveHDDialogFragment extends AbsDialogFragment { if (bundle == null) { return; } - roomId=bundle.getString("roomId",null); + roomId = bundle.getString("roomId", null); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } showType = bundle.getInt("show_type"); - if (showType==0){ + if (showType == 0) { findViewById(R.id.title_laout).setVisibility(View.GONE); - }else { + } else { findViewById(R.id.title_laout).setVisibility(View.VISIBLE); } - if(bundle.getInt("height",-1)!=-1) { - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, bundle.getInt("height",-1)); + if (bundle.getInt("height", -1) != -1) { + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, bundle.getInt("height", -1)); mWebView.setLayoutParams(params); } mWebView.loadUrl(bundle.getString("url")); @@ -182,7 +171,7 @@ public class LiveHDDialogFragment extends AbsDialogFragment { @JavascriptInterface 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(); } @@ -224,19 +213,34 @@ public class LiveHDDialogFragment extends AbsDialogFragment { dismiss(); ((LiveAudienceActivity) mContext).openGiftWindow(); } + @JavascriptInterface - public void androidGoBack(){ + public void androidGoBack() { dismiss(); } @JavascriptInterface 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 - public void androidClickToNewH5PageView(String url){ + public void androidClickToNewH5PageView(String url) { url = CommonAppConfig.HOST + url; url += "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + 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(); - LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", 0, liveSdk); - } - }); + private LiveRoomCheckLivePresenter mCheckLivePresenter; + + 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); } - } - }); + }); + } + } /** 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 21b88efad..54ea19439 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -166,7 +166,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe private LiveImDeletUtil liveImDeletUtil; private List greetings = new ArrayList<>(); private Handler liveHandler = new Handler(); - + //公共參數 + private OpenParametersModel openParametersModel = null; public PortraitLiveManager(Activity context, Intent intent) { this.mContext = context; @@ -204,6 +205,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) { + openParametersModel = new OpenParametersModel(); mContext.runOnUiThread(new Runnable() { @Override public void run() { @@ -217,7 +219,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe liveID = data.getUid(); Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS) - .setParametersModel(new OpenParametersModel() + .setParametersModel(openParametersModel .setmLiveType(mLiveType) .setmLiveTypeVal(mLiveTypeVal))); @@ -1031,7 +1033,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe //回传参数 Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS) - .setParametersModel(new OpenParametersModel().setmDanmuPrice(mDanmuPrice) + .setParametersModel(openParametersModel.setmDanmuPrice(mDanmuPrice) .setmSocketUserType(mSocketUserType) .setmChatLevel(mChatLevel) .setmDanMuLevel(mDanMuLevel) @@ -1209,7 +1211,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS) - .setParametersModel(new OpenParametersModel().setmLiveGuardInfo(mLiveGuardInfo) + .setParametersModel(openParametersModel.setmLiveGuardInfo(mLiveGuardInfo) .setFansNum(fansNum) .setIs_fans(is_fans))); if (mLiveRoomViewHolder != null) {