961 lines
38 KiB
Java
961 lines
38 KiB
Java
package com.yunbao.live.views;
|
||
|
||
import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.WISH_LIST_UPDATE;
|
||
|
||
import android.app.Dialog;
|
||
import android.content.Context;
|
||
import android.graphics.drawable.Drawable;
|
||
import android.net.ConnectivityManager;
|
||
import android.net.NetworkInfo;
|
||
import android.os.Build;
|
||
import android.os.Bundle;
|
||
import android.os.Handler;
|
||
import android.os.Looper;
|
||
import android.text.Html;
|
||
import android.text.TextUtils;
|
||
import android.util.Log;
|
||
import android.view.View;
|
||
import android.view.ViewGroup;
|
||
import android.view.inputmethod.InputMethodManager;
|
||
import android.widget.EditText;
|
||
import android.widget.ImageView;
|
||
import android.widget.TextView;
|
||
|
||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||
import androidx.core.content.ContextCompat;
|
||
|
||
import com.lxj.xpopup.XPopup;
|
||
import com.lxj.xpopup.core.BasePopupView;
|
||
import com.lxj.xpopup.interfaces.XPopupCallback;
|
||
import com.yunbao.common.CommonAppConfig;
|
||
import com.yunbao.common.Constants;
|
||
import com.yunbao.common.activity.WebViewActivity;
|
||
import com.yunbao.common.bean.IMLoginModel;
|
||
import com.yunbao.common.bean.LiveAnchorCallMeModel;
|
||
import com.yunbao.common.bean.LiveAnchorSayModel;
|
||
import com.yunbao.common.bean.LiveClassBean;
|
||
import com.yunbao.common.bean.LiveRoomTypeBean;
|
||
import com.yunbao.common.bean.UserBean;
|
||
import com.yunbao.common.event.LivePushRyEvent;
|
||
import com.yunbao.common.glide.ImgLoader;
|
||
import com.yunbao.common.http.HttpCallback;
|
||
import com.yunbao.common.http.LiveHttpConsts;
|
||
import com.yunbao.common.http.LiveHttpUtil;
|
||
import com.yunbao.common.interfaces.CommonCallback;
|
||
import com.yunbao.common.interfaces.ImageResultCallback;
|
||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||
import com.yunbao.common.manager.IMLoginManager;
|
||
import com.yunbao.common.utils.Bus;
|
||
import com.yunbao.common.utils.DialogUitl;
|
||
import com.yunbao.common.utils.L;
|
||
import com.yunbao.common.utils.ProcessImageUtil;
|
||
import com.yunbao.common.utils.RouteUtil;
|
||
import com.yunbao.common.utils.StringUtil;
|
||
import com.yunbao.common.utils.ToastUtil;
|
||
import com.yunbao.common.utils.WordUtil;
|
||
import com.yunbao.common.views.AbsViewHolder;
|
||
import com.yunbao.common.views.LiveClarityCustomPopup;
|
||
import com.yunbao.common.views.LiveNewWishListPopup;
|
||
import com.yunbao.common.views.LiveOpenCustomPopup;
|
||
import com.yunbao.common.views.LiveRobotSettingCustomPopup;
|
||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||
import com.yunbao.faceunity.FaceManager;
|
||
import com.yunbao.live.R;
|
||
import com.yunbao.live.activity.LiveActivity;
|
||
import com.yunbao.live.activity.LiveSwAnchorActivity;
|
||
import com.yunbao.live.dialog.LiveAnchorEditCallMeDialog;
|
||
import com.yunbao.live.dialog.LiveAnchorSayPopDialog;
|
||
import com.yunbao.live.dialog.LiveFaceUnityDialogFragment;
|
||
import com.yunbao.live.dialog.LiveFaceUnityDialogNewFragment;
|
||
import com.yunbao.live.dialog.LiveNewRoomClassDialogFragment;
|
||
import com.yunbao.live.dialog.LiveNewRoomTypeDialogFragment;
|
||
import com.yunbao.live.dialog.LiveTimeDialogFragment;
|
||
import com.yunbao.live.event.LiveAudienceEvent;
|
||
|
||
import org.greenrobot.eventbus.Subscribe;
|
||
import org.greenrobot.eventbus.ThreadMode;
|
||
|
||
import java.io.File;
|
||
import java.util.Locale;
|
||
|
||
import io.agora.beautyapi.faceunity.agora.SWManager;
|
||
|
||
public class LiveNewReadySwViewHolder extends AbsViewHolder implements View.OnClickListener {
|
||
|
||
private ConstraintLayout mAvatar, mRootView;
|
||
private TextView mCoverText;
|
||
private EditText mEditTitle;
|
||
private ProcessImageUtil mImageUtil;
|
||
private File mAvatarFile;
|
||
private TextView mLiveClass, anchorAgreement;
|
||
private TextView mLiveTypeTextView, liveClarity;//房间类型TextView
|
||
private TextView mLiveWishListTextView;//心愿单TextView
|
||
private int mLiveClassID;//直播频道id
|
||
private int mLiveType;//房间类型
|
||
private int mLiveTypeVal;//房间密码,门票收费金额
|
||
private int mLiveTimeCoin;//计时收费金额
|
||
private boolean mOpenLocation = true;
|
||
private int mLiveSdk;
|
||
private LiveClassBean classBean;
|
||
private FaceManager manager;
|
||
private TextView faceTextView;//提示人脸未检测到的TextView
|
||
private ImageView imgClarity, selectorProtocol;
|
||
private int selectClarity = 1;
|
||
private LiveOpenCustomPopup liveOpenCustomPopup;
|
||
private boolean selector = true;
|
||
private String mLiveUid;
|
||
|
||
public LiveNewReadySwViewHolder(Context context, ViewGroup parentView, int liveSdk) {
|
||
super(context, parentView, liveSdk);
|
||
}
|
||
|
||
@Override
|
||
protected void processArguments(Object... args) {
|
||
if (args.length > 0) {
|
||
mLiveSdk = (int) args[0];
|
||
}
|
||
}
|
||
|
||
@Override
|
||
protected int getLayoutId() {
|
||
return R.layout.view_new_live_ready;
|
||
}
|
||
|
||
@Override
|
||
public void init() {
|
||
mRootView = (ConstraintLayout) findViewById(R.id.traceroute_rootview);
|
||
imgClarity = (ImageView) findViewById(R.id.img_clarity);
|
||
selectorProtocol = (ImageView) findViewById(R.id.selector_protocol);
|
||
liveClarity = (TextView) findViewById(R.id.live_clarity);
|
||
anchorAgreement = (TextView) findViewById(R.id.anchor_agreement);
|
||
mRootView.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View view) {
|
||
InputMethodManager imm = (InputMethodManager)
|
||
mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||
}
|
||
});
|
||
|
||
mAvatar = (ConstraintLayout) findViewById(R.id.avatar);
|
||
mAvatar.setOnClickListener(this);
|
||
UserBean u = CommonAppConfig.getInstance().getUserBean();
|
||
ImgLoader.displayDrawable(mContext, u.getAvatar(), new ImgLoader.DrawableCallback() {
|
||
@Override
|
||
public void onLoadSuccess(Drawable drawable) {
|
||
mAvatar.setBackground(drawable);
|
||
}
|
||
|
||
@Override
|
||
public void onLoadFailed() {
|
||
|
||
}
|
||
});
|
||
mCoverText = (TextView) findViewById(R.id.cover_text);
|
||
mEditTitle = (EditText) findViewById(R.id.edit_title);
|
||
findViewById(R.id.btn_room_type).setOnClickListener(this);
|
||
mOpenLocation = true;
|
||
mLiveClass = (TextView) findViewById(R.id.live_class);
|
||
mLiveTypeTextView = (TextView) findViewById(R.id.text_room_type);
|
||
mLiveWishListTextView = (TextView) findViewById(R.id.text_wishlist);
|
||
faceTextView = (TextView) findViewById(R.id.faceTextView);
|
||
|
||
mImageUtil = ((LiveActivity) mContext).getProcessImageUtil();
|
||
mImageUtil.setImageResultCallback(new ImageResultCallback() {
|
||
|
||
@Override
|
||
public void beforeCamera() {
|
||
((LiveSwAnchorActivity) mContext).beforeCamera();
|
||
}
|
||
|
||
@Override
|
||
public void onSuccess(File file) {
|
||
if (file != null) {
|
||
ImgLoader.displayFileDrawable(mContext, file, new ImgLoader.DrawableCallback() {
|
||
@Override
|
||
public void onLoadSuccess(Drawable drawable) {
|
||
mAvatar.setBackground(drawable);
|
||
}
|
||
|
||
@Override
|
||
public void onLoadFailed() {
|
||
|
||
}
|
||
});
|
||
if (mAvatarFile == null) {
|
||
mCoverText.setText(mContext.getString(R.string.live_cover_2));
|
||
mCoverText.setBackground(ContextCompat.getDrawable(mContext, R.drawable.bg_live_cover));
|
||
}
|
||
mAvatarFile = file;
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onFailure() {
|
||
}
|
||
});
|
||
findViewById(R.id.btn_camera).setOnClickListener(this);
|
||
findViewById(R.id.btn_live_class).setOnClickListener(this);
|
||
findViewById(R.id.btn_close).setOnClickListener(this);
|
||
findViewById(R.id.btn_beauty).setOnClickListener(this);
|
||
findViewById(R.id.btn_robot).setOnClickListener(this);
|
||
findViewById(R.id.btn_start_live).setOnClickListener(this);
|
||
findViewById(R.id.btn_wishlist).setOnClickListener(this);
|
||
findViewById(R.id.btn_horizontally).setOnClickListener(this);
|
||
findViewById(R.id.anchor_agreement_layout).setOnClickListener(this);
|
||
findViewById(R.id.btn_live_anchor_say).setOnClickListener(this);
|
||
findViewById(R.id.btn_live_anchor_call_me).setOnClickListener(this);
|
||
|
||
if (manager != null) {
|
||
manager.setFaceStatusChanged(new FaceManager.FaceStatusChanged() {
|
||
final Handler handler = new Handler(Looper.getMainLooper());
|
||
|
||
@Override
|
||
public void onFaceChanged(int num) {
|
||
handler.post(() -> {
|
||
if (num == 0) {
|
||
faceTextView.setVisibility(View.VISIBLE);
|
||
} else {
|
||
faceTextView.setVisibility(View.GONE);
|
||
}
|
||
});
|
||
}
|
||
});
|
||
//新美颜
|
||
setFaceUnity(true);
|
||
|
||
}
|
||
//设置清晰度
|
||
// DeviceUtils.getMemory(mContext); //获取可用内存
|
||
// DeviceUtils.getNetSpeed(mContext);//获取当前上传网速
|
||
// Log.e("网速和内存", "内存:" + + " 网速:" + DeviceUtils.getNetSpeed(mContext));
|
||
|
||
IMLoginManager.get(mContext).setSelectClarity(selectClarity);
|
||
//setSelectClarity(IMLoginManager.get(mContext).getSelectClarity());
|
||
ViewClicksAntiShake
|
||
.clicksAntiShake(
|
||
findViewById(R.id.btn_live_clarity), () -> {
|
||
|
||
LiveClarityCustomPopup liveClarityCustomPopup =
|
||
new LiveClarityCustomPopup(mContext,
|
||
IMLoginManager.get(mContext).getSelectClarity(),
|
||
IMLoginManager.get(mContext).getClarity() ? 0 : LiveClarityCustomPopup.BAN_1080, false);
|
||
new XPopup.Builder(mContext)
|
||
.setPopupCallback(new XPopupCallback() {
|
||
@Override
|
||
public void onCreated(BasePopupView popupView) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void beforeShow(BasePopupView popupView) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onShow(BasePopupView popupView) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onDismiss(BasePopupView popupView) {
|
||
setSelectClarity(liveClarityCustomPopup.getSelectClarity());
|
||
}
|
||
|
||
@Override
|
||
public void beforeDismiss(BasePopupView popupView) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public boolean onBackPressed(BasePopupView popupView) {
|
||
return false;
|
||
}
|
||
|
||
@Override
|
||
public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onClickOutside(BasePopupView popupView) {
|
||
|
||
}
|
||
})
|
||
.asCustom(liveClarityCustomPopup)
|
||
.show();
|
||
});
|
||
String keywordHtml2 = "</font><font color='#FF8D41'size='42px'>" + mContext.getString(R.string.anchor_hint) + "</font>";
|
||
String contextHtml = "<font color='#ffffff'size='42px'>" + mContext.getString(R.string.anchor_agreement) + "</font>";
|
||
anchorAgreement.setText(Html.fromHtml(contextHtml + keywordHtml2));
|
||
selectorProtocol.setPressed(true);
|
||
selectorProtocol.setSelected(true);
|
||
selector = selectorProtocol.isSelected();
|
||
selectorProtocol.setOnClickListener(new View.OnClickListener() {
|
||
@Override
|
||
public void onClick(View v) {
|
||
selector = !selector;
|
||
selectorProtocol.setSelected(selector);
|
||
}
|
||
});
|
||
}
|
||
|
||
private void setSelectClarity(int selectClarity) {
|
||
this.selectClarity = selectClarity;
|
||
IMLoginManager.get(mContext).setSelectClarity(selectClarity);
|
||
switch (selectClarity) {
|
||
case 0:
|
||
imgClarity.setImageResource(R.mipmap.icon_sd);
|
||
liveClarity.setText(R.string.standard_clear);
|
||
break;
|
||
case 1:
|
||
imgClarity.setImageResource(R.mipmap.icon_hd);
|
||
liveClarity.setText(R.string.high_definition);
|
||
break;
|
||
case 2:
|
||
imgClarity.setImageResource(R.mipmap.icon_fhd);
|
||
liveClarity.setText(R.string.ultra_hd);
|
||
break;
|
||
}
|
||
if (liveOpenCustomPopup != null) {
|
||
liveOpenCustomPopup.setSelectClarity(selectClarity);
|
||
}
|
||
//SWManager.get().setDimensions(selectClarity);
|
||
Log.e("切换分辨率", "时间戳" + System.currentTimeMillis());
|
||
//重新发布一下流
|
||
Bus.get().post(new LivePushRyEvent());
|
||
}
|
||
|
||
public void setManager(FaceManager manager) {
|
||
this.manager = manager;
|
||
}
|
||
|
||
|
||
@Override
|
||
public void onClick(View v) {
|
||
if (!canClick()) {
|
||
return;
|
||
}
|
||
int i = v.getId();
|
||
if (i == R.id.avatar) {
|
||
setAvatar();
|
||
|
||
} else if (i == R.id.btn_camera) {
|
||
toggleCamera();
|
||
} else if (i == R.id.btn_close) {
|
||
close();
|
||
} else if (i == R.id.btn_live_class) {
|
||
chooseLiveClass();
|
||
} else if (i == R.id.btn_beauty) {
|
||
//beauty();//momo美颜
|
||
setFaceUnity(false); //新娱美颜
|
||
} else if (i == R.id.btn_wishlist) {
|
||
//点击心愿单
|
||
openWishListWindow();
|
||
} else if (i == R.id.btn_room_type) {
|
||
chooseLiveType();
|
||
} else if (i == R.id.btn_start_live) {
|
||
if (!selector) {
|
||
ToastUtil.show(mContext.getString(R.string.anchor_agreement_hint));
|
||
return;
|
||
}
|
||
if (mLiveClassID == 0) {
|
||
ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
|
||
return;
|
||
}
|
||
// startLive();
|
||
liveOpenCustomPopup = new LiveOpenCustomPopup(mContext, IMLoginManager.get(mContext).getSelectClarity(), classBean, liveRoomTypeBean)
|
||
.setSayStatus(IMLoginManager.get(mContext).getAnchorSayStatus())
|
||
.setCallMeStatus(IMLoginManager.get(mContext).getAnchorCallStatus())
|
||
.setCallBack(new LiveOpenCustomPopup.LiveOpenCallBack() {
|
||
@Override
|
||
|
||
public void startLive(LiveRoomTypeBean liveRoomTypeModel, LiveClassBean classModel) {
|
||
if (classModel != null) {
|
||
classBean = classModel;
|
||
mLiveClassID = classBean.getId();
|
||
}
|
||
liveRoomTypeBean = liveRoomTypeModel;
|
||
mLiveType = liveRoomTypeModel.getId();
|
||
startLiveInit();
|
||
liveOpenCustomPopup = null;
|
||
}
|
||
|
||
@Override
|
||
public void selectClarity(int selectClarity) {
|
||
LiveClarityCustomPopup liveClarityCustomPopup =
|
||
new LiveClarityCustomPopup(mContext,
|
||
IMLoginManager.get(mContext).getSelectClarity(),
|
||
IMLoginManager.get(mContext).getClarity() ? 0 : LiveClarityCustomPopup.BAN_1080, false);
|
||
new XPopup.Builder(mContext)
|
||
.setPopupCallback(new XPopupCallback() {
|
||
@Override
|
||
public void onCreated(BasePopupView popupView) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void beforeShow(BasePopupView popupView) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onShow(BasePopupView popupView) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onDismiss(BasePopupView popupView) {
|
||
setSelectClarity(liveClarityCustomPopup.getSelectClarity());
|
||
}
|
||
|
||
@Override
|
||
public void beforeDismiss(BasePopupView popupView) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public boolean onBackPressed(BasePopupView popupView) {
|
||
return false;
|
||
}
|
||
|
||
@Override
|
||
public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onClickOutside(BasePopupView popupView) {
|
||
|
||
}
|
||
})
|
||
.asCustom(liveClarityCustomPopup)
|
||
.show();
|
||
}
|
||
|
||
@Override
|
||
public void openRobot() {
|
||
LiveRobotSettingCustomPopup liveRobotSettingCustomPopup = new LiveRobotSettingCustomPopup(mContext);
|
||
new XPopup.Builder(mContext)
|
||
.setPopupCallback(new XPopupCallback() {
|
||
@Override
|
||
public void onCreated(BasePopupView popupView) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void beforeShow(BasePopupView popupView) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onShow(BasePopupView popupView) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onDismiss(BasePopupView popupView) {
|
||
if (liveOpenCustomPopup != null) {
|
||
liveOpenCustomPopup.initDate();
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void beforeDismiss(BasePopupView popupView) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public boolean onBackPressed(BasePopupView popupView) {
|
||
return false;
|
||
}
|
||
|
||
@Override
|
||
public void onKeyBoardStateChanged(BasePopupView popupView, int height) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onDrag(BasePopupView popupView, int value, float percent, boolean upOrLeft) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onClickOutside(BasePopupView popupView) {
|
||
|
||
}
|
||
})
|
||
.asCustom(liveRobotSettingCustomPopup)
|
||
.show();
|
||
}
|
||
|
||
@Override
|
||
public void openLiveRoomType(LiveRoomTypeBean liveRoomTypeModel) {
|
||
liveRoomTypeBean = liveRoomTypeModel;
|
||
mLiveType = liveRoomTypeModel.getId();
|
||
chooseLiveType();
|
||
}
|
||
|
||
@Override
|
||
public void openLiveClass(LiveClassBean classModel) {
|
||
if (classModel != null) {
|
||
classBean = classModel;
|
||
mLiveClassID = classBean.getId();
|
||
}
|
||
chooseLiveClass();
|
||
}
|
||
|
||
@Override
|
||
public void openWishlist() {
|
||
//点击心愿单
|
||
openWishListWindow();
|
||
}
|
||
|
||
@Override
|
||
public void openAnchorSay() {
|
||
openAnchorSayDialog();
|
||
}
|
||
|
||
@Override
|
||
public void openCallMe() {
|
||
openAnchorCallMeDialog();
|
||
}
|
||
});
|
||
new XPopup.Builder(mContext)
|
||
.asCustom(liveOpenCustomPopup)
|
||
.show();
|
||
} else if (i == R.id.btn_locaiton) {
|
||
switchLocation();
|
||
} else if (i == R.id.btn_horizontally) {
|
||
SWManager.get().setMirrorMode();
|
||
} else if (i == R.id.btn_robot) {
|
||
new XPopup.Builder(mContext)
|
||
.asCustom(new LiveRobotSettingCustomPopup(mContext))
|
||
.show();
|
||
} else if (i == R.id.anchor_agreement_layout) {
|
||
String ct = Locale.getDefault().getLanguage();
|
||
IMLoginModel model = IMLoginManager.get(mContext).getUserInfo();
|
||
StringBuffer url = new StringBuffer();
|
||
url.append(CommonAppConfig.HOST);
|
||
url.append("/h5/page/index.html?id=708");
|
||
url.append("&uid=")
|
||
.append(model.getId())
|
||
.append("&token=")
|
||
.append(model.getToken()).append("&isZh=")
|
||
.append(WordUtil.isNewZh() ? "1" : 0);
|
||
WebViewActivity.forward(mContext, url.toString(), false);
|
||
} else if (i == R.id.btn_live_anchor_say) {
|
||
openAnchorSayDialog();
|
||
} else if (i == R.id.btn_live_anchor_call_me) {
|
||
openAnchorCallMeDialog();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 新娱美颜
|
||
*/
|
||
public void setFaceUnity(boolean init) {
|
||
LiveFaceUnityDialogFragment fragment = new LiveFaceUnityDialogFragment(mContext);
|
||
fragment.setManager(manager);
|
||
fragment.setDismissShowUi(mRootView);
|
||
if (mContext instanceof LiveSwAnchorActivity) {
|
||
fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "FaceUnity");
|
||
mRootView.setVisibility(View.INVISIBLE);
|
||
if (init) {
|
||
fragment.dismiss();
|
||
}
|
||
}
|
||
}
|
||
|
||
public void setFaceUnityNew(boolean init) {
|
||
LiveFaceUnityDialogNewFragment fragment = new LiveFaceUnityDialogNewFragment(mContext);
|
||
fragment.setManager(manager);
|
||
fragment.setDismissShowUi(mRootView);
|
||
if (mContext instanceof LiveSwAnchorActivity) {
|
||
fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "FaceUnity");
|
||
mRootView.setVisibility(View.INVISIBLE);
|
||
if (init) {
|
||
fragment.dismiss();
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/**
|
||
* 打开心愿单窗口
|
||
*/
|
||
public void openWishListWindow() {
|
||
// LiveNewWishListDialogFragment fragment = new LiveNewWishListDialogFragment();
|
||
//
|
||
// if (mContext instanceof LiveRyAnchorActivity) {
|
||
// fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "RY");
|
||
//
|
||
// }
|
||
new XPopup.Builder(mContext)
|
||
.enableDrag(false)
|
||
.asCustom(new LiveNewWishListPopup((LiveSwAnchorActivity) mContext))
|
||
.show();
|
||
}
|
||
|
||
public void openAnchorSayDialog() {
|
||
new LiveAnchorSayPopDialog(mContext).setLiveUid(mLiveUid).setOnItemClickListener(new OnItemClickListener<LiveAnchorSayModel>() {
|
||
@Override
|
||
public void onItemClick(LiveAnchorSayModel bean, int position) {
|
||
if (liveOpenCustomPopup != null) {
|
||
liveOpenCustomPopup.setSayStatus(bean.getLivePreview().getIsShow() == 1);
|
||
}
|
||
}
|
||
}).showDialog();
|
||
}
|
||
|
||
public void openAnchorCallMeDialog() {
|
||
new LiveAnchorEditCallMeDialog(mContext).setLiveUid(mLiveUid).setOnItemClickListener(new OnItemClickListener<LiveAnchorCallMeModel>() {
|
||
@Override
|
||
public void onItemClick(LiveAnchorCallMeModel bean, int position) {
|
||
if (liveOpenCustomPopup != null) {
|
||
liveOpenCustomPopup.setCallMeStatus(bean.getIsShow() == 1);
|
||
}
|
||
}
|
||
}).showDialog();
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void updateStart(LiveAudienceEvent event) {
|
||
if (event.getType() == WISH_LIST_UPDATE) {
|
||
if (liveOpenCustomPopup != null) {
|
||
liveOpenCustomPopup.initDate();
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 打开 关闭位置
|
||
*/
|
||
private void switchLocation() {
|
||
if (mOpenLocation) {
|
||
new DialogUitl.Builder(mContext)
|
||
.setContent(mContext.getString(R.string.live_location_close_3))
|
||
.setCancelable(true)
|
||
.setConfirmString(mContext.getString(R.string.live_location_close_2))
|
||
.setClickCallback(new DialogUitl.SimpleCallback() {
|
||
|
||
@Override
|
||
public void onConfirmClick(Dialog dialog, String content) {
|
||
toggleLocation();
|
||
}
|
||
})
|
||
.build()
|
||
.show();
|
||
} else {
|
||
toggleLocation();
|
||
}
|
||
}
|
||
|
||
private void toggleLocation() {
|
||
mOpenLocation = !mOpenLocation;
|
||
}
|
||
|
||
/**
|
||
* 设置头像
|
||
*/
|
||
private void setAvatar() {
|
||
if (mLiveSdk == Constants.LIVE_SDK_TX) {
|
||
mImageUtil.getImageByAlbum(true);
|
||
} else {
|
||
DialogUitl.showStringArrayDialog(mContext, new Integer[]{
|
||
R.string.camera, R.string.alumb}, new DialogUitl.StringArrayDialogCallback() {
|
||
@Override
|
||
public void onItemClick(String text, int tag) {
|
||
if (tag == R.string.camera) {
|
||
mImageUtil.getImageByCamera();
|
||
} else {
|
||
mImageUtil.getImageByAlbum(true);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 切换镜头
|
||
*/
|
||
private void toggleCamera() {
|
||
((LiveSwAnchorActivity) mContext).toggleCamera();
|
||
}
|
||
|
||
/**
|
||
* 关闭
|
||
*/
|
||
private void close() {
|
||
((LiveSwAnchorActivity) mContext).endLives();
|
||
}
|
||
|
||
/**
|
||
* 选择直播频道
|
||
*/
|
||
private void chooseLiveClass() {
|
||
/* try {
|
||
Intent intent = new Intent(mContext, LiveChooseClassActivity.class);
|
||
intent.putExtra(Constants.CLASS_ID, mLiveClassID);
|
||
mImageUtil.startActivityForResult(intent, mActivityResultCallback);
|
||
}catch (Exception e){
|
||
|
||
}*/
|
||
|
||
Bundle bundle = new Bundle();
|
||
bundle.putInt(Constants.CLASS_ID, mLiveClassID);
|
||
LiveNewRoomClassDialogFragment fragment = new LiveNewRoomClassDialogFragment();
|
||
fragment.setArguments(bundle);
|
||
fragment.setCallback(new CommonCallback<LiveClassBean>() {
|
||
@Override
|
||
public void callback(LiveClassBean bean) {
|
||
classBean = bean;
|
||
mLiveClassID = classBean.getId();
|
||
mLiveClass.setText(bean.getName());
|
||
if (liveOpenCustomPopup != null) {
|
||
liveOpenCustomPopup.setClassBean(classBean);
|
||
}
|
||
}
|
||
});
|
||
fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
|
||
|
||
}
|
||
|
||
/**
|
||
* 设置美颜
|
||
*/
|
||
private void beauty() {
|
||
((LiveSwAnchorActivity) mContext).beauty();
|
||
// Intent intent = new Intent(mContext, Beauty360Activity3.class);
|
||
// mContext.startActivity(intent);
|
||
|
||
}
|
||
|
||
/**
|
||
* 选择直播类型
|
||
*/
|
||
private LiveRoomTypeBean liveRoomTypeBean = new LiveRoomTypeBean(0, mContext.getString(R.string.live_room_public));
|
||
|
||
private void chooseLiveType() {
|
||
Bundle bundle = new Bundle();
|
||
bundle.putInt(Constants.CHECKED_ID, mLiveType);
|
||
LiveNewRoomTypeDialogFragment fragment = new LiveNewRoomTypeDialogFragment();
|
||
fragment.setArguments(bundle);
|
||
fragment.setCallback(new CommonCallback<LiveRoomTypeBean>() {
|
||
@Override
|
||
public void callback(LiveRoomTypeBean bean) {
|
||
liveRoomTypeBean = bean;
|
||
switch (bean.getId()) {
|
||
case Constants.LIVE_TYPE_NORMAL:
|
||
onLiveTypeNormal(bean);
|
||
break;
|
||
case Constants.LIVE_TYPE_PWD:
|
||
onLiveTypePwd(bean);
|
||
break;
|
||
case Constants.LIVE_TYPE_PAY:
|
||
onLiveTypePay(bean);
|
||
break;
|
||
case Constants.LIVE_TYPE_TIME:
|
||
onLiveTypeTime(bean);
|
||
break;
|
||
}
|
||
if (liveOpenCustomPopup != null) {
|
||
liveOpenCustomPopup.setLiveRoomTypeBean(liveRoomTypeBean);
|
||
}
|
||
}
|
||
});
|
||
fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveRoomTypeDialogFragment");
|
||
}
|
||
|
||
/**
|
||
* 普通房间
|
||
*/
|
||
private void onLiveTypeNormal(LiveRoomTypeBean bean) {
|
||
mLiveType = bean.getId();
|
||
mLiveTypeTextView.setText(bean.getName());
|
||
mLiveTypeVal = 0;
|
||
mLiveTimeCoin = 0;
|
||
}
|
||
|
||
/**
|
||
* 密码房间
|
||
*/
|
||
private void onLiveTypePwd(final LiveRoomTypeBean bean) {
|
||
DialogUitl.showSimpleInputDialog(mContext, mContext.getString(R.string.live_set_pwd), DialogUitl.INPUT_TYPE_NUMBER_PASSWORD, 8, new DialogUitl.SimpleCallback() {
|
||
@Override
|
||
public void onConfirmClick(Dialog dialog, String content) {
|
||
if (TextUtils.isEmpty(content)) {
|
||
ToastUtil.show(mContext.getString(R.string.live_set_pwd_empty));
|
||
} else {
|
||
mLiveType = bean.getId();
|
||
mLiveTypeTextView.setText(WordUtil.isNewZh() ? "密碼房" : "password room");
|
||
if (StringUtil.isInt(content)) {
|
||
mLiveTypeVal = Integer.parseInt(content);
|
||
}
|
||
mLiveTimeCoin = 0;
|
||
dialog.dismiss();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 付费房间
|
||
*/
|
||
private void onLiveTypePay(final LiveRoomTypeBean bean) {
|
||
DialogUitl.showSimpleInputDialog(mContext, mContext.getString(R.string.live_set_fee), DialogUitl.INPUT_TYPE_NUMBER, 8, new DialogUitl.SimpleCallback() {
|
||
@Override
|
||
public void onConfirmClick(Dialog dialog, String content) {
|
||
if (TextUtils.isEmpty(content)) {
|
||
ToastUtil.show(mContext.getString(R.string.live_set_fee_empty));
|
||
} else {
|
||
mLiveType = bean.getId();
|
||
mLiveTypeTextView.setText(bean.getName());
|
||
if (StringUtil.isInt(content)) {
|
||
mLiveTypeVal = Integer.parseInt(content);
|
||
}
|
||
mLiveTimeCoin = 0;
|
||
dialog.dismiss();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 计时房间
|
||
*/
|
||
private void onLiveTypeTime(final LiveRoomTypeBean bean) {
|
||
LiveTimeDialogFragment fragment = new LiveTimeDialogFragment();
|
||
Bundle bundle = new Bundle();
|
||
bundle.putInt(Constants.CHECKED_COIN, mLiveTimeCoin);
|
||
fragment.setArguments(bundle);
|
||
fragment.setCommonCallback(new CommonCallback<Integer>() {
|
||
@Override
|
||
public void callback(Integer coin) {
|
||
mLiveType = bean.getId();
|
||
mLiveTypeTextView.setText(bean.getName());
|
||
mLiveTypeVal = coin;
|
||
mLiveTimeCoin = coin;
|
||
}
|
||
});
|
||
fragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveTimeDialogFragment");
|
||
}
|
||
|
||
public void hide() {
|
||
if (mContentView != null && mContentView.getVisibility() == View.VISIBLE) {
|
||
mContentView.setVisibility(View.INVISIBLE);
|
||
}
|
||
}
|
||
|
||
|
||
public void show() {
|
||
if (mContentView != null && mContentView.getVisibility() != View.VISIBLE) {
|
||
mContentView.setVisibility(View.VISIBLE);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 点击开始直播按钮
|
||
*/
|
||
private void startLiveInit() {
|
||
if (isWifiProxy(mContext) || checkVPN((ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE))) {
|
||
ToastUtil.show(WordUtil.isNewZh() ? "檢測開啓了VPN或者代理,請先關閉VPN或者代理再開播。" :
|
||
"It is detected that VPN or proxy is turned on. Please turn off VPN or proxy before starting the broadcast.");
|
||
} else {
|
||
boolean startPreview = ((LiveSwAnchorActivity) mContext).isStartPreview();
|
||
// if (!startPreview) {
|
||
// ToastUtil.show(R.string.please_wait);
|
||
// return;
|
||
// }
|
||
if (mLiveClassID == 0) {
|
||
ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
|
||
return;
|
||
}
|
||
createRoom();
|
||
}
|
||
}
|
||
|
||
private boolean isWifiProxy(Context context) {
|
||
final boolean IS_ICS_OR_LATER = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH;
|
||
String proxyAddress;
|
||
int proxyPort;
|
||
if (IS_ICS_OR_LATER) {
|
||
proxyAddress = System.getProperty("http.proxyHost");
|
||
String portStr = System.getProperty("http.proxyPort");
|
||
proxyPort = Integer.parseInt((portStr != null ? portStr : "-1"));
|
||
} else {
|
||
proxyAddress = android.net.Proxy.getHost(context);
|
||
proxyPort = android.net.Proxy.getPort(context);
|
||
}
|
||
return (!TextUtils.isEmpty(proxyAddress)) && (proxyPort != -1);
|
||
}
|
||
|
||
private boolean checkVPN(ConnectivityManager connMgr) {
|
||
//don't know why always returns null:
|
||
NetworkInfo networkInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_VPN);
|
||
boolean isVpnConn = networkInfo == null ? false : networkInfo.isConnected();
|
||
return isVpnConn;
|
||
}
|
||
|
||
/**
|
||
* 请求创建直播间接口,开始直播
|
||
*/
|
||
boolean isHttpBack = false;
|
||
|
||
private void createRoom() {
|
||
if (!isHttpBack) {
|
||
isHttpBack = true;
|
||
if (mLiveClassID == 0) {
|
||
ToastUtil.show(WordUtil.getNewString(R.string.live_choose_live_class));
|
||
return;
|
||
}
|
||
String title = mEditTitle.getText().toString().trim();
|
||
LiveHttpUtil.newcreateRoom(title, mLiveClassID, mLiveType, mLiveTypeVal, mAvatarFile, IMLoginManager.get(mContext).getSelectClarity() + 1, true, new HttpCallback() {
|
||
@Override
|
||
public void onSuccess(int code, String msg, final String[] info) {
|
||
isHttpBack = false;
|
||
if (code == 0 && info.length > 0) {
|
||
L.e("开播", "createRoom------->" + info[0]);
|
||
final CommonAppConfig appConfig = CommonAppConfig.getInstance();
|
||
UserBean u = appConfig.getUserBean();
|
||
((LiveSwAnchorActivity) mContext).startLiveSuccess(info[0], mLiveType, mLiveTypeVal);
|
||
} else {
|
||
ToastUtil.show(msg);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onError() {
|
||
super.onError();
|
||
isHttpBack = false;
|
||
}
|
||
});
|
||
} else {
|
||
ToastUtil.show(WordUtil.isNewZh() ? "請求中,請勿重複點擊" : "During request, please do not click repeatedly");
|
||
}
|
||
}
|
||
|
||
public void release() {
|
||
mImageUtil = null;
|
||
}
|
||
|
||
@Override
|
||
public void onDestroy() {
|
||
LiveHttpUtil.cancel(LiveHttpConsts.CREATE_ROOM);
|
||
}
|
||
|
||
public void setLiveUid(String mLiveUid) {
|
||
this.mLiveUid = mLiveUid;
|
||
}
|
||
}
|