diff --git a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java index 84b5d37dc..ea5ee467c 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMLoginManager.java @@ -159,11 +159,11 @@ public class IMLoginManager extends BaseCacheManager { } public boolean isMountEffect() { - return getBoolean(MountEffect, false); + return getBoolean(MountEffect, true); } public boolean isGiftEffect() { - return getBoolean(GiftEffect, false); + return getBoolean(GiftEffect, true); } /** 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 a6a2bb6f4..8f2fa86df 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -216,6 +216,7 @@ public class LiveAudienceActivity extends LiveActivity { public void onPageSelected(int position) { super.onPageSelected(position); mCurrentPage = position; + } }); verticalViewPager.setPageTransformer(false, new ViewPager.PageTransformer() { @@ -234,7 +235,6 @@ public class LiveAudienceActivity extends LiveActivity { manager.onRemove(); } } - // 满足此种条件,表明需要加载直播视频,以及聊天室了 if (viewGroup.getId() == mCurrentItem && (position == 0) && mCurrentItem != mLastPosition) { loadData(viewGroup, mCurrentItem); @@ -249,20 +249,9 @@ public class LiveAudienceActivity extends LiveActivity { private void loadData(ViewGroup viewGroup, int currentItem) { mViewGroup = viewGroup; mLastPosition = currentItem; - liveHandler.removeCallbacks(liveRunnable); - if (mCurrentPage > 0) { - liveHandler.postDelayed(liveRunnable, 800); - } else { - liveHandler.post(liveRunnable); - } + liveHandler.post(liveRunnable); Log.e("收到socket--->", "mLiveUid--------------------------->" + mLiveUid); - //加载当前页面数据 - View rootView = manager.getRootView(); - if (rootView.getParent() != null && rootView.getParent() instanceof ViewGroup) { - ((ViewGroup) (rootView.getParent())).removeView(rootView); - manager.onRemove(); - } - mViewGroup.addView(manager.getRootView()); + } //获取直播间状态 @@ -292,17 +281,30 @@ public class LiveAudienceActivity extends LiveActivity { if (liveBean1 == null) { return; } - mLiveSDK = liveSdk; - mLiveType = liveType; - mLiveTypeVal = liveTypeVal; - mLiveBean = liveBean1; - mLiveUid = liveBean1.getUid(); - mStream = liveBean1.getStream(); - mAncherName = liveBean1.getUserNiceName(); - mAncherIcon = liveBean1.getAvatar(); + runOnUiThread(new Runnable() { + @Override + public void run() { + mLiveSDK = liveSdk; + mLiveType = liveType; + mLiveTypeVal = liveTypeVal; + mLiveBean = liveBean1; + mLiveUid = liveBean1.getUid(); + mStream = liveBean1.getStream(); + mAncherName = liveBean1.getUserNiceName(); + mAncherIcon = liveBean1.getAvatar(); + Log.e("收到socket--->", "mLiveUid--------------------------->" + mLiveUid); + //加载当前页面数据 + View rootView = manager.getRootView(); + if (rootView.getParent() != null && rootView.getParent() instanceof ViewGroup) { + ((ViewGroup) (rootView.getParent())).removeView(rootView); + manager.onRemove(); + } + mViewGroup.addView(manager.getRootView()); + manager.onAdd(liveBean1, liveType, liveTypeVal, liveSdk); + } + }); - manager.onAdd(liveBean1, liveType, liveTypeVal, liveSdk); }); diff --git a/live/src/main/java/com/yunbao/live/adapter/VerticalPagerAdapter.java b/live/src/main/java/com/yunbao/live/adapter/VerticalPagerAdapter.java index 48e1ba219..6edabd64f 100644 --- a/live/src/main/java/com/yunbao/live/adapter/VerticalPagerAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/VerticalPagerAdapter.java @@ -44,12 +44,13 @@ public class VerticalPagerAdapter extends androidx.viewpager.widget.PagerAdapter @Override public Object instantiateItem(ViewGroup container, int position) { - Log.e("LiveAudienceActivity", "VerticalPagerAdapter:" + position); + View view = LayoutInflater.from(container.getContext()).inflate(R.layout.layout_portrait_live_item, null); // 背景 AnchorRecommendItemModel liveItemBean = liveBeans.get(position); ImageView ivBg = view.findViewById(R.id.iv_bg); ImgLoader.displayBlurLive(mContext, liveItemBean.getAvatar(), ivBg); + Log.e("LiveAudienceActivity", "加载图片:" + liveItemBean.getAvatar()); // 加载动画 ImageView ivLoading = view.findViewById(R.id.iv_loading); AnimationDrawable frameAnimation = (AnimationDrawable) ivLoading.getBackground(); 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 1c428538e..9024371d3 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -181,10 +181,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe private void ininView() { // 直播间根布局 mRootContainer = (DrawerLayout) LayoutInflater.from(mContext).inflate(R.layout.activity_live_audience, null); - - playContainer = mRootContainer.findViewById(R.id.play_container); - mViewPager = mRootContainer.findViewById(R.id.viewPager); btnSmallScreen = mRootContainer.findViewById(R.id.btn_small_screen); mSecondPage = (ViewGroup) LayoutInflater.from(mContext).inflate(R.layout.view_audience_page, mViewPager, false); @@ -200,89 +197,104 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mContainer.removeAllViews(); mViewPager.setAdapter(pagerAdapter); mViewPager.setCurrentItem(1); - //直播页面背景 liveBack = mRootContainer.findViewById(R.id.live_back); mask = mRootContainer.findViewById(R.id.mask); - - } @Override public void onAdd(LiveBean data, int liveType, int liveTypeVal, int liveSdk) { - mLiveBean = data; - mLiveSDK = liveSdk; - mLiveType = liveType; - mLiveTypeVal = liveTypeVal; - liveID = data.getUid(); - Bus.get().post(new LiveAudienceEvent() - .setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS) - .setParametersModel(new OpenParametersModel() - .setmLiveType(mLiveType) - .setmLiveTypeVal(mLiveTypeVal))); - - mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0)); - mLivePlayViewHolder.addToParent(); - mLivePlayViewHolder.subscribeActivityLifeCycle(); - mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager()); - - mLiveRoomViewHolder.subscribeActivityLifeCycle(); - mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer); - mLiveAudienceViewHolder.addToParent(); - mLiveRoomViewHolder.addToParent(); - mLiveAudienceViewHolder.subscribeActivityLifeCycle(); - mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView()); - mLiveLinkMicAnchorPresenter = new LiveLinkMicAnchorPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, null); - - mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null); - - - //直播间背景 - ImgLoader.displayBlurLive(mContext, data.getAvatar(), liveBack); - mask.setVisibility(View.VISIBLE); - - mLivePlayViewHolder.setCover(data.getThumb()); - mLivePlayViewHolder.play(data.getPull()); - mLiveRoomViewHolder.setAvatar(data.getAvatar()); - mLiveRoomViewHolder.setAnchorLevel(data.getLevelAnchor()); - mLiveRoomViewHolder.setName(data.getUserNiceName()); - mLiveRoomViewHolder.setRoomNum(data.getLiangNameTip()); - mLiveRoomViewHolder.setTitle(data.getTitle()); - - mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), ""); - - mLiveRoomViewHolder.setLiveUid(data.getUid()); - //心愿单 - LiveHttpUtil.getWishList(mLiveBean.getUid(), new HttpCallback() { + mContext.runOnUiThread(new Runnable() { @Override - public void onSuccess(int code, String msg, String[] info) { - if (info.length > 0) { - String json = info[0]; - WishlistModel model = GsonUtils.fromJson(json, WishlistModel.class); - if (mLiveRoomViewHolder != null && model != null) - mLiveRoomViewHolder.initWishList(model.getWishlist()); + public void run() { + Log.e("ImgLoader1", data.getAvatar()); + + + mLiveBean = data; + mLiveSDK = liveSdk; + mLiveType = liveType; + mLiveTypeVal = liveTypeVal; + liveID = data.getUid(); + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS) + .setParametersModel(new OpenParametersModel() + .setmLiveType(mLiveType) + .setmLiveTypeVal(mLiveTypeVal))); + + mLivePlayViewHolder = new LivePlayRyViewHolder(mContext, playContainer, mIntent.getIntExtra("landscape", 0)); + mLivePlayViewHolder.addToParent(); + mLivePlayViewHolder.subscribeActivityLifeCycle(); + mLiveRoomViewHolder = new LiveRoomViewHolder(false, 1, mContext, mContainer, mSecondPage.findViewById(R.id.gift_gif), mSecondPage.findViewById(R.id.gift_svga), mContainerWrap, mContext.getWindowManager()); + + mLiveRoomViewHolder.subscribeActivityLifeCycle(); + mLiveAudienceViewHolder = new LiveAudienceViewHolder(mContext, mContainer); + mLiveAudienceViewHolder.addToParent(); + mLiveRoomViewHolder.addToParent(); + mLiveAudienceViewHolder.subscribeActivityLifeCycle(); + mLiveLinkMicPresenter = new LiveLinkMicPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, mLiveAudienceViewHolder.getContentView()); + mLiveLinkMicAnchorPresenter = new LiveLinkMicAnchorPresenter(mContext, mLivePlayViewHolder, false, mLiveSDK, null); + + mLiveRyLinkMicPkPresenter = new LiveRyLinkMicPkPresenter(mContext, mLivePlayViewHolder, false, null); + //直播间背景 + ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack); + mask.setVisibility(View.VISIBLE); + mLivePlayViewHolder.setCover(data.getThumb()); + mLivePlayViewHolder.play(data.getPull()); + mLiveRoomViewHolder.setAvatar(data.getAvatar()); + mLiveRoomViewHolder.setAnchorLevel(data.getLevelAnchor()); + mLiveRoomViewHolder.setName(data.getUserNiceName()); + mLiveRoomViewHolder.setRoomNum(data.getLiangNameTip()); + mLiveRoomViewHolder.setTitle(data.getTitle()); + + mLiveRyLinkMicPkPresenter.setLiveUid(data.getUid(), ""); + + mLiveRoomViewHolder.setLiveUid(data.getUid()); + + mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), PortraitLiveManager.this); + if (mLiveLinkMicPresenter != null) { + mLiveLinkMicPresenter.setSocketClient(mSocketClient); } - } + //心愿单 + LiveHttpUtil.getWishList(mLiveBean.getUid(), new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (info.length > 0) { + String json = info[0]; + WishlistModel model = GsonUtils.fromJson(json, WishlistModel.class); + if (mLiveRoomViewHolder != null && model != null) { + mLiveRoomViewHolder.initWishList(model.getWishlist()); - @Override - public void onFinish() { + } + } + } + + @Override + public void onFinish() { + + + } + }); enterRoom(); + mLiveRoomViewHolder.initHourRankList(); } }); - mLiveRoomViewHolder.initHourRankList(); + } @Override public void onRemove() { - //子线程执行退出操作 - liveHandler.post(() -> exitLiveRoom()); + IMLoginManager.get(mContext).setisNewUserOne(false); + //子线程执行退出操作 + endPlay(); + exitLiveRoom(); if (mLiveAudienceViewHolder != null) { mLiveAudienceViewHolder.removeFromParent(); mLiveAudienceViewHolder.countDownTimerTrickery = null; mLiveAudienceViewHolder.removeCallbacks(); + mLiveAudienceViewHolder.release(); } mLiveAudienceViewHolder = null; //断开socket @@ -293,6 +305,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mSocketRyClient = null; //结束播放 if (mLivePlayViewHolder != null) { + mLivePlayViewHolder.removeFromParent(); mLivePlayViewHolder.stopPlay(); mLivePlayViewHolder.release(); } @@ -317,16 +330,20 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe if (mLiveEndViewHolder != null) { mLiveEndViewHolder.removeFromParent(); + mLiveEndViewHolder.release(); mLiveEndViewHolder = null; } if (mLiveLinkMicPresenter != null) { mLiveLinkMicPresenter.clearData(); + mLiveLinkMicPresenter.release(); } if (mLiveLinkMicAnchorPresenter != null) { mLiveLinkMicAnchorPresenter.clearData(); + mLiveLinkMicAnchorPresenter.release(); } if (mLiveRyLinkMicPkPresenter != null) { mLiveRyLinkMicPkPresenter.clearData(); + mLiveRyLinkMicPkPresenter.release(); } } @@ -660,6 +677,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void onLiveEnd() { + endPlay(); if (!CommonAppConfig.LIVE_ROOM_SCROLL) { if (mViewPager != null) { if (mViewPager.getCurrentItem() != 1) { @@ -667,7 +685,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } mViewPager.setCanScroll(false); } - endPlay(); + } else { if (mLivePlayViewHolder != null) { mLivePlayViewHolder.stopPlay2(); @@ -964,10 +982,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe private void enterRoom() { //进入直播间IM - mSocketRyClient = new SocketRyClient(mLiveBean.getUid(), this); - if (mLiveLinkMicPresenter != null) { - mLiveLinkMicPresenter.setSocketClient(mSocketClient); - } timeIndex = 0; LiveHttpUtil.enterRoom(mLiveBean.getUid(), mLiveBean.getStream(), new HttpCallback() { @@ -993,7 +1007,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mask.setVisibility(View.GONE); } } - //回传参数 Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.OPEN_PARAMETERS) @@ -1300,7 +1313,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe if (mLiveRoomViewHolder != null) mLiveRoomViewHolder.clearList(); - IMLoginManager.get(mContext).setisNewUserOne(false); if (countDownTimer != null) { countDownTimer.cancel(); diff --git a/live/src/main/res/layout/dialog_new_guard_buy.xml b/live/src/main/res/layout/dialog_new_guard_buy.xml index 444b8e434..4fc4a2ab1 100644 --- a/live/src/main/res/layout/dialog_new_guard_buy.xml +++ b/live/src/main/res/layout/dialog_new_guard_buy.xml @@ -63,6 +63,7 @@ android:text="@string/buy_guard_info" android:textColor="#020202" android:textSize="16sp" + android:textStyle="bold" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -73,6 +74,7 @@ android:layout_height="110dp" android:layout_marginStart="6dp" android:layout_marginTop="16dp" + android:gravity="center" android:layout_marginEnd="6dp" android:orientation="vertical" android:overScrollMode="never" @@ -104,8 +106,8 @@ android:id="@+id/guard_rights" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginStart="16dp" - android:layout_marginEnd="16dp" + android:layout_marginStart="5dp" + android:layout_marginBottom="10dp" android:overScrollMode="never" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -132,7 +134,7 @@ android:layout_marginTop="25dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - tools:visibility="visible"> + tools:visibility="gone"> + tools:visibility="visible"> @@ -215,7 +217,7 @@