修改LiveHDDialogFragment Gravity 位置
This commit is contained in:
parent
8eb88e4149
commit
fbfe1af405
@ -0,0 +1,35 @@
|
||||
package com.yunbao.common.views.weight;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.jakewharton.rxbinding3.view.RxView;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import kotlin.Unit;
|
||||
|
||||
/**
|
||||
* View防抖
|
||||
*/
|
||||
public class OnClickShakeListener implements View.OnClickListener{
|
||||
|
||||
|
||||
private long mDuration=800;
|
||||
private View.OnClickListener mListener;
|
||||
private long lastTime=0;
|
||||
public OnClickShakeListener(View.OnClickListener listener){
|
||||
mListener=listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (System.currentTimeMillis()-lastTime<mDuration){
|
||||
return;
|
||||
}
|
||||
lastTime=System.currentTimeMillis();
|
||||
mListener.onClick(v);
|
||||
}
|
||||
|
||||
}
|
@ -15,6 +15,8 @@ import android.content.ClipData;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@ -55,6 +57,7 @@ import com.tencent.imsdk.v2.V2TIMSDKListener;
|
||||
import com.tencent.imsdk.v2.V2TIMUserFullInfo;
|
||||
import com.yunbao.common.utils.AppManager;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DebugUtils;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.Constants;
|
||||
@ -107,6 +110,7 @@ import com.yunbao.common.utils.GoogleUtils;
|
||||
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
|
||||
import com.yunbao.common.utils.LocationUtil;
|
||||
import com.yunbao.common.utils.MessageSayHiNotifyManager;
|
||||
import com.yunbao.common.utils.PluginManager;
|
||||
import com.yunbao.common.utils.ProcessResultUtil;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
@ -117,19 +121,24 @@ import com.yunbao.common.views.APKUpdateCustomPopup;
|
||||
import com.yunbao.common.views.AbsMainViewHolder;
|
||||
import com.yunbao.common.views.floatingview.APPEasyFloat;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
import com.yunbao.live.LiveConfig;
|
||||
import com.yunbao.live.activity.LiveAnchorActivity;
|
||||
import com.yunbao.live.activity.LiveAudienceActivity;
|
||||
import com.yunbao.live.event.LiveAudienceEvent;
|
||||
import com.yunbao.live.activity.LiveRyAnchorActivity;
|
||||
import com.yunbao.live.activity.LiveSwAnchorActivity;
|
||||
import com.yunbao.live.bean.LiveKsyConfigBean;
|
||||
|
||||
import com.yunbao.live.utils.LiveStorge;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.adapter.FullAdToBannerTransition;
|
||||
import com.yunbao.main.dialog.AnchorStartLiveNotifyDialog;
|
||||
import com.yunbao.main.dialog.MainStartDialogFragment;
|
||||
import com.yunbao.main.dialog.ReturnUserDialog;
|
||||
import com.yunbao.main.dialog.SigninDialog;
|
||||
import com.yunbao.main.event.PDLiveConversationListEvent;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
import com.yunbao.main.interfaces.MainAppBarLayoutListener;
|
||||
import com.yunbao.main.interfaces.MainStartChooseCallback;
|
||||
import com.yunbao.main.manager.imrongcloud.ConversationIMListManager;
|
||||
import com.yunbao.main.utils.GenerateTestUserSig;
|
||||
import com.yunbao.main.utils.UserInfoManager;
|
||||
@ -873,8 +882,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
});
|
||||
|
||||
}
|
||||
// });
|
||||
|
||||
// });
|
||||
private boolean isFrist = true;
|
||||
public void mainClick(View v) {
|
||||
|
||||
if (!canClick()) {
|
||||
@ -882,11 +892,14 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
}
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_start) {
|
||||
showStartDialog();
|
||||
ViewClicksAntiShake.clicksAntiShake(2000,v, () -> {
|
||||
showStartDialog();
|
||||
});
|
||||
MobclickAgent.onEvent(mContext, "broadcast", "开播按钮");
|
||||
// ViewClicksAntiShake.clicksAntiShake(v, () -> {
|
||||
//
|
||||
// });
|
||||
if (isFrist){
|
||||
isFrist=false;
|
||||
v.callOnClick();
|
||||
}
|
||||
} else if (i == R.id.btn_search) {
|
||||
SearchActivity.forward(mContext);
|
||||
|
||||
@ -901,32 +914,46 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
//RandomPkDialogFragment fragment = new RandomPkDialogFragment();
|
||||
//fragment.show(this.getSupportFragmentManager(), "RandomPkDialogFragment");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void startStartDialog(){
|
||||
if(!IMLoginManager.get(mContext).getUserInfo().anchorUserType()){
|
||||
ToastUtil.show(getString(R.string.only_open_anchor));
|
||||
}else {
|
||||
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.");
|
||||
DebugUtils.runDebugCode(() -> onLiveClick());
|
||||
} else {
|
||||
onLiveClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void showStartDialog() {
|
||||
if (isReady == true) {
|
||||
MainStartDialogFragment dialogFragment = new MainStartDialogFragment();
|
||||
dialogFragment.setMainStartChooseCallback(true, this);
|
||||
dialogFragment.show(getSupportFragmentManager(), "MainStartDialogFragment");
|
||||
startStartDialog();
|
||||
Log.i(TAG,"connectIM isReady");
|
||||
} else {
|
||||
connectIM(AppManager.getInstance().getMainActivity(), new RongIMClient.ConnectCallback() {
|
||||
@Override
|
||||
public void onSuccess(String t) {
|
||||
MainStartDialogFragment dialogFragment = new MainStartDialogFragment();
|
||||
dialogFragment.setMainStartChooseCallback(true, MainActivity.this);
|
||||
dialogFragment.show(getSupportFragmentManager(), "MainStartDialogFragment");
|
||||
startStartDialog();
|
||||
Log.i(TAG,"connectIM onSuccess");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ConnectionErrorCode e) {
|
||||
ToastUtil.show(R.string.net_error + "" + e.toString());
|
||||
Log.i(TAG,"connectIM onError");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDatabaseOpened(RongIMClient.DatabaseOpenStatus code) {
|
||||
ToastUtil.show(R.string.net_error + "" + code);
|
||||
Log.i(TAG,"connectIM onDatabaseOpened");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1706,4 +1733,168 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//这些是开播的逻辑
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private HttpCallback mGetLiveSdkCallback;
|
||||
public void onLiveClick() {
|
||||
boolean isAnchor = IMLoginManager.get(mContext).getUserInfo().anchorUserType();
|
||||
if (isAnchor) {
|
||||
String[] permissions;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
permissions = new String[]{
|
||||
Manifest.permission.CAMERA,
|
||||
Manifest.permission.RECORD_AUDIO
|
||||
};
|
||||
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.TIRAMISU) {
|
||||
permissions = new String[]{
|
||||
//Manifest.permission.READ_MEDIA_IMAGES, 去掉选择图片的权限,到里面选择封面的时候再去申请
|
||||
Manifest.permission.CAMERA,
|
||||
Manifest.permission.RECORD_AUDIO
|
||||
};
|
||||
} else {
|
||||
permissions = new String[]{
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.CAMERA,
|
||||
Manifest.permission.RECORD_AUDIO
|
||||
};
|
||||
}
|
||||
mProcessResultUtil.requestPermissions(permissions, mStartLiveRunnable);
|
||||
} else {
|
||||
ToastUtil.show(getString(R.string.only_open_anchor));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Runnable mStartLiveRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (CommonAppConfig.LIVE_SDK_CHANGED) {
|
||||
if (mGetLiveSdkCallback == null) {
|
||||
mGetLiveSdkCallback = new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, final String[] info) {
|
||||
if (code == 0 && info.length > 0) {
|
||||
LiveHttpUtil.getisRong(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info1) {
|
||||
try {
|
||||
LiveHttpUtil.getIsSw(new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] infos) {
|
||||
JSONObject obj = JSON.parseObject(info[0]);
|
||||
JSONObject obj1 = JSON.parseObject(info1[0]);
|
||||
try {
|
||||
if (code == 201) { //声网
|
||||
LiveSwAnchorActivity.forward(mContext, Constants.LIVE_SDK_SW, JSON.parseObject(obj.getString("android"), LiveKsyConfigBean.class));
|
||||
} else if (code == 200) {//融云
|
||||
LiveRyAnchorActivity.forward(mContext, obj.getIntValue("live_sdk"), JSON.parseObject(obj.getString("android"), LiveKsyConfigBean.class));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
if (!CommonAppConfig.IS_PLUGIN_MODEL || PluginManager.getInstance().isDownloadApk()) {
|
||||
PluginManager.getInstance().loadAnchorPlugin(it -> {
|
||||
LiveHttpUtil.getLiveSdk(mGetLiveSdkCallback);
|
||||
});
|
||||
} else {
|
||||
String tips = "需要下載開播插件,是否下載";
|
||||
if (!WordUtil.isNewZh()) {
|
||||
tips = "You need to download the plug-in, whether to download";
|
||||
}
|
||||
DialogUitl.showSimpleDialog(mContext, tips, new DialogUitl.SimpleCallback() {
|
||||
@Override
|
||||
public void onConfirmClick(Dialog dialog, String content) {
|
||||
Dialog downloadDialog = DialogUitl.loadingDialog(mContext, "Downloading...");
|
||||
downloadDialog.show();
|
||||
PluginManager.getInstance().loadAnchorPlugin(it -> {
|
||||
LiveHttpUtil.getLiveSdk(mGetLiveSdkCallback);
|
||||
downloadDialog.dismiss();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
LiveAnchorActivity.forward(mContext, CommonAppConfig.LIVE_SDK_USED, LiveConfig.getDefaultKsyConfig());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private MainStartChooseCallback mMainStartChooseCallback = new MainStartChooseCallback() {
|
||||
@Override
|
||||
public void onLiveClick() {
|
||||
boolean isAnchor = IMLoginManager.get(mContext).getUserInfo().anchorUserType();
|
||||
if (isAnchor) {
|
||||
String[] permissions;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
|
||||
permissions = new String[]{
|
||||
Manifest.permission.CAMERA,
|
||||
Manifest.permission.RECORD_AUDIO
|
||||
};
|
||||
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.TIRAMISU) {
|
||||
permissions = new String[]{
|
||||
//Manifest.permission.READ_MEDIA_IMAGES, 去掉选择图片的权限,到里面选择封面的时候再去申请
|
||||
Manifest.permission.CAMERA,
|
||||
Manifest.permission.RECORD_AUDIO
|
||||
};
|
||||
} else {
|
||||
permissions = new String[]{
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.CAMERA,
|
||||
Manifest.permission.RECORD_AUDIO
|
||||
};
|
||||
}
|
||||
mProcessResultUtil.requestPermissions(permissions, mStartLiveRunnable);
|
||||
} else {
|
||||
ToastUtil.show(getString(R.string.only_open_anchor));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVideoClick() {
|
||||
//
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user