開播設置,修改開播接口新增分辨率設置參數,網絡內存檢測和提示信息
This commit is contained in:
@@ -136,4 +136,6 @@ public class DeviceUtils {
|
||||
lastTotalRxBytes = nowTotalRxBytes;
|
||||
return speed;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.yunbao.common.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.lxj.xpopup.core.CenterPopupView;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
public class HintCustomPopup extends CenterPopupView {
|
||||
private String title, contest;
|
||||
|
||||
public HintCustomPopup(@NonNull Context context, String title, String contest) {
|
||||
super(context);
|
||||
this.title = title;
|
||||
this.contest = contest;
|
||||
}
|
||||
|
||||
public HintCustomPopup(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
// 返回自定义弹窗的布局
|
||||
@Override
|
||||
protected int getImplLayoutId() {
|
||||
return R.layout.hint_custom_popup;
|
||||
}
|
||||
|
||||
// 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
TextView titleText = findViewById(R.id.title);
|
||||
TextView contestText = findViewById(R.id.contest);
|
||||
if (!TextUtils.isEmpty(title)) {
|
||||
titleText.setText(title);
|
||||
}
|
||||
if (!TextUtils.isEmpty(contest)) {
|
||||
contestText.setText(contest);
|
||||
}
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_open_ok), () -> {
|
||||
if (callBack != null) {
|
||||
callBack.onSure();
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.live_open_cancel), () -> {
|
||||
if (callBack != null) {
|
||||
callBack.onCancel();
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
private HintCustomCallBack callBack;
|
||||
|
||||
public HintCustomPopup setCallBack(HintCustomCallBack callBack) {
|
||||
this.callBack = callBack;
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface HintCustomCallBack {
|
||||
void onSure();
|
||||
|
||||
void onCancel();
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,27 @@
|
||||
package com.yunbao.common.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.text.format.Formatter;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.core.BottomPopupView;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.DeviceUtils;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.DoubleSummaryStatistics;
|
||||
import java.util.List;
|
||||
|
||||
public class LiveClarityCustomPopup extends BottomPopupView implements View.OnClickListener {
|
||||
public static final int BAN_720 = 1;
|
||||
public static final int BAN_1080 = 2;
|
||||
@@ -91,16 +98,51 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl
|
||||
});
|
||||
//高清
|
||||
ViewClicksAntiShake.clicksAntiShake(lineHd, () -> {
|
||||
selectClarity = 1;
|
||||
selectClarity(selectClarity);
|
||||
dismiss();
|
||||
String memorg = formateFileSize(Long.parseLong(DeviceUtils.getMemory(getContext())));
|
||||
if (Double.parseDouble(memorg) > 7 && netAverage > 100) {
|
||||
selectClarity = 1;
|
||||
selectClarity(selectClarity);
|
||||
dismiss();
|
||||
} else {
|
||||
new XPopup.Builder(getContext())
|
||||
.asCustom(new HintCustomPopup(getContext(), getContext().getString(R.string.net_hint), getContext().getString(R.string.net_hint2)).setCallBack(new HintCustomPopup.HintCustomCallBack() {
|
||||
@Override
|
||||
public void onSure() {
|
||||
selectClarity = 1;
|
||||
selectClarity(selectClarity);
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
}
|
||||
}))
|
||||
.show();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
//超高清
|
||||
ViewClicksAntiShake.clicksAntiShake(lineFhd, () -> {
|
||||
selectClarity = 2;
|
||||
selectClarity(selectClarity);
|
||||
dismiss();
|
||||
|
||||
new XPopup.Builder(getContext())
|
||||
.asCustom(new HintCustomPopup(getContext()).setCallBack(new HintCustomPopup.HintCustomCallBack() {
|
||||
@Override
|
||||
public void onSure() {
|
||||
selectClarity = 2;
|
||||
selectClarity(selectClarity);
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
}
|
||||
}))
|
||||
.show();
|
||||
|
||||
|
||||
});
|
||||
if (banSelect == BAN_720) {
|
||||
lineFhd.setEnabled(false);
|
||||
@@ -116,6 +158,12 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl
|
||||
}
|
||||
}
|
||||
|
||||
//调用系统函数,字符串转换 long -String KB/MB
|
||||
private String formateFileSize(long size) {
|
||||
String fileSize = Formatter.formatFileSize(getContext(), size);
|
||||
return fileSize.substring(0, fileSize.length() - 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态选择
|
||||
*
|
||||
@@ -150,6 +198,28 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl
|
||||
}
|
||||
}
|
||||
|
||||
private Handler netHandler = new Handler();
|
||||
private Runnable netRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (netSpeeds.size() < 11) {
|
||||
netSpeeds.add(DeviceUtils.getNetSpeed(getContext()));
|
||||
netHandler.postDelayed(netRunnable, 100);
|
||||
} else {
|
||||
long min = Collections.min(netSpeeds);
|
||||
long max = Collections.max(netSpeeds);
|
||||
|
||||
DoubleSummaryStatistics statistics = netSpeeds.stream().mapToDouble(Number::doubleValue).summaryStatistics();
|
||||
netAverage = statistics.getAverage();
|
||||
Log.e("网络速度", "最大值:" + max + " 最小值:" + min + " 平均值:" + netAverage);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
private List<Long> netSpeeds = new ArrayList<>();
|
||||
private double netAverage = 0;
|
||||
|
||||
private void initDate() {
|
||||
netHandler.postDelayed(netRunnable, 100);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user