直播内播放
This commit is contained in:
parent
dedb30d297
commit
05d4b29991
@ -0,0 +1,172 @@
|
|||||||
|
package com.yunbao.common.views.floatingview;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.app.Application;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class APPEasyFloat implements Application.ActivityLifecycleCallbacks {
|
||||||
|
private List<Class<?>> blackList = new ArrayList<>();
|
||||||
|
private int mLayout = 0;
|
||||||
|
private FrameLayout.LayoutParams mLayoutParams = getFloatingLayoutParams();
|
||||||
|
private boolean dragEnable = true;
|
||||||
|
private boolean autoMoveToEdge = true;
|
||||||
|
private static APPEasyFloat instance;
|
||||||
|
private MagnetViewListener magnetViewListener;
|
||||||
|
|
||||||
|
public APPEasyFloat setMagnetViewListener(MagnetViewListener magnetViewListener) {
|
||||||
|
this.magnetViewListener = magnetViewListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static APPEasyFloat getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new APPEasyFloat();
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public APPEasyFloat layout(int layout) {
|
||||||
|
mLayout = layout;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public APPEasyFloat layoutParams(FrameLayout.LayoutParams layoutParams) {
|
||||||
|
mLayoutParams = layoutParams;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public APPEasyFloat blackList(List<Class<?>> blackList) {
|
||||||
|
this.blackList.addAll(blackList);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public APPEasyFloat black(Class<?> back) {
|
||||||
|
this.blackList.add(back);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否可拖拽(位置是否固定)
|
||||||
|
*/
|
||||||
|
public APPEasyFloat dragEnable(boolean dragEnable) {
|
||||||
|
this.dragEnable = dragEnable;
|
||||||
|
FloatingView.get().dragEnable(dragEnable);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDragEnable() {
|
||||||
|
|
||||||
|
return dragEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否自动靠边
|
||||||
|
*/
|
||||||
|
public APPEasyFloat setAutoMoveToEdge(boolean autoMoveToEdge) {
|
||||||
|
this.autoMoveToEdge = autoMoveToEdge;
|
||||||
|
FloatingView.get().setAutoMoveToEdge(autoMoveToEdge);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAutoMoveToEdge() {
|
||||||
|
return autoMoveToEdge;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isActivityInValid(Activity activity) {
|
||||||
|
return blackList.contains(activity.getClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityStarted(@NonNull Activity activity) {
|
||||||
|
if (isActivityInValid(activity)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
initShow(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResumed(@NonNull Activity activity) {
|
||||||
|
if (isActivityInValid(activity))
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityPaused(@NonNull Activity activity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityStopped(@NonNull Activity activity) {
|
||||||
|
if (isActivityInValid(activity)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (magnetViewListener != null) {
|
||||||
|
magnetViewListener.onRemove();
|
||||||
|
}
|
||||||
|
FloatingView.get().detach(activity);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityDestroyed(@NonNull Activity activity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private FrameLayout.LayoutParams getFloatingLayoutParams() {
|
||||||
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
|
||||||
|
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||||
|
FrameLayout.LayoutParams.WRAP_CONTENT
|
||||||
|
);
|
||||||
|
params.gravity = Gravity.BOTTOM | Gravity.END;
|
||||||
|
params.setMargins(0, params.topMargin, params.rightMargin, 500);
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initShow(Activity activity) {
|
||||||
|
if (FloatingView.get().getContainer() == null) {
|
||||||
|
EnFloatingView enFloatingView = new EnFloatingView(activity, mLayout);
|
||||||
|
FloatingView.get().customView(enFloatingView);
|
||||||
|
if (magnetViewListener != null) {
|
||||||
|
magnetViewListener.invoke(enFloatingView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FloatingView.get().
|
||||||
|
layoutParams(mLayoutParams).
|
||||||
|
attach(activity).
|
||||||
|
dragEnable(dragEnable);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show(Activity activity) {
|
||||||
|
initShow(activity);
|
||||||
|
activity.getApplication().registerActivityLifecycleCallbacks(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dismiss(Activity activity) {
|
||||||
|
FloatingView.get().remove();
|
||||||
|
FloatingView.get().detach(activity);
|
||||||
|
activity.getApplication().unregisterActivityLifecycleCallbacks(this);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.yunbao.common.views.floatingview;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes;
|
||||||
|
import androidx.annotation.LayoutRes;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.yunbao.common.R;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName EnFloatingView
|
||||||
|
* @Description 悬浮窗
|
||||||
|
* @Author Yunpeng Li
|
||||||
|
* @Creation 2018/3/15 下午5:04
|
||||||
|
* @Mender Yunpeng Li
|
||||||
|
* @Modification 2018/3/15 下午5:04
|
||||||
|
*/
|
||||||
|
public class EnFloatingView extends FloatingMagnetView {
|
||||||
|
|
||||||
|
private final ImageView mIcon;
|
||||||
|
|
||||||
|
public EnFloatingView(@NonNull Context context) {
|
||||||
|
this(context, R.layout.view_flaot_live);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnFloatingView(@NonNull Context context, @LayoutRes int resource) {
|
||||||
|
super(context, null);
|
||||||
|
inflate(context, resource, this);
|
||||||
|
mIcon = findViewById(R.id.icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIconImage(@DrawableRes int resId){
|
||||||
|
mIcon.setImageResource(resId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,252 @@
|
|||||||
|
package com.yunbao.common.views.floatingview;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.ViewConfiguration;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import com.yunbao.common.views.floatingview.utils.SystemUtils;
|
||||||
|
|
||||||
|
|
||||||
|
public class FloatingMagnetView extends FrameLayout {
|
||||||
|
|
||||||
|
public static final int MARGIN_EDGE = 13;
|
||||||
|
private float mOriginalRawX;
|
||||||
|
private float mOriginalRawY;
|
||||||
|
private float mOriginalX;
|
||||||
|
private float mOriginalY;
|
||||||
|
private static final int TOUCH_TIME_THRESHOLD = 150;
|
||||||
|
private long mLastTouchDownTime;
|
||||||
|
protected MoveAnimator mMoveAnimator;
|
||||||
|
protected int mScreenWidth;
|
||||||
|
private int mScreenHeight;
|
||||||
|
private int mStatusBarHeight;
|
||||||
|
private boolean isNearestLeft = true;
|
||||||
|
private float mPortraitY;
|
||||||
|
private boolean dragEnable = true;
|
||||||
|
private boolean autoMoveToEdge = false;
|
||||||
|
|
||||||
|
|
||||||
|
public FloatingMagnetView(Context context) {
|
||||||
|
this(context, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FloatingMagnetView(Context context, AttributeSet attrs) {
|
||||||
|
this(context, attrs, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FloatingMagnetView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
|
super(context, attrs, defStyleAttr);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
mMoveAnimator = new MoveAnimator();
|
||||||
|
mStatusBarHeight = SystemUtils.getStatusBarHeight(getContext());
|
||||||
|
setClickable(true);
|
||||||
|
// updateSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dragEnable 是否可拖动
|
||||||
|
*/
|
||||||
|
public void updateDragState(boolean dragEnable) {
|
||||||
|
this.dragEnable = dragEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param autoMoveToEdge 是否自动到边缘
|
||||||
|
*/
|
||||||
|
public void setAutoMoveToEdge(boolean autoMoveToEdge) {
|
||||||
|
this.autoMoveToEdge = autoMoveToEdge;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
|
if (event == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch (event.getAction()) {
|
||||||
|
case MotionEvent.ACTION_DOWN:
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_MOVE:
|
||||||
|
updateViewPosition(event);
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_UP:
|
||||||
|
clearPortraitY();
|
||||||
|
if (autoMoveToEdge) {
|
||||||
|
moveToEdge();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void updateViewPosition(MotionEvent event) {
|
||||||
|
//dragEnable
|
||||||
|
if (!dragEnable) return;
|
||||||
|
//占满width或height时不用变
|
||||||
|
LayoutParams params = (LayoutParams) getLayoutParams();
|
||||||
|
//限制不可超出屏幕宽度
|
||||||
|
float desX = mOriginalX + event.getRawX() - mOriginalRawX;
|
||||||
|
if (params.width == LayoutParams.WRAP_CONTENT) {
|
||||||
|
if (desX < 0) {
|
||||||
|
desX = MARGIN_EDGE;
|
||||||
|
}
|
||||||
|
if (desX > mScreenWidth) {
|
||||||
|
desX = mScreenWidth - MARGIN_EDGE;
|
||||||
|
}
|
||||||
|
setX(desX);
|
||||||
|
}
|
||||||
|
// 限制不可超出屏幕高度
|
||||||
|
float desY = mOriginalY + event.getRawY() - mOriginalRawY;
|
||||||
|
if (params.height == LayoutParams.WRAP_CONTENT) {
|
||||||
|
if (desY < mStatusBarHeight) {
|
||||||
|
desY = mStatusBarHeight;
|
||||||
|
}
|
||||||
|
if (desY > mScreenHeight - getHeight()) {
|
||||||
|
desY = mScreenHeight - getHeight();
|
||||||
|
}
|
||||||
|
setY(desY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changeOriginalTouchParams(MotionEvent event) {
|
||||||
|
mOriginalX = getX();
|
||||||
|
mOriginalY = getY();
|
||||||
|
mOriginalRawX = event.getRawX();
|
||||||
|
mOriginalRawY = event.getRawY();
|
||||||
|
mLastTouchDownTime = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateSize() {
|
||||||
|
ViewGroup viewGroup = (ViewGroup) getParent();
|
||||||
|
if (viewGroup != null) {
|
||||||
|
mScreenWidth = viewGroup.getWidth() - getWidth();
|
||||||
|
mScreenHeight = viewGroup.getHeight();
|
||||||
|
}
|
||||||
|
// mScreenWidth = (SystemUtils.getScreenWidth(getContext()) - this.getWidth());
|
||||||
|
// mScreenHeight = SystemUtils.getScreenHeight(getContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveToEdge() {
|
||||||
|
//dragEnable
|
||||||
|
if (!dragEnable) return;
|
||||||
|
moveToEdge(isNearestLeft(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void moveToEdge(boolean isLeft, boolean isLandscape) {
|
||||||
|
float moveDistance = isLeft ? MARGIN_EDGE : mScreenWidth - MARGIN_EDGE;
|
||||||
|
float y = getY();
|
||||||
|
if (!isLandscape && mPortraitY != 0) {
|
||||||
|
y = mPortraitY;
|
||||||
|
clearPortraitY();
|
||||||
|
}
|
||||||
|
mMoveAnimator.start(moveDistance, Math.min(Math.max(0, y), mScreenHeight - getHeight()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearPortraitY() {
|
||||||
|
mPortraitY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isNearestLeft() {
|
||||||
|
int middle = mScreenWidth / 2;
|
||||||
|
isNearestLeft = getX() < middle;
|
||||||
|
return isNearestLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected class MoveAnimator implements Runnable {
|
||||||
|
|
||||||
|
private Handler handler = new Handler(Looper.getMainLooper());
|
||||||
|
private float destinationX;
|
||||||
|
private float destinationY;
|
||||||
|
private long startingTime;
|
||||||
|
|
||||||
|
void start(float x, float y) {
|
||||||
|
this.destinationX = x;
|
||||||
|
this.destinationY = y;
|
||||||
|
startingTime = System.currentTimeMillis();
|
||||||
|
handler.post(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (getRootView() == null || getRootView().getParent() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
float progress = Math.min(1, (System.currentTimeMillis() - startingTime) / 400f);
|
||||||
|
float deltaX = (destinationX - getX()) * progress;
|
||||||
|
float deltaY = (destinationY - getY()) * progress;
|
||||||
|
move(deltaX, deltaY);
|
||||||
|
if (progress < 1) {
|
||||||
|
handler.post(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stop() {
|
||||||
|
handler.removeCallbacks(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void move(float deltaX, float deltaY) {
|
||||||
|
setX(getX() + deltaX);
|
||||||
|
setY(getY() + deltaY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onConfigurationChanged(Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
if (getParent() != null) {
|
||||||
|
final boolean isLandscape = newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE;
|
||||||
|
markPortraitY(isLandscape);
|
||||||
|
((ViewGroup) getParent()).post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateSize();
|
||||||
|
moveToEdge(isNearestLeft, isLandscape);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void markPortraitY(boolean isLandscape) {
|
||||||
|
if (isLandscape) {
|
||||||
|
mPortraitY = getY();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private float touchDownX;
|
||||||
|
|
||||||
|
private void initTouchDown(MotionEvent ev) {
|
||||||
|
changeOriginalTouchParams(ev);
|
||||||
|
updateSize();
|
||||||
|
mMoveAnimator.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
|
boolean intercepted = false;
|
||||||
|
switch (ev.getActionMasked()) {
|
||||||
|
case MotionEvent.ACTION_DOWN:
|
||||||
|
intercepted = false;
|
||||||
|
touchDownX = ev.getX();
|
||||||
|
initTouchDown(ev);
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_MOVE:
|
||||||
|
intercepted = Math.abs(touchDownX - ev.getX()) >= ViewConfiguration.get(getContext()).getScaledTouchSlop();
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_UP:
|
||||||
|
intercepted = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return intercepted;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,219 @@
|
|||||||
|
package com.yunbao.common.views.floatingview;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.RelativeLayout;
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes;
|
||||||
|
import androidx.annotation.LayoutRes;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
|
||||||
|
import com.yunbao.common.R;
|
||||||
|
import com.yunbao.common.views.floatingview.utils.EnContext;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName FloatingView
|
||||||
|
* @Description 悬浮窗管理器
|
||||||
|
* @Author Yunpeng Li
|
||||||
|
* @Creation 2018/3/15 下午5:05
|
||||||
|
* @Mender Yunpeng Li
|
||||||
|
* @Modification 2018/3/15 下午5:05
|
||||||
|
*/
|
||||||
|
public class FloatingView implements IFloatingView {
|
||||||
|
|
||||||
|
private FloatingMagnetView mEnFloatingView;
|
||||||
|
private static volatile FloatingView mInstance;
|
||||||
|
private WeakReference<FrameLayout> mContainer;
|
||||||
|
@LayoutRes
|
||||||
|
private int mLayoutId = R.layout.view_flaot_live;
|
||||||
|
@DrawableRes
|
||||||
|
private int mIconRes = R.drawable.com_facebook_button_icon;
|
||||||
|
private ViewGroup.LayoutParams mLayoutParams = getParams();
|
||||||
|
|
||||||
|
private FloatingView() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FloatingView get() {
|
||||||
|
if (mInstance == null) {
|
||||||
|
synchronized (FloatingView.class) {
|
||||||
|
if (mInstance == null) {
|
||||||
|
mInstance = new FloatingView();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView remove() {
|
||||||
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (mEnFloatingView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ViewCompat.isAttachedToWindow(mEnFloatingView) && getContainer() != null) {
|
||||||
|
getContainer().removeView(mEnFloatingView);
|
||||||
|
}
|
||||||
|
mEnFloatingView = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensureFloatingView() {
|
||||||
|
synchronized (this) {
|
||||||
|
if (mEnFloatingView != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
EnFloatingView enFloatingView = new EnFloatingView(EnContext.get(), mLayoutId);
|
||||||
|
mEnFloatingView = enFloatingView;
|
||||||
|
enFloatingView.setLayoutParams(mLayoutParams);
|
||||||
|
enFloatingView.setIconImage(mIconRes);
|
||||||
|
addViewToWindow(enFloatingView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView add() {
|
||||||
|
ensureFloatingView();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView attach(Activity activity) {
|
||||||
|
attach(getActivityRoot(activity));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView attach(FrameLayout container) {
|
||||||
|
if (container == null || mEnFloatingView == null) {
|
||||||
|
mContainer = new WeakReference<>(container);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
if (mEnFloatingView.getParent() == container) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
if (mEnFloatingView.getParent() != null) {
|
||||||
|
((ViewGroup) mEnFloatingView.getParent()).removeView(mEnFloatingView);
|
||||||
|
}
|
||||||
|
mContainer = new WeakReference<>(container);
|
||||||
|
container.addView(mEnFloatingView);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView detach(Activity activity) {
|
||||||
|
detach(getActivityRoot(activity));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView detach(FrameLayout container) {
|
||||||
|
if (mEnFloatingView != null && container != null && ViewCompat.isAttachedToWindow(mEnFloatingView)) {
|
||||||
|
container.removeView(mEnFloatingView);
|
||||||
|
}
|
||||||
|
if (getContainer() == container) {
|
||||||
|
mContainer = null;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingMagnetView getView() {
|
||||||
|
return mEnFloatingView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView icon(@DrawableRes int resId) {
|
||||||
|
mIconRes = resId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView customView(FloatingMagnetView viewGroup) {
|
||||||
|
mEnFloatingView = viewGroup;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView customView(@LayoutRes int resource) {
|
||||||
|
mLayoutId = resource;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView layoutParams(ViewGroup.LayoutParams params) {
|
||||||
|
mLayoutParams = params;
|
||||||
|
if (mEnFloatingView != null) {
|
||||||
|
mEnFloatingView.setLayoutParams(params);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView listener(MagnetViewListener magnetViewListener) {
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView dragEnable(boolean dragEnable) {
|
||||||
|
if (mEnFloatingView != null) {
|
||||||
|
mEnFloatingView.updateDragState(dragEnable);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FloatingView setAutoMoveToEdge(boolean autoMoveToEdge) {
|
||||||
|
if (mEnFloatingView != null) {
|
||||||
|
mEnFloatingView.setAutoMoveToEdge(autoMoveToEdge);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addViewToWindow(final View view) {
|
||||||
|
if (getContainer() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getContainer().addView(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FrameLayout getContainer() {
|
||||||
|
if (mContainer == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return mContainer.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private FrameLayout.LayoutParams getParams() {
|
||||||
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
|
||||||
|
RelativeLayout.LayoutParams.WRAP_CONTENT,
|
||||||
|
RelativeLayout.LayoutParams.WRAP_CONTENT);
|
||||||
|
params.gravity = Gravity.BOTTOM | Gravity.START;
|
||||||
|
params.setMargins(13, params.topMargin, params.rightMargin, 500);
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
private FrameLayout getActivityRoot(Activity activity) {
|
||||||
|
if (activity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return (FrameLayout) activity.getWindow().getDecorView().findViewById(android.R.id.content);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.yunbao.common.views.floatingview;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes;
|
||||||
|
import androidx.annotation.LayoutRes;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Yunpeng Li on 2018/3/15.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface IFloatingView {
|
||||||
|
|
||||||
|
FloatingView remove();
|
||||||
|
|
||||||
|
FloatingView add();
|
||||||
|
|
||||||
|
FloatingView attach(Activity activity);
|
||||||
|
|
||||||
|
FloatingView attach(FrameLayout container);
|
||||||
|
|
||||||
|
FloatingView detach(Activity activity);
|
||||||
|
|
||||||
|
FloatingView detach(FrameLayout container);
|
||||||
|
|
||||||
|
FloatingMagnetView getView();
|
||||||
|
|
||||||
|
FloatingView icon(@DrawableRes int resId);
|
||||||
|
|
||||||
|
FloatingView customView(FloatingMagnetView viewGroup);
|
||||||
|
|
||||||
|
FloatingView customView(@LayoutRes int resource);
|
||||||
|
|
||||||
|
FloatingView layoutParams(ViewGroup.LayoutParams params);
|
||||||
|
|
||||||
|
FloatingView listener(MagnetViewListener magnetViewListener);
|
||||||
|
|
||||||
|
FloatingView dragEnable(boolean dragEnable);
|
||||||
|
|
||||||
|
FloatingView setAutoMoveToEdge(boolean autoMoveToEdge);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.yunbao.common.views.floatingview;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by liyunpeng on 17/11/29.
|
||||||
|
*/
|
||||||
|
public interface MagnetViewListener {
|
||||||
|
void invoke(FloatingMagnetView magnetView);
|
||||||
|
|
||||||
|
void onRemove();
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.yunbao.common.views.floatingview.utils;
|
||||||
|
|
||||||
|
import android.app.Application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Yunpeng Li on 2018/11/8.
|
||||||
|
*/
|
||||||
|
public class EnContext {
|
||||||
|
|
||||||
|
private static final Application INSTANCE;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Application app = null;
|
||||||
|
try {
|
||||||
|
app = (Application) Class.forName("android.app.AppGlobals").getMethod("getInitialApplication").invoke(null);
|
||||||
|
if (app == null)
|
||||||
|
throw new IllegalStateException("Static initialization of Applications must be on main thread.");
|
||||||
|
} catch (final Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
try {
|
||||||
|
app = (Application) Class.forName("android.app.ActivityThread").getMethod("currentApplication").invoke(null);
|
||||||
|
} catch (final Exception ex) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
INSTANCE = app;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Application get() {
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.yunbao.common.views.floatingview.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Yunpeng Li on 2018/3/15.
|
||||||
|
*/
|
||||||
|
public class SystemUtils {
|
||||||
|
|
||||||
|
public static int getStatusBarHeight(Context context) {
|
||||||
|
int result = 0;
|
||||||
|
int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||||
|
if (resourceId > 0) {
|
||||||
|
result = context.getResources().getDimensionPixelSize(resourceId);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getScreenWidth(Context context) {
|
||||||
|
int screenWith = -1;
|
||||||
|
try {
|
||||||
|
screenWith = context.getResources().getDisplayMetrics().widthPixels;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return screenWith;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getScreenHeight(Context context) {
|
||||||
|
int screenHeight = -1;
|
||||||
|
try {
|
||||||
|
screenHeight = context.getResources().getDisplayMetrics().heightPixels;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return screenHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -15,6 +15,9 @@ import com.tencent.rtmp.ui.TXCloudVideoView;
|
|||||||
import com.yunbao.common.R;
|
import com.yunbao.common.R;
|
||||||
import com.yunbao.common.bean.LiveBean;
|
import com.yunbao.common.bean.LiveBean;
|
||||||
import com.yunbao.common.utils.RouteUtil;
|
import com.yunbao.common.utils.RouteUtil;
|
||||||
|
import com.yunbao.common.views.floatingview.APPEasyFloat;
|
||||||
|
import com.yunbao.common.views.floatingview.FloatingMagnetView;
|
||||||
|
import com.yunbao.common.views.floatingview.MagnetViewListener;
|
||||||
|
|
||||||
import kotlin.Unit;
|
import kotlin.Unit;
|
||||||
import kotlin.jvm.functions.Function1;
|
import kotlin.jvm.functions.Function1;
|
||||||
@ -44,17 +47,41 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void builderFloat(Activity mContext, String url) {
|
public void builderFloat(Activity mContext, String url,Class<?> back) {
|
||||||
liveOnInvokeView = new LiveOnInvokeView();
|
|
||||||
this.mContext = mContext;
|
this.mContext = mContext;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
EasyFloat.with(mContext)
|
APPEasyFloat.getInstance().layout(R.layout.view_flaot_live)
|
||||||
.setTag(TAG)
|
.dragEnable(true)
|
||||||
.setLayout(R.layout.view_flaot_live, liveOnInvokeView)
|
.setAutoMoveToEdge(true)
|
||||||
.setShowPattern(ShowPattern.CURRENT_ACTIVITY)
|
.black(back)
|
||||||
.setGravity(Gravity.END | Gravity.CENTER_VERTICAL, 0, 200)
|
.setMagnetViewListener(new MagnetViewListener() {
|
||||||
.registerCallback(this)
|
@Override
|
||||||
.show();
|
public void invoke(FloatingMagnetView magnetView) {
|
||||||
|
TXCloudVideoView videoView = magnetView.findViewById(R.id.video_view);
|
||||||
|
mPlayer = new V2TXLivePlayerImpl(mContext);
|
||||||
|
mPlayer.setRenderView(videoView);
|
||||||
|
mPlayer.startPlay(url);
|
||||||
|
ViewClicksAntiShake.clicksAntiShake(magnetView.findViewById(R.id.btn_close), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||||
|
@Override
|
||||||
|
public void onViewClicks() {
|
||||||
|
mPlayer.stopPlay();
|
||||||
|
APPEasyFloat.getInstance().dismiss(mContext);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ViewClicksAntiShake.clicksAntiShake(videoView, () -> {
|
||||||
|
mPlayer.stopPlay();
|
||||||
|
APPEasyFloat.getInstance().dismiss(mContext);
|
||||||
|
RouteUtil.forwardLiveAudienceActivity(mLiveBean, mLiveType, mLiveSDK, mLiveTypeVal);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRemove() {
|
||||||
|
mPlayer.stopPlay();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show(mContext);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void builderSystemFloat(Activity mContext, String url) {
|
public void builderSystemFloat(Activity mContext, String url) {
|
||||||
@ -65,6 +92,7 @@ public class LiveFloatView implements Function1<FloatCallbacks.Builder, Unit> {
|
|||||||
.setTag(TAG)
|
.setTag(TAG)
|
||||||
.setLayout(R.layout.view_flaot_live, liveOnInvokeView)
|
.setLayout(R.layout.view_flaot_live, liveOnInvokeView)
|
||||||
.setShowPattern(ShowPattern.ALL_TIME)
|
.setShowPattern(ShowPattern.ALL_TIME)
|
||||||
|
.setFilter()
|
||||||
.setGravity(Gravity.END | Gravity.CENTER_VERTICAL, 0, 200)
|
.setGravity(Gravity.END | Gravity.CENTER_VERTICAL, 0, 200)
|
||||||
.registerCallback(this)
|
.registerCallback(this)
|
||||||
.show();
|
.show();
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.yunbao.live">
|
package="com.yunbao.live">
|
||||||
|
<!--com.kugou.fanxing.allinone.watch.liveroominone.media.FALiveRoomInOneActivity"-->
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
|
||||||
@ -14,13 +15,21 @@
|
|||||||
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
|
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.LiveAudienceActivity"
|
android:name=".activity.LiveAudienceActivity"
|
||||||
android:screenOrientation="portrait"
|
android:configChanges="screenLayout|orientation"
|
||||||
android:theme="@style/AppTheme"
|
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
|
|
||||||
|
android:theme="@style/AppTheme"
|
||||||
|
android:windowSoftInputMode="adjustPan|stateAlwaysHidden"
|
||||||
|
tools:targetApi="n" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.LiveChooseClassActivity"
|
android:name=".activity.LiveChooseClassActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
|
<activity
|
||||||
|
android:name=".activity.FALiveRoomInOneActivity"
|
||||||
|
android:resizeableActivity="true"
|
||||||
|
android:screenOrientation="portrait"
|
||||||
|
android:supportsPictureInPicture="true"
|
||||||
|
tools:targetApi="n" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.LiveReportActivity"
|
android:name=".activity.LiveReportActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package com.yunbao.live.activity;
|
||||||
|
|
||||||
|
import android.app.PictureInPictureParams;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
|
||||||
|
import com.yunbao.common.activity.AbsActivity;
|
||||||
|
import com.yunbao.live.R;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 画中画act
|
||||||
|
*/
|
||||||
|
public class FALiveRoomInOneActivity extends AbsActivity {
|
||||||
|
@Override
|
||||||
|
protected int getLayoutId() {
|
||||||
|
return R.layout.view_flaot_live;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
|
@Override
|
||||||
|
public void main() {
|
||||||
|
super.init();
|
||||||
|
PictureInPictureParams params = new PictureInPictureParams.Builder()
|
||||||
|
.build();
|
||||||
|
enterPictureInPictureMode(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode, Configuration newConfig) {
|
||||||
|
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,9 +3,12 @@ package com.yunbao.live.activity;
|
|||||||
import static com.yunbao.live.views.LivePlayRyViewHolder.Micing;
|
import static com.yunbao.live.views.LivePlayRyViewHolder.Micing;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.PictureInPictureParams;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@ -17,6 +20,11 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import androidx.annotation.IdRes;
|
import androidx.annotation.IdRes;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.RequiresApi;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
|
import androidx.core.view.WindowInsetsControllerCompat;
|
||||||
import androidx.viewpager.widget.ViewPager;
|
import androidx.viewpager.widget.ViewPager;
|
||||||
|
|
||||||
import com.adjust.sdk.Adjust;
|
import com.adjust.sdk.Adjust;
|
||||||
@ -650,6 +658,22 @@ public class LiveAudienceActivity extends LiveActivity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfigurationChanged(@NonNull Configuration newConfig) {
|
||||||
|
super.onConfigurationChanged(newConfig);
|
||||||
|
adjustFullScreen(newConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void adjustFullScreen(Configuration config) {
|
||||||
|
final WindowInsetsControllerCompat insetsController = ViewCompat.getWindowInsetsController(getWindow().getDecorView());
|
||||||
|
if (insetsController == null)
|
||||||
|
return;
|
||||||
|
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
insetsController.hide(WindowInsetsCompat.Type.systemBars());
|
||||||
|
} else {
|
||||||
|
insetsController.show(WindowInsetsCompat.Type.systemBars());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跳转页面或者弹窗展示
|
* 跳转页面或者弹窗展示
|
||||||
@ -1057,4 +1081,6 @@ public class LiveAudienceActivity extends LiveActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,7 @@ import com.yunbao.common.utils.WordUtil;
|
|||||||
import com.yunbao.common.utils.formatBigNum;
|
import com.yunbao.common.utils.formatBigNum;
|
||||||
import com.yunbao.common.views.weight.LiveFloatView;
|
import com.yunbao.common.views.weight.LiveFloatView;
|
||||||
import com.yunbao.live.R;
|
import com.yunbao.live.R;
|
||||||
|
import com.yunbao.live.activity.FALiveRoomInOneActivity;
|
||||||
import com.yunbao.live.activity.LiveActivity;
|
import com.yunbao.live.activity.LiveActivity;
|
||||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||||
import com.yunbao.live.bean.LiveBuyGuardMsgBean;
|
import com.yunbao.live.bean.LiveBuyGuardMsgBean;
|
||||||
@ -373,7 +374,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
|
|||||||
.setmLiveType(mLiveType)
|
.setmLiveType(mLiveType)
|
||||||
.setmLiveTypeVal(mLiveTypeVal));
|
.setmLiveTypeVal(mLiveTypeVal));
|
||||||
}
|
}
|
||||||
|
//
|
||||||
mContext.finish();
|
mContext.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,7 @@ import com.yunbao.common.utils.ToastUtil;
|
|||||||
import com.yunbao.common.utils.VersionUtil;
|
import com.yunbao.common.utils.VersionUtil;
|
||||||
import com.yunbao.common.utils.WordUtil;
|
import com.yunbao.common.utils.WordUtil;
|
||||||
import com.yunbao.common.views.AbsMainViewHolder;
|
import com.yunbao.common.views.AbsMainViewHolder;
|
||||||
|
import com.yunbao.common.views.weight.LiveFloatView;
|
||||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||||
import com.yunbao.live.http.LiveHttpConsts;
|
import com.yunbao.live.http.LiveHttpConsts;
|
||||||
@ -91,7 +92,6 @@ import com.yunbao.live.http.LiveHttpUtil;
|
|||||||
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
|
import com.yunbao.live.presenter.LiveRoomCheckLivePresenter;
|
||||||
import com.yunbao.live.utils.LiveStorge;
|
import com.yunbao.live.utils.LiveStorge;
|
||||||
import com.yunbao.live.views.ChatListViewHolder;
|
import com.yunbao.live.views.ChatListViewHolder;
|
||||||
import com.yunbao.common.views.weight.LiveFloatView;
|
|
||||||
import com.yunbao.main.R;
|
import com.yunbao.main.R;
|
||||||
import com.yunbao.main.dialog.MainStartDialogFragment;
|
import com.yunbao.main.dialog.MainStartDialogFragment;
|
||||||
import com.yunbao.main.dialog.ReturnUserDialog;
|
import com.yunbao.main.dialog.ReturnUserDialog;
|
||||||
@ -1254,15 +1254,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
|||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onLiveFloatEvent(LiveFloatEvent event) {
|
public void onLiveFloatEvent(LiveFloatEvent event) {
|
||||||
if (event.isTime()) {
|
|
||||||
new Handler().postDelayed(() -> LiveFloatView.getInstance()
|
new Handler().post(() -> LiveFloatView.getInstance()
|
||||||
.cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK(), event.getmLiveTypeVal())
|
.cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK(), event.getmLiveTypeVal())
|
||||||
.builderFloat(mContext, event.getmLiveBean().getPull()), 800);
|
.builderFloat(mContext, event.getmLiveBean().getPull(), LiveAudienceActivity.class));
|
||||||
} else {
|
|
||||||
new Handler().post(() -> LiveFloatView.getInstance()
|
|
||||||
.cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK(), event.getmLiveTypeVal())
|
|
||||||
.builderFloat(mContext, event.getmLiveBean().getPull()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user