修复暂时离开功能无效问题

调整购买守护的动画效果
This commit is contained in:
zlzw 2024-06-16 11:00:50 +08:00
parent 020b5c1025
commit a7421ba1a6
10 changed files with 125 additions and 35 deletions

View File

@ -2,7 +2,10 @@ package com.yunbao.common.custom;
import android.view.View; import android.view.View;
import androidx.core.view.ViewCompat;
import com.stx.xhb.androidx.transformers.BasePageTransformer; import com.stx.xhb.androidx.transformers.BasePageTransformer;
import com.yunbao.common.manager.IMLoginManager;
public class LiveGuardScalePageTransformer extends BasePageTransformer { public class LiveGuardScalePageTransformer extends BasePageTransformer {
/** /**
@ -12,23 +15,54 @@ public class LiveGuardScalePageTransformer extends BasePageTransformer {
* github:https://github.com/xiaohaibin * github:https://github.com/xiaohaibin
* describe: 适用于一屏显示多个模式 * describe: 适用于一屏显示多个模式
*/ */
private static final float MIN_SCALE = 0.8F; private float mMinScale = 0.85f;
private float mMinAlpha = 1f;
public LiveGuardScalePageTransformer() {
}
public LiveGuardScalePageTransformer(float minAlpha, float minScale) {
setMinAlpha(minAlpha);
setMinScale(minScale);
}
@Override @Override
public void handleInvisiblePage(View view, float position) { public void handleInvisiblePage(View view, float position) {
view.setScaleY(MIN_SCALE); ViewCompat.setAlpha(view, 0);
} }
@Override @Override
public void handleLeftPage(View view, float position) { public void handleLeftPage(View view, float position) {
float scale = Math.max(MIN_SCALE, 1 - Math.abs(position)); float scale = Math.max(mMinScale, 1 + position);
float vertMargin = view.getHeight() * (1 - scale) / 2;
float horzMargin = view.getWidth() * (1 - scale) / 2;
view.setTranslationX(horzMargin - vertMargin / 2);
view.setScaleX(scale);
view.setScaleY( scale); view.setScaleY( scale);
view.setAlpha( mMinAlpha + (scale - mMinScale) / (1 - mMinScale) * (1 - mMinAlpha));
} }
@Override @Override
public void handleRightPage(View view, float position) { public void handleRightPage(View view, float position) {
float scale = Math.max(MIN_SCALE, 1 - Math.abs(position)); float scale = Math.max(mMinScale, 1 - position);
float vertMargin = view.getHeight() * (1 - scale) / 2;
float horzMargin = view.getWidth() * (1 - scale) / 2;
view.setTranslationX( -horzMargin + vertMargin / 2);
view.setScaleX( scale);
view.setScaleY( scale); view.setScaleY( scale);
view.setAlpha( mMinAlpha + (scale - mMinScale) / (1 - mMinScale) * (1 - mMinAlpha));
} }
public void setMinAlpha(float minAlpha) {
if (minAlpha >= 0.6f && minAlpha <= 1.0f) {
mMinAlpha = minAlpha;
}
}
public void setMinScale(float minScale) {
if (minScale >= 0.6f && minScale <= 1.0f) {
mMinScale = minScale;
}
}
} }

View File

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View File

@ -1,10 +1,17 @@
package io.agora.beautyapi.faceunity.agora; package io.agora.beautyapi.faceunity.agora;
import android.app.Activity; import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.net.Uri;
import android.text.TextUtils;
import android.view.SurfaceView; import android.view.SurfaceView;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import androidx.core.content.res.ResourcesCompat;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.CommonAppContext; import com.yunbao.common.CommonAppContext;
import com.yunbao.common.bean.SwTokenModel; import com.yunbao.common.bean.SwTokenModel;
@ -17,6 +24,9 @@ import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.faceunity.utils.FURenderer; import com.yunbao.faceunity.utils.FURenderer;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -27,13 +37,16 @@ import io.agora.beautyapi.faceunity.Config;
import io.agora.beautyapi.faceunity.FaceUnityBeautyAPI; import io.agora.beautyapi.faceunity.FaceUnityBeautyAPI;
import io.agora.beautyapi.faceunity.FaceUnityBeautyAPIKt; import io.agora.beautyapi.faceunity.FaceUnityBeautyAPIKt;
import io.agora.beautyapi.faceunity.MirrorMode; import io.agora.beautyapi.faceunity.MirrorMode;
import io.agora.beautyapi.faceunity.R;
import io.agora.rtc2.ChannelMediaOptions; import io.agora.rtc2.ChannelMediaOptions;
import io.agora.rtc2.Constants; import io.agora.rtc2.Constants;
import io.agora.rtc2.IRtcEngineEventHandler; import io.agora.rtc2.IRtcEngineEventHandler;
import io.agora.rtc2.RtcConnection; import io.agora.rtc2.RtcConnection;
import io.agora.rtc2.RtcEngine;
import io.agora.rtc2.RtcEngineConfig; import io.agora.rtc2.RtcEngineConfig;
import io.agora.rtc2.RtcEngineEx; import io.agora.rtc2.RtcEngineEx;
import io.agora.rtc2.video.ContentInspectConfig; import io.agora.rtc2.video.ContentInspectConfig;
import io.agora.rtc2.video.ImageTrackOptions;
import io.agora.rtc2.video.VideoCanvas; import io.agora.rtc2.video.VideoCanvas;
import io.agora.rtc2.video.VideoEncoderConfiguration; import io.agora.rtc2.video.VideoEncoderConfiguration;
@ -53,6 +66,7 @@ public class SWManager extends BaseCacheManager {
private FrameLayout linkUserContainer;//连麦用户视图 private FrameLayout linkUserContainer;//连麦用户视图
private onRtcEngineListener onRtcEngineListener; private onRtcEngineListener onRtcEngineListener;
private List<String> drPkUserInfo = new ArrayList<>(); private List<String> drPkUserInfo = new ArrayList<>();
private ImageTrackOptions imageTrackOptions = null;
private onDrPkJoinSuccessListener onDrPkJoinSuccessListener; private onDrPkJoinSuccessListener onDrPkJoinSuccessListener;
@ -66,6 +80,17 @@ public class SWManager extends BaseCacheManager {
public SWManager(Context context) { public SWManager(Context context) {
super(context); super(context);
String filePath = context.getCacheDir() + File.separator + "zslk.png";
if (!new File(filePath).exists()) {
Bitmap bitmap = ((BitmapDrawable) ResourcesCompat.getDrawable(context.getResources(), com.yunbao.common.R.mipmap.zslk, null)).getBitmap();
try {
bitmap.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream(filePath));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
imageTrackOptions = new ImageTrackOptions(filePath, 1);
} }
/** /**
@ -80,6 +105,12 @@ public class SWManager extends BaseCacheManager {
return manager; return manager;
} }
public void setLeaveFlag(boolean leave) {
if (mRtcEngine != null) {
mRtcEngine.enableVideoImageSource(leave, imageTrackOptions);
}
}
/** /**
* 初始化声网SDK * 初始化声网SDK
*/ */
@ -126,7 +157,6 @@ public class SWManager extends BaseCacheManager {
cfg.orientationMode = VideoEncoderConfiguration.ORIENTATION_MODE.ORIENTATION_MODE_FIXED_PORTRAIT; cfg.orientationMode = VideoEncoderConfiguration.ORIENTATION_MODE.ORIENTATION_MODE_FIXED_PORTRAIT;
mRtcEngine.setVideoEncoderConfiguration(cfg); mRtcEngine.setVideoEncoderConfiguration(cfg);
// 创建一个 SurfaceView 对象并将其作为 FrameLayout 的子对象 // 创建一个 SurfaceView 对象并将其作为 FrameLayout 的子对象
@ -497,6 +527,7 @@ public class SWManager extends BaseCacheManager {
public interface onRtcEngineListener { public interface onRtcEngineListener {
void onOpenSuccess(String channel, int uid); void onOpenSuccess(String channel, int uid);
void onUserOffline(int uid); void onUserOffline(int uid);
} }

View File

@ -125,6 +125,7 @@ import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback;
import cn.rongcloud.rtc.base.RCRTCRect; import cn.rongcloud.rtc.base.RCRTCRect;
import cn.rongcloud.rtc.base.RTCErrorCode; import cn.rongcloud.rtc.base.RTCErrorCode;
import io.agora.beautyapi.faceunity.agora.SWManager; import io.agora.beautyapi.faceunity.agora.SWManager;
import io.agora.rtc2.RtcEngine;
import io.rong.imlib.IRongCallback; import io.rong.imlib.IRongCallback;
import io.rong.imlib.RongIMClient; import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation; import io.rong.imlib.model.Conversation;
@ -547,12 +548,16 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl
} }
}); });
SWManager.get().setLeaveFlag(true);
mLiveAnchorViewHolder.setLeaveFlag(true);
} else if (leave == 1) { } else if (leave == 1) {
leave = 0; leave = 0;
leave_img.setVisibility(View.GONE); leave_img.setVisibility(View.GONE);
// 清除水印 // 清除水印
boolean ret = RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(null, rect); boolean ret = RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(null, rect);
sendSystemMessageSw(mContext.getString(R.string.live_anchor_come_back)); sendSystemMessageSw(mContext.getString(R.string.live_anchor_come_back));
SWManager.get().setLeaveFlag(false);
mLiveAnchorViewHolder.setLeaveFlag(false);
} }
HttpClient.getInstance().get("Live.isLeave", "Live.isLeave") HttpClient.getInstance().get("Live.isLeave", "Live.isLeave")

View File

@ -30,9 +30,6 @@ import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.enums.PopupPosition; import com.lxj.xpopup.enums.PopupPosition;
import com.makeramen.roundedimageview.RoundedImageView; import com.makeramen.roundedimageview.RoundedImageView;
import com.stx.xhb.androidx.XBanner; import com.stx.xhb.androidx.XBanner;
import com.stx.xhb.androidx.transformers.ScalePageTransformer;
import com.yunbao.common.custom.LiveGuardScalePageTransformer;
import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.adapter.LiveBuyGuardPrivilegeAdapter; import com.yunbao.common.adapter.LiveBuyGuardPrivilegeAdapter;
import com.yunbao.common.bean.CheckUpgradesModel; import com.yunbao.common.bean.CheckUpgradesModel;
@ -42,6 +39,7 @@ import com.yunbao.common.bean.GuardGetGuardUserInfoModel;
import com.yunbao.common.bean.GuardPriceModel; import com.yunbao.common.bean.GuardPriceModel;
import com.yunbao.common.bean.GuardUserInfoModel; import com.yunbao.common.bean.GuardUserInfoModel;
import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.custom.LiveGuardScalePageTransformer;
import com.yunbao.common.dialog.AbsDialogPopupWindow; import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.common.dialog.GuardBuyTipsDialog; import com.yunbao.common.dialog.GuardBuyTipsDialog;
import com.yunbao.common.dialog.GuardUpgradePopup; import com.yunbao.common.dialog.GuardUpgradePopup;
@ -52,6 +50,7 @@ import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DeviceUtils;
import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.common.views.weight.ViewClicksAntiShake;
@ -160,8 +159,8 @@ public class LiveBuyGuardDialog extends AbsDialogPopupWindow {
buyGuardBannerModels.add(guardBannerModel); buyGuardBannerModels.add(guardBannerModel);
} }
buyGuardBanner.setBannerData(R.layout.banner_item_buy_guard, buyGuardBannerModels); buyGuardBanner.setBannerData(R.layout.banner_item_buy_guard, buyGuardBannerModels);
buyGuardBanner.setIsClipChildrenMode(true);
buyGuardBanner.setCustomPageTransformer(new LiveGuardScalePageTransformer()); buyGuardBanner.setCustomPageTransformer(new LiveGuardScalePageTransformer());
buyGuardBanner.setIsClipChildrenMode(true);
guardPrivilegeStrings = data.getGuardData().get(0).getGuardPrivilege(); guardPrivilegeStrings = data.getGuardData().get(0).getGuardPrivilege();
buyGuardBanner.postDelayed(new Runnable() { buyGuardBanner.postDelayed(new Runnable() {
@Override @Override

View File

@ -91,6 +91,8 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
private LiveRoomHandler mLiveRoomHandler; private LiveRoomHandler mLiveRoomHandler;
private static LinearLayout btn_end_pk_dr; private static LinearLayout btn_end_pk_dr;
private String drpkRoomId; //多人 PK 房主 roomUid private String drpkRoomId; //多人 PK 房主 roomUid
private ImageView leaveImg;
public void setDrpkRoomId(String drpkRoomId) { public void setDrpkRoomId(String drpkRoomId) {
this.drpkRoomId = drpkRoomId; this.drpkRoomId = drpkRoomId;
} }
@ -131,6 +133,7 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
mDrawable1 = ContextCompat.getDrawable(mContext, R.mipmap.icon_live_func_1); mDrawable1 = ContextCompat.getDrawable(mContext, R.mipmap.icon_live_func_1);
btn_end_pk_dr = (LinearLayout) findViewById(R.id.btn_end_pk_dr); btn_end_pk_dr = (LinearLayout) findViewById(R.id.btn_end_pk_dr);
mBtnFunction = (ImageView) findViewById(R.id.btn_function); mBtnFunction = (ImageView) findViewById(R.id.btn_function);
leaveImg = (ImageView) findViewById(R.id.leave_img);
btn_dr = (TextView) findViewById(R.id.btn_dr); btn_dr = (TextView) findViewById(R.id.btn_dr);
mBanner = (Banner) findViewById(R.id.banner); mBanner = (Banner) findViewById(R.id.banner);
mBtnFunction.setImageDrawable(mDrawable0); mBtnFunction.setImageDrawable(mDrawable0);
@ -686,6 +689,10 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
private final int WHAT_ANCHOR_LIVE_TIME = 3;//直播间主播计时 private final int WHAT_ANCHOR_LIVE_TIME = 3;//直播间主播计时
public void setLeaveFlag(boolean leave) {
leaveImg.setVisibility(leave ? View.VISIBLE : View.GONE);
}
private class LiveRoomHandler extends Handler { private class LiveRoomHandler extends Handler {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {

View File

@ -669,6 +669,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
if (LivePlaySwViewHolder.leave != null) { if (LivePlaySwViewHolder.leave != null) {
LivePlaySwViewHolder.leave.setVisibility(View.VISIBLE); LivePlaySwViewHolder.leave.setVisibility(View.VISIBLE);
} }
if (LivePlayRyViewHolder.leave != null) {
LivePlayRyViewHolder.leave.setVisibility(View.VISIBLE);
}
} }
//判断是否有连麦要显示连麦窗口 //判断是否有连麦要显示连麦窗口
String linkMicUid = data.getEnterRoomInfo().getLinkmicUid(); String linkMicUid = data.getEnterRoomInfo().getLinkmicUid();

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root" android:id="@+id/root"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -54,5 +55,6 @@
android:layout_marginBottom="45dp" android:layout_marginBottom="45dp"
android:scaleType="fitXY" android:scaleType="fitXY"
android:src="@mipmap/zslk" android:src="@mipmap/zslk"
android:visibility="gone" /> android:visibility="gone"
tools:visibility="visible" />
</FrameLayout> </FrameLayout>

View File

@ -39,8 +39,8 @@
<ImageView <ImageView
android:id="@+id/leave" android:id="@+id/leave"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="0dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:scaleType="centerCrop" android:scaleType="centerCrop"
android:src="@mipmap/zslk" android:src="@mipmap/zslk"

View File

@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:orientation="vertical"> android:orientation="vertical">
@ -154,6 +155,14 @@
android:layout_height="45dp" android:layout_height="45dp"
android:layout_gravity="bottom"> android:layout_gravity="bottom">
<ImageView
android:id="@+id/leave_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="matrix"
android:src="@mipmap/zslk"
android:visibility="gone"
tools:visibility="visible" />
<ImageView <ImageView
android:id="@+id/btn_close" android:id="@+id/btn_close"