Merge branch 'master' into dev_20221020
This commit is contained in:
commit
1e2d146e74
@ -0,0 +1,94 @@
|
||||
package com.yunbao.common.dialog;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.lzf.easyfloat.interfaces.OnPermissionResult;
|
||||
import com.lzf.easyfloat.permission.PermissionUtils;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
/**
|
||||
* 悬浮窗设置页面
|
||||
*/
|
||||
public class FloatSettingsDialog extends AbsDialogFragment {
|
||||
private ImageView specialSwitch, specialMountSwitch;
|
||||
private boolean isFloat;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.view_float_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDialogStyle() {
|
||||
return R.style.dialog2;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canCancel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
specialSwitch = (ImageView) findViewById(R.id.special_switch);
|
||||
specialMountSwitch = (ImageView) findViewById(R.id.special_mount_switch);
|
||||
isFloat = IMLoginManager.get(getActivity()).isFloat();
|
||||
if (!isFloat) {
|
||||
ImgLoader.display(getContext(), R.mipmap.special_icon_off, specialSwitch);
|
||||
} else {
|
||||
ImgLoader.display(getContext(), R.mipmap.special_icon_on, specialSwitch);
|
||||
}
|
||||
boolean floatPermission = PermissionUtils.checkPermission(mContext);
|
||||
if (!floatPermission) {
|
||||
ImgLoader.display(getContext(), R.mipmap.special_icon_off, specialMountSwitch);
|
||||
} else {
|
||||
ImgLoader.display(getContext(), R.mipmap.special_icon_on, specialMountSwitch);
|
||||
}
|
||||
//礼物特效开关
|
||||
ViewClicksAntiShake.clicksAntiShake(specialSwitch, () -> {
|
||||
isFloat = !isFloat;
|
||||
if (!isFloat) {
|
||||
ImgLoader.display(getContext(), R.mipmap.special_icon_off, specialSwitch);
|
||||
} else {
|
||||
ImgLoader.display(getContext(), R.mipmap.special_icon_on, specialSwitch);
|
||||
}
|
||||
//更新特效开关
|
||||
IMLoginManager.get(getContext()).initFloat(isFloat);
|
||||
|
||||
}
|
||||
);
|
||||
//坐骑特效开关
|
||||
ViewClicksAntiShake.clicksAntiShake(specialMountSwitch, () -> {
|
||||
dismiss();
|
||||
PermissionUtils.requestPermission(getActivity(), new OnPermissionResult() {
|
||||
@Override
|
||||
public void permissionResult(boolean isFloat) {
|
||||
if (!isFloat) {
|
||||
ImgLoader.display(getContext(), R.mipmap.special_icon_off, specialSwitch);
|
||||
} else {
|
||||
ImgLoader.display(getContext(), R.mipmap.special_icon_on, specialSwitch);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setWindowAttributes(Window window) {
|
||||
window.setWindowAnimations(R.style.bottomToTopAnim);
|
||||
WindowManager.LayoutParams params = window.getAttributes();
|
||||
params.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
params.gravity = Gravity.BOTTOM;
|
||||
window.setAttributes(params);
|
||||
}
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
package com.yunbao.common.views.weight;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
|
||||
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.tencent.live2.V2TXLivePlayer;
|
||||
import com.tencent.live2.impl.V2TXLivePlayerImpl;
|
||||
import com.tencent.rtmp.ui.TXCloudVideoView;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.bean.LiveBean;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
|
||||
/**
|
||||
* 直播间悬浮窗管理
|
||||
*/
|
||||
public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
||||
|
||||
private static LiveFloatView instance;
|
||||
private LiveOnInvokeView liveOnInvokeView = null;
|
||||
private Activity mContext;
|
||||
private String url;
|
||||
private LiveBean mLiveBean;
|
||||
private int mLiveType;
|
||||
private int mLiveSDK;
|
||||
private int mLiveTypeVal;
|
||||
private FloatCallbacks.Builder builder;
|
||||
private String TAG = "LiveFloatView";
|
||||
private V2TXLivePlayer mPlayer;
|
||||
|
||||
public static LiveFloatView getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new LiveFloatView();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void builderFloat(Activity mContext, String url) {
|
||||
liveOnInvokeView = new LiveOnInvokeView();
|
||||
this.mContext = mContext;
|
||||
this.url = url;
|
||||
EasyFloat.with(mContext)
|
||||
.setTag(TAG)
|
||||
.setLayout(R.layout.view_flaot_live, liveOnInvokeView)
|
||||
.setShowPattern(ShowPattern.CURRENT_ACTIVITY)
|
||||
.setGravity(Gravity.END | Gravity.CENTER_VERTICAL, 0, 200)
|
||||
.registerCallback(this)
|
||||
.show();
|
||||
}
|
||||
|
||||
public void builderSystemFloat(Activity mContext, String url) {
|
||||
liveOnInvokeView = new LiveOnInvokeView();
|
||||
this.mContext = mContext;
|
||||
this.url = url;
|
||||
EasyFloat.with(mContext)
|
||||
.setTag(TAG)
|
||||
.setLayout(R.layout.view_flaot_live, liveOnInvokeView)
|
||||
.setShowPattern(ShowPattern.ALL_TIME)
|
||||
.setGravity(Gravity.END | Gravity.CENTER_VERTICAL, 0, 200)
|
||||
.registerCallback(this)
|
||||
.show();
|
||||
}
|
||||
|
||||
public LiveFloatView cacheLiveData(LiveBean mLiveBean, int mLiveType, int mLiveSDK, int mLiveTypeVal) {
|
||||
this.mLiveBean = mLiveBean;
|
||||
this.mLiveType = mLiveType;
|
||||
this.mLiveSDK = mLiveSDK;
|
||||
this.mLiveTypeVal = mLiveTypeVal;
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Unit invoke(FloatCallbacks.Builder builder) {
|
||||
this.builder = builder;
|
||||
builder.createResult((aBoolean, s, view) -> {
|
||||
Log.e("LiveFloatView", "aBoolean:" + aBoolean + "---------------------s:" + s);
|
||||
if (callback != null) {
|
||||
callback.invoke(aBoolean);
|
||||
}
|
||||
builder.dismiss(() -> {
|
||||
if (mPlayer != null && mPlayer.isPlaying() == 1) {
|
||||
mPlayer.stopPlay();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
builder.hide(view12 -> {
|
||||
if (mPlayer != null && mPlayer.isPlaying() == 1) {
|
||||
mPlayer.pauseAudio();
|
||||
mPlayer.pauseVideo();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
return null;
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 悬浮窗布局管理
|
||||
*/
|
||||
private class LiveOnInvokeView implements OnInvokeView {
|
||||
|
||||
@Override
|
||||
public void invoke(View view) {
|
||||
TXCloudVideoView videoView = view.findViewById(R.id.video_view);
|
||||
mPlayer = new V2TXLivePlayerImpl(mContext);
|
||||
mPlayer.setRenderView(videoView);
|
||||
mPlayer.startPlay(url);
|
||||
ViewClicksAntiShake.clicksAntiShake(view.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
mPlayer.stopPlay();
|
||||
EasyFloat.dismiss("LiveFloatView", true);
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
|
||||
mPlayer.stopPlay();
|
||||
RouteUtil.forwardLiveAudienceActivity(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private LiveFloatViewCallback callback;
|
||||
|
||||
public LiveFloatView setCallback(LiveFloatViewCallback callback) {
|
||||
this.callback = callback;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface LiveFloatViewCallback {
|
||||
void invoke(Boolean aBoolean);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user