悬浮窗视频调整,主播离开下滑直播间离开画面不消失问题修复

This commit is contained in:
18401019693 2022-11-29 14:34:23 +08:00
parent 744de267dd
commit cf4948a3e2
6 changed files with 114 additions and 18 deletions

View File

@ -73,8 +73,8 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
CardView layout = magnetView.findViewById(R.id.layout);
RelativeLayout.LayoutParams cardParams = (RelativeLayout.LayoutParams) layout.getLayoutParams();
if (mLiveBean.getLandscape() == 1) {
cardParams.height = DpUtil.dp2px(130);
cardParams.width = DpUtil.dp2px(230);
cardParams.height = DpUtil.dp2px(190);
cardParams.width = DpUtil.dp2px(255);
} else {
cardParams.height = DpUtil.dp2px(224);
cardParams.width = DpUtil.dp2px(126);
@ -91,8 +91,8 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
Log.e("视频流有", "videoWidth:" + videoWidth + " videoHeight:" + videoHeight);
if (mLiveBean.getLandscape() != 1){
if (videoWidth > 720) {
cardParams.height = DpUtil.dp2px(130);
cardParams.width = DpUtil.dp2px(230);
cardParams.height = DpUtil.dp2px(190);
cardParams.width = DpUtil.dp2px(255);
} else {
cardParams.height = DpUtil.dp2px(224);
cardParams.width = DpUtil.dp2px(126);
@ -206,8 +206,8 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
CardView layout = view.findViewById(R.id.layout);
RelativeLayout.LayoutParams cardParams = (RelativeLayout.LayoutParams) layout.getLayoutParams();
if (mLiveBean.getLandscape() == 1) {
cardParams.height = DpUtil.dp2px(130);
cardParams.width = DpUtil.dp2px(230);
cardParams.height = DpUtil.dp2px(190);
cardParams.width = DpUtil.dp2px(255);
} else {
cardParams.height = DpUtil.dp2px(224);
cardParams.width = DpUtil.dp2px(126);
@ -224,8 +224,8 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
Log.e("视频流有", "videoWidth:" + videoWidth + " videoHeight:" + videoHeight);
if (mLiveBean.getLandscape() != 1){
if (videoWidth > 720) {
cardParams.height = DpUtil.dp2px(130);
cardParams.width = DpUtil.dp2px(230);
cardParams.height = DpUtil.dp2px(190);
cardParams.width = DpUtil.dp2px(255);
} else {
cardParams.height = DpUtil.dp2px(224);
cardParams.width = DpUtil.dp2px(126);

View File

@ -0,0 +1,68 @@
package com.yunbao.common.views.weight;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.view.Gravity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import com.lzf.easyfloat.EasyFloat;
import com.lzf.easyfloat.enums.ShowPattern;
import com.lzf.easyfloat.interfaces.FloatCallbacks;
import com.lzf.easyfloat.interfaces.OnInvokeView;
import com.yunbao.common.R;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.DeviceUtils;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
public class LiveLoadingViewHolder implements Function1<FloatCallbacks.Builder, Unit> {
private String TAG = "LiveLoadingViewHolder";
private Activity mContext;
private String url;
public void builderSystemFloat(Activity mContext, String url) {
this.mContext = mContext;
this.url = url;
EasyFloat.with(mContext)
.setTag(TAG)
.setLayout(R.layout.layout_portrait_live_item, new LiveOnInvokeView())
.setShowPattern(ShowPattern.CURRENT_ACTIVITY)
.setFilter()
.setGravity(Gravity.CENTER)
.setAnimator(null)
.setMatchParent(true,true)
.registerCallback(this)
.show();
}
/**
* loading
*/
private class LiveOnInvokeView implements OnInvokeView {
@Override
public void invoke(View view) {
RelativeLayout layout = view.findViewById(R.id.layout);
FrameLayout.LayoutParams cardParams = (FrameLayout.LayoutParams) layout.getLayoutParams();
cardParams.width = DeviceUtils.getScreenWidth(mContext);
cardParams.height = DeviceUtils.getScreenHeight(mContext);
layout.setLayoutParams(cardParams);
ImageView ivBg = view.findViewById(R.id.iv_bg);
ImgLoader.displayBlurLive(mContext, url, ivBg);
// 加载动画
ImageView ivLoading = view.findViewById(R.id.iv_loading);
AnimationDrawable frameAnimation = (AnimationDrawable) ivLoading.getBackground();
frameAnimation.start();
}
}
@Override
public Unit invoke(FloatCallbacks.Builder builder) {
return null;
}
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

View File

@ -144,6 +144,7 @@ public class LiveAudienceActivity extends LiveActivity {
private Handler liveHandler = new Handler();
private ImageView voicePress;
private View titleLine;
private boolean liveIndex = true;
@Override
public <T extends View> T findViewById(@IdRes int id) {
@ -301,7 +302,7 @@ public class LiveAudienceActivity extends LiveActivity {
@Override
public void run() {
AnchorRecommendItemModel data = itemModelList.get(mCurrentPage);
if (mCurrentPage==0){
if (mCurrentPage == 0&&liveIndex) {
View rootView = manager.getRootView();
if (rootView.getParent() != null && rootView.getParent() instanceof ViewGroup) {
((ViewGroup) (rootView.getParent())).removeView(rootView);
@ -313,11 +314,12 @@ public class LiveAudienceActivity extends LiveActivity {
//加载完页面后再后台静默下载礼物svga
downloadAllGift();
over();
}else {
} else {
new LiveRoomCheckLivePresenter(mContext, data.getUid(), data.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
liveIndex =false;
try {
mLiveSDK = Integer.parseInt(liveSdk);
mLiveTypeVal = Integer.parseInt(liveTypeVal);
@ -754,7 +756,7 @@ public class LiveAudienceActivity extends LiveActivity {
if (liveBean == null) {
return;
}
if(MicStatusManager.getInstance().isMic(liveUid)){
if (MicStatusManager.getInstance().isMic(liveUid)) {
MicStatusManager.getInstance().showDownMicDialog(mContext);
return;
}
@ -1053,7 +1055,7 @@ public class LiveAudienceActivity extends LiveActivity {
break;
case LIVE_ROOM_EXCEPTION:
//主播未直播时自动下滑至下一个直播间
mCurrentPage = mCurrentPage+1;
mCurrentPage = mCurrentPage + 1;
liveHandler.post(liveRunnable);
break;
case REFRESH_THE_LIVEl_PAGE:

View File

@ -2988,6 +2988,19 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
});
}
/**
* 获取是否有热度卡加成
*/
public static void getIsHot(String isUseHotCard) {
if ("1".equals(isUseHotCard)) {
ft_hot_add.setVisibility(View.VISIBLE);
} else {
ft_hot_add.setVisibility(View.GONE);
}
}
public void resetUserListWidth(int width) {
ViewGroup.LayoutParams params = mUserRecyclerView.getLayoutParams();
params.width = width;
@ -3169,7 +3182,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
if (taskModel != null) {
GiftModel giftModel = newPeopleTask.getGift();
if (giftModel!=null){
if (giftModel != null) {
RewardAllModel rewardOne = newPeopleTask.getRewardOne();
String gold = rewardOne.getGold();
String experience = rewardOne.getExperience();
@ -3580,7 +3593,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
.setMicIng(2)
.setBean(liveBean).setLiveType(liveType).setLiveTypeVal(Integer.parseInt(liveTypeVal)));
} else {
if(MicStatusManager.getInstance().isMic(liveUid)){
if (MicStatusManager.getInstance().isMic(liveUid)) {
MicStatusManager.getInstance().showDownMicDialog(mContext);
return;
}

View File

@ -59,6 +59,7 @@ import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.utils.formatBigNum;
import com.yunbao.common.views.weight.LiveFloatView;
import com.yunbao.common.views.weight.LiveLoadingViewHolder;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.activity.LiveAudienceActivity;
@ -257,7 +258,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveLinkMicPresenter.setLiveSdk(mLiveSDK);
mLiveLinkMicAnchorPresenter.setLiveSdk(mLiveSDK);
}
//去除主播离开画面
if (LivePlayKsyViewHolder.leave != null) {
LivePlayKsyViewHolder.leave.setVisibility(View.GONE);
}
if (LivePlayRyViewHolder.leave != null) {
LivePlayRyViewHolder.leave.setVisibility(View.GONE);
}
//直播间背景
ImgLoader.displayBlurLive(mContext, mLiveBean.getAvatar(), liveBack, 400, 600);
//ImageLoadUtils.loadUrlToBlur(mContext,mLiveBean.getAvatar(),400,600,liveBack);
@ -304,6 +311,8 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override
public void onSuccess(EnterRoomNewModel data) {
mLivePlayViewHolder.setLiveBeanLandscape(data.getLiveInfo().getLandscape());
//是否热度卡加成
mLiveRoomViewHolder.getIsHot(data.getIsUseHotCard());
isEnterRoom = true;
//延时1秒发送
liveHandler.postDelayed(sendFIm, 700);
@ -334,10 +343,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
bannerModel.setStart(false);
bannerModel.setLink(model.getLink());
bannerModel.setImageUrl(model.getImg());
if (TextUtils.equals(model.getIsHidden(),"0")){
bannerBeans.add(bannerModel);
}
}
}
//底部轮播
mLiveRoomViewHolder.addWishListActivity(bannerBeans);
//直播间上部轮播新人特惠趣味游戏幸运天使 轮播接口
@ -503,6 +515,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.showPrizePoolLevel(String.valueOf(giftPrizePoolLevel));
}
}
}
@Override