From 6fcb194995c5dbe7e3cc565313518bd74d4e824e Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 5 Jan 2023 17:48:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BF=AE=E6=94=B9=E6=B8=85?= =?UTF-8?q?=E6=99=B0=E5=BA=A6=E6=8F=90=E7=A4=BA=E5=BC=B9=E7=AA=97=E4=B8=BA?= =?UTF-8?q?=E9=BB=91=E5=BA=95=E7=99=BD=E5=AD=97=E7=9A=84=E8=80=8C=E4=B8=8D?= =?UTF-8?q?=E6=98=AFToast?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/utils/ToastUtil.java | 39 +++++++++++++++++++ .../common/views/LiveClarityCustomPopup.java | 17 +++++--- .../live/views/LivePlayRyViewHolder.java | 2 +- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/utils/ToastUtil.java b/common/src/main/java/com/yunbao/common/utils/ToastUtil.java index cb4fb343f..d8245a7ab 100644 --- a/common/src/main/java/com/yunbao/common/utils/ToastUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/ToastUtil.java @@ -1,10 +1,16 @@ 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.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; +import android.widget.TextView; import android.widget.Toast; import com.yunbao.common.CommonAppContext; @@ -38,6 +44,39 @@ public class ToastUtil { 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) { if (TextUtils.isEmpty(s)) { return; diff --git a/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java b/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java index e0abd63d7..5b06484b9 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveClarityCustomPopup.java @@ -39,13 +39,18 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl 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); this.banSelect = banSelect; if (selectClarity == -1) { selectClarity = 0; } - this.isUser = true; + this.isUser = isUser; this.selectClarity = selectClarity; } @@ -108,9 +113,9 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl ViewClicksAntiShake.clicksAntiShake(lineHd, () -> { if(lineHd.getTag()!=null){ if(isUser){//用户端 - ToastUtil.show(R.string.live_user_ban_hd); + ToastUtil.showStyle(R.string.live_user_ban_hd,2000); }else{//主播端 - ToastUtil.show(""); + ToastUtil.showStyle("",2000); } return; } @@ -143,9 +148,9 @@ public class LiveClarityCustomPopup extends BottomPopupView implements View.OnCl ViewClicksAntiShake.clicksAntiShake(lineFhd, () -> { if(lineFhd.getTag()!=null){ if(isUser){//用户端 - ToastUtil.show(R.string.live_user_ban_fhd); + ToastUtil.showStyle(R.string.live_user_ban_fhd,2000); }else{//主播端 - ToastUtil.show(""); + ToastUtil.showStyle("",2000); } return; } diff --git a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java index 98751cbb3..b935e18da 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePlayRyViewHolder.java @@ -697,7 +697,7 @@ public class LivePlayRyViewHolder extends LiveRoomPlayViewHolder { break; } - LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, PLAY_MODEL, ban); + LiveClarityCustomPopup liveClarityCustomPopup = new LiveClarityCustomPopup(mContext, PLAY_MODEL, ban,true); new XPopup.Builder(mContext) .setPopupCallback(new XPopupCallback() { @Override