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