调整修改清晰度提示弹窗为黑底白字的而不是Toast

This commit is contained in:
zlzw 2023-01-05 17:48:10 +08:00
parent 7cea6b4f8d
commit 6fcb194995
3 changed files with 51 additions and 7 deletions

View File

@ -1,10 +1,16 @@
package com.yunbao.common.utils; package com.yunbao.common.utils;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.yunbao.common.CommonAppContext; import com.yunbao.common.CommonAppContext;
@ -38,6 +44,39 @@ public class ToastUtil {
show(WordUtil.getString(res)); show(WordUtil.getString(res));
} }
/**
* 显示黑底白字的提示
*
* @param res 内容
* @param delayMillis 显示时间 毫秒
*/
public static void showStyle(int res, long delayMillis) {
showStyle(WordUtil.getString(res), delayMillis);
}
/**
* 显示黑底白字的提示
*
* @param content 内容
* @param delayMillis 显示时间 毫秒
*/
public static void showStyle(String content, long delayMillis) {
Dialog dialog = new Dialog(CommonAppContext.getTopActivity(), R.style.dialog);
dialog.setContentView(R.layout.dialog_toast);
dialog.setCancelable(false);
dialog.setCanceledOnTouchOutside(false);
if (!TextUtils.isEmpty(content)) {
TextView titleView = (TextView) dialog.findViewById(R.id.text);
if (titleView != null) {
titleView.setTextColor(Color.WHITE);
titleView.setGravity(Gravity.CENTER);
titleView.setText(content);
}
}
dialog.show();
new Handler(Looper.getMainLooper()).postDelayed(dialog::dismiss, delayMillis);
}
public static void show(String s) { public static void show(String s) {
if (TextUtils.isEmpty(s)) { if (TextUtils.isEmpty(s)) {
return; return;

View File

@ -39,13 +39,18 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl
return selectClarity; return selectClarity;
} }
public LiveClarityCustomPopup(@NonNull Context context, int selectClarity, int banSelect) { /**
*
* @param banSelect 禁止选项{@link #BAN_720} 禁止高清和超高清 {@link #BAN_1080} 禁止超高清
* @param isUser 是否为观众true 观众false 主播
*/
public LiveClarityCustomPopup(@NonNull Context context, int selectClarity, int banSelect,boolean isUser) {
super(context); super(context);
this.banSelect = banSelect; this.banSelect = banSelect;
if (selectClarity == -1) { if (selectClarity == -1) {
selectClarity = 0; selectClarity = 0;
} }
this.isUser = true; this.isUser = isUser;
this.selectClarity = selectClarity; this.selectClarity = selectClarity;
} }
@ -108,9 +113,9 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl
ViewClicksAntiShake.clicksAntiShake(lineHd, () -> { ViewClicksAntiShake.clicksAntiShake(lineHd, () -> {
if(lineHd.getTag()!=null){ if(lineHd.getTag()!=null){
if(isUser){//用户端 if(isUser){//用户端
ToastUtil.show(R.string.live_user_ban_hd); ToastUtil.showStyle(R.string.live_user_ban_hd,2000);
}else{//主播端 }else{//主播端
ToastUtil.show(""); ToastUtil.showStyle("",2000);
} }
return; return;
} }
@ -143,9 +148,9 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl
ViewClicksAntiShake.clicksAntiShake(lineFhd, () -> { ViewClicksAntiShake.clicksAntiShake(lineFhd, () -> {
if(lineFhd.getTag()!=null){ if(lineFhd.getTag()!=null){
if(isUser){//用户端 if(isUser){//用户端
ToastUtil.show(R.string.live_user_ban_fhd); ToastUtil.showStyle(R.string.live_user_ban_fhd,2000);
}else{//主播端 }else{//主播端
ToastUtil.show(""); ToastUtil.showStyle("",2000);
} }
return; return;
} }

View File

@ -697,7 +697,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder {
break; break;
} }
LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, PLAY_MODEL, ban); LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, PLAY_MODEL, ban,true);
new XPopup.Builder(mContext) new XPopup.Builder(mContext)
.setPopupCallback(new XPopupCallback() { .setPopupCallback(new XPopupCallback() {
@Override @Override