From ad1599cccec7418be10189afcb8f62b1357152c7 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 14 Sep 2022 18:05:42 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=85=A8=E7=AB=99=E5=96=87=E5=8F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/assets/icon_livemsgbg_chaohuang.svga | Bin .../main/assets/icon_livemsgbg_guowang.svga | Bin .../main/assets/icon_livemsgbg_huangdi.svga | Bin .../java/com/yunbao/common/bean/MsgModel.java | 32 ++- .../imrongcloud/RongcloudIMManager.java | 4 +- .../weight/FullServiceNotificationView.java | 238 ++++++++++++++++++ .../views/weight/GradientColorTextView.java | 55 ++++ .../common/views/weight/MarqueeTextView.java | 3 + .../src/main/res/anim/vice_screen_come_in.xml | 0 .../background_whole_station_horn.xml | 0 .../background_whole_text_station_horn.xml | 8 + .../layout/view_full_service_notification.xml | 98 ++++++++ .../res/layout/view_whole_station_horn.xml | 44 ++++ .../main/res/mipmap-xxhdpi}/img_chaohuang.png | Bin .../main/res/mipmap-xxhdpi}/img_huangdi.png | Bin .../main/res/mipmap-xxhdpi}/imng_guowang.png | Bin .../yunbao/live/activity/LiveActivity.java | 88 +------ .../live/activity/LiveAudienceActivity.java | 12 +- .../live/dialog/LiveInputDialogFragment.java | 2 +- .../yunbao/live/event/LiveAudienceEvent.java | 13 +- .../yunbao/live/socket/SocketRyClient.java | 9 +- .../live/views/LiveAudienceViewHolder.java | 102 +------- .../yunbao/live/views/LiveRoomViewHolder.java | 22 +- .../live/views/PortraitLiveManager.java | 12 +- .../res/layout/dialog_live_chat_input.xml | 2 +- live/src/main/res/layout/view_live_room.xml | 13 +- .../res/layout/view_whole_station_horn.xml | 35 --- .../layout/view_whole_station_horn_layout.xml | 1 - 28 files changed, 546 insertions(+), 247 deletions(-) rename {live => common}/src/main/assets/icon_livemsgbg_chaohuang.svga (100%) rename {live => common}/src/main/assets/icon_livemsgbg_guowang.svga (100%) rename {live => common}/src/main/assets/icon_livemsgbg_huangdi.svga (100%) create mode 100644 common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java create mode 100644 common/src/main/java/com/yunbao/common/views/weight/GradientColorTextView.java rename {live => common}/src/main/res/anim/vice_screen_come_in.xml (100%) rename {live => common}/src/main/res/drawable/background_whole_station_horn.xml (100%) create mode 100644 common/src/main/res/drawable/background_whole_text_station_horn.xml create mode 100644 common/src/main/res/layout/view_full_service_notification.xml create mode 100644 common/src/main/res/layout/view_whole_station_horn.xml rename {live/src/main/res/mipmap-xxxhdpi => common/src/main/res/mipmap-xxhdpi}/img_chaohuang.png (100%) rename {live/src/main/res/mipmap-xxxhdpi => common/src/main/res/mipmap-xxhdpi}/img_huangdi.png (100%) rename {live/src/main/res/mipmap-xxxhdpi => common/src/main/res/mipmap-xxhdpi}/imng_guowang.png (100%) delete mode 100644 live/src/main/res/layout/view_whole_station_horn.xml diff --git a/live/src/main/assets/icon_livemsgbg_chaohuang.svga b/common/src/main/assets/icon_livemsgbg_chaohuang.svga similarity index 100% rename from live/src/main/assets/icon_livemsgbg_chaohuang.svga rename to common/src/main/assets/icon_livemsgbg_chaohuang.svga diff --git a/live/src/main/assets/icon_livemsgbg_guowang.svga b/common/src/main/assets/icon_livemsgbg_guowang.svga similarity index 100% rename from live/src/main/assets/icon_livemsgbg_guowang.svga rename to common/src/main/assets/icon_livemsgbg_guowang.svga diff --git a/live/src/main/assets/icon_livemsgbg_huangdi.svga b/common/src/main/assets/icon_livemsgbg_huangdi.svga similarity index 100% rename from live/src/main/assets/icon_livemsgbg_huangdi.svga rename to common/src/main/assets/icon_livemsgbg_huangdi.svga diff --git a/common/src/main/java/com/yunbao/common/bean/MsgModel.java b/common/src/main/java/com/yunbao/common/bean/MsgModel.java index 2b623d121..8e48a5e4a 100644 --- a/common/src/main/java/com/yunbao/common/bean/MsgModel.java +++ b/common/src/main/java/com/yunbao/common/bean/MsgModel.java @@ -1,6 +1,9 @@ package com.yunbao.common.bean; +import android.text.TextUtils; + import com.google.gson.annotations.SerializedName; +import com.yunbao.common.views.weight.FullServiceNotificationView; public class MsgModel extends BaseModel { /** @@ -19,7 +22,7 @@ public class MsgModel extends BaseModel { @SerializedName("user_name") private String userName = ""; @SerializedName("noble_id") - private long nobleId = 0; + private String nobleId = ""; @SerializedName("trumpet_msg") private String trumpetMsg = ""; @SerializedName("anchor_id") @@ -52,11 +55,11 @@ public class MsgModel extends BaseModel { return this; } - public long getNobleId() { + public String getNobleId() { return nobleId; } - public MsgModel setNobleId(long nobleId) { + public MsgModel setNobleId(String nobleId) { this.nobleId = nobleId; return this; } @@ -78,4 +81,27 @@ public class MsgModel extends BaseModel { this.anchorId = anchorId; return this; } + + /** + * 获取贵族等级 + * + * @return + */ + public FullServiceNotificationView.RoleType getRoleType() { + if (TextUtils.isEmpty(nobleId)) { + return null; + } else { + FullServiceNotificationView.RoleType roleType = null; + if (TextUtils.equals(nobleId, "5")) { + roleType = FullServiceNotificationView.RoleType.KING; + } else if (TextUtils.equals(nobleId, "6")) { + roleType = FullServiceNotificationView.RoleType.EMPEROR; + } else if (TextUtils.equals(nobleId, "7")) { + roleType = FullServiceNotificationView.RoleType.BETTER_EMPEROR; + } else { + + } + return roleType; + } + } } diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java index 5d519a4b2..0bc787c92 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/RongcloudIMManager.java @@ -35,9 +35,9 @@ import static com.yunbao.common.CommonAppContext.isReady; */ public class RongcloudIMManager { //融云开发者平台注册app唯一识别符 - public static final String RONG_IM_KEY = "uwd1c0sxu1p71"; +// public static final String RONG_IM_KEY = "uwd1c0sxu1p71"; //测试环境 -// public static final String RONG_IM_KEY = "pvxdm17jpd3hr"; + public static final String RONG_IM_KEY = "pvxdm17jpd3hr"; private static final String CLASSNAME = "RongcloudIMManager"; diff --git a/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java b/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java new file mode 100644 index 000000000..49395e080 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java @@ -0,0 +1,238 @@ +package com.yunbao.common.views.weight; + +import android.animation.ValueAnimator; +import android.content.Context; +import android.graphics.Color; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.view.animation.Animation; +import android.view.animation.AnimationSet; +import android.view.animation.TranslateAnimation; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.opensource.svgaplayer.SVGACallback; +import com.opensource.svgaplayer.SVGADrawable; +import com.opensource.svgaplayer.SVGAImageView; +import com.opensource.svgaplayer.SVGAParser; +import com.opensource.svgaplayer.SVGAVideoEntity; +import com.yunbao.common.R; +import com.yunbao.common.glide.ImgLoader; + +import org.jetbrains.annotations.NotNull; + +import java.lang.reflect.Field; + +/** + * 全服通知 + */ +public class FullServiceNotificationView extends FrameLayout { + private Context mContext; + private View rootView; + private SVGAImageView svagaBc; + private ImageView iconImg; + private TextView gotoRoomView, rcUserText; + private GradientColorTextView rcUserName; + private RoleType type; + private RelativeLayout contextLayout; + private long animationTime = 8600; + private String userName = "熱度卡如何獲得?", userText = "前往「個人中心」-「我的包裹」中,即可使用熱度卡。"; + + public FullServiceNotificationView(@NonNull Context context) { + super(context); + init(context); + } + + public FullServiceNotificationView(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + init(context); + } + + public FullServiceNotificationView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(context); + } + + public FullServiceNotificationView setUserNameAndUserText(String userName, String userText) { + this.userName = userName; + this.userText = userText; + rcUserText.setText(":" + userText); + rcUserName.setGradientColor(Color.parseColor("#FFFFFF"), Color.parseColor("#FFEF00")); + return this; + } + + private void init(Context context) { + mContext = context; + rootView = LayoutInflater.from(mContext).inflate(R.layout.view_full_service_notification, this, true); + svagaBc = rootView.findViewById(R.id.svaga_bc); + iconImg = rootView.findViewById(R.id.icon_img); + gotoRoomView = rootView.findViewById(R.id.goto_room_view); + iconImg = rootView.findViewById(R.id.icon_img); + rcUserName = rootView.findViewById(R.id.rc_user_name); + rcUserText = rootView.findViewById(R.id.rc_user_text); + contextLayout = rootView.findViewById(R.id.context_layout); + gotoRoomView.setVisibility(GONE); + contextLayout.setVisibility(GONE); + + } + + public FullServiceNotificationView setType(RoleType type) { + this.type = type; + switch (type) { + case KING: + ImgLoader.display(mContext, R.mipmap.imng_guowang, iconImg); + setFullServiceStart("icon_livemsgbg_guowang.svga"); + break; + case EMPEROR: + ImgLoader.display(mContext, R.mipmap.img_huangdi, iconImg); + setFullServiceStart("icon_livemsgbg_huangdi.svga"); + break; + case BETTER_EMPEROR: + ImgLoader.display(mContext, R.mipmap.img_chaohuang, iconImg); + setFullServiceStart("icon_livemsgbg_chaohuang.svga"); + break; + } + return this; + } + + private void setFullServiceStart(String svgaName) { + svagaBc.setCallback(svgaCallback); + svagaBc.setLoops(1); + svagaBc.startAnimation(); + new SVGAParser(mContext) + .decodeFromAssets(svgaName, new SVGAParser.ParseCompletion() { + @Override + public void onComplete(@NotNull SVGAVideoEntity svgaVideoEntity) { + svagaBc.setVisibility(VISIBLE); + SVGADrawable imageView = new SVGADrawable(svgaVideoEntity); + svagaBc.setImageDrawable(imageView); + try { + Field mAnimator = svagaBc.getClass().getDeclaredField("mAnimator"); + mAnimator.setAccessible(true); + ValueAnimator animator = (ValueAnimator) mAnimator.get(svagaBc); + animationTime = animator.getDuration(); + System.out.println("播放时间 = " + animator.getDuration()); + } catch (Exception e) { + e.printStackTrace(); + } + svagaBc.startAnimation(); + } + + @Override + public void onError() { + + } + }, null); + } + + private SVGACallback svgaCallback = new SVGACallback() { + @Override + public void onPause() { + + } + + @Override + public void onFinished() { + svagaBc.clear(); + svagaBc.setVisibility(GONE); + gotoRoomView.setVisibility(GONE); + } + + @Override + public void onRepeat() { + + } + + @Override + public void onStep(int frame, double v) { + System.out.println("frame = " + frame); + + if (frame == 12) { + gotoRoomView.setVisibility(VISIBLE); + contextLayout.setVisibility(VISIBLE); + contextLayout.post(() -> { + TranslateAnimation animationTranslate = new TranslateAnimation(0, -contextLayout.getMeasuredWidth(), 0, 0); + AnimationSet animationSet1 = new AnimationSet(true); + animationSet1.addAnimation(animationTranslate); + animationSet1.setFillAfter(true); + animationSet1.setDuration((animationTime - 800) / 2); + animationSet1.setAnimationListener(animationListener); + contextLayout.startAnimation(animationSet1); + }); + } + if (frame == 165) { + gotoRoomView.setVisibility(GONE); + contextLayout.setVisibility(GONE); + } + + + } + }; + + Animation.AnimationListener animationListener = new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { + + } + + @Override + public void onAnimationEnd(Animation animation) { + contextLayout.clearAnimation(); + if (svagaBc.isAnimating()) { + TranslateAnimation animationTranslate = new TranslateAnimation(0, -contextLayout.getMeasuredWidth(), 0, 0); + AnimationSet animationSet1 = new AnimationSet(true); + animationSet1.addAnimation(animationTranslate); + animationSet1.setFillAfter(true); + animationSet1.setDuration((animationTime - 800) / 2); + animationSet1.setAnimationListener(animationListener); + contextLayout.startAnimation(animationSet1); + } + } + + @Override + public void onAnimationRepeat(Animation animation) { + + } + }; + + /** + * 角色类型 + */ + public enum RoleType { + KING("国王", 5), + EMPEROR("皇帝", 6), + BETTER_EMPEROR("超皇", 7); + private String name; + private int type; + + + RoleType(String name, int type) { + this.name = name; + this.type = type; + } + + public String getName() { + return name; + } + + public RoleType setName(String name) { + this.name = name; + return this; + } + + public int getType() { + return type; + } + + public RoleType setType(int type) { + this.type = type; + return this; + } + } +} diff --git a/common/src/main/java/com/yunbao/common/views/weight/GradientColorTextView.java b/common/src/main/java/com/yunbao/common/views/weight/GradientColorTextView.java new file mode 100644 index 000000000..bee9ac748 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/weight/GradientColorTextView.java @@ -0,0 +1,55 @@ +package com.yunbao.common.views.weight; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.LinearGradient; +import android.graphics.Paint; +import android.graphics.Rect; +import android.graphics.Shader; +import android.util.AttributeSet; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatTextView; + +/** + * 文字渐变 + */ +public class GradientColorTextView extends AppCompatTextView { + private LinearGradient mLinearGradient; + private Paint mPaint; + private int mViewWidth = 0; + private Rect mTextBound = new Rect(); + private int fromColor, toColor; + + public GradientColorTextView(@NonNull Context context) { + super(context); + } + + public GradientColorTextView(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public GradientColorTextView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + public void setGradientColor(int fromColor, int toColor) { + this.fromColor = fromColor; + this.toColor = toColor; + } + + @SuppressLint("DrawAllocation") + @Override + protected void onDraw(Canvas canvas) { + mViewWidth = getMeasuredHeight(); + mPaint = getPaint(); + String mTipText = getText().toString(); + mPaint.getTextBounds(mTipText, 0, mTipText.length(), mTextBound); + mLinearGradient = new LinearGradient(0, 0, 0, mViewWidth, + new int[]{fromColor, toColor}, + null, Shader.TileMode.REPEAT); + mPaint.setShader(mLinearGradient); + canvas.drawText(mTipText, getMeasuredWidth() / 2 - mTextBound.width() / 2, getMeasuredHeight() / 2 + mTextBound.height() / 2, mPaint); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/weight/MarqueeTextView.java b/common/src/main/java/com/yunbao/common/views/weight/MarqueeTextView.java index d948d3ffc..a57faf57a 100644 --- a/common/src/main/java/com/yunbao/common/views/weight/MarqueeTextView.java +++ b/common/src/main/java/com/yunbao/common/views/weight/MarqueeTextView.java @@ -1,6 +1,7 @@ package com.yunbao.common.views.weight; import android.content.Context; +import android.graphics.drawable.Drawable; import android.util.AttributeSet; import androidx.annotation.NonNull; @@ -24,4 +25,6 @@ public class MarqueeTextView extends AppCompatTextView { public boolean isFocused() { return true; } + + } diff --git a/live/src/main/res/anim/vice_screen_come_in.xml b/common/src/main/res/anim/vice_screen_come_in.xml similarity index 100% rename from live/src/main/res/anim/vice_screen_come_in.xml rename to common/src/main/res/anim/vice_screen_come_in.xml diff --git a/live/src/main/res/drawable/background_whole_station_horn.xml b/common/src/main/res/drawable/background_whole_station_horn.xml similarity index 100% rename from live/src/main/res/drawable/background_whole_station_horn.xml rename to common/src/main/res/drawable/background_whole_station_horn.xml diff --git a/common/src/main/res/drawable/background_whole_text_station_horn.xml b/common/src/main/res/drawable/background_whole_text_station_horn.xml new file mode 100644 index 000000000..fd4be151a --- /dev/null +++ b/common/src/main/res/drawable/background_whole_text_station_horn.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_full_service_notification.xml b/common/src/main/res/layout/view_full_service_notification.xml new file mode 100644 index 000000000..fcd1f1cb0 --- /dev/null +++ b/common/src/main/res/layout/view_full_service_notification.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_whole_station_horn.xml b/common/src/main/res/layout/view_whole_station_horn.xml new file mode 100644 index 000000000..015fdee0d --- /dev/null +++ b/common/src/main/res/layout/view_whole_station_horn.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/mipmap-xxxhdpi/img_chaohuang.png b/common/src/main/res/mipmap-xxhdpi/img_chaohuang.png similarity index 100% rename from live/src/main/res/mipmap-xxxhdpi/img_chaohuang.png rename to common/src/main/res/mipmap-xxhdpi/img_chaohuang.png diff --git a/live/src/main/res/mipmap-xxxhdpi/img_huangdi.png b/common/src/main/res/mipmap-xxhdpi/img_huangdi.png similarity index 100% rename from live/src/main/res/mipmap-xxxhdpi/img_huangdi.png rename to common/src/main/res/mipmap-xxhdpi/img_huangdi.png diff --git a/live/src/main/res/mipmap-xxxhdpi/imng_guowang.png b/common/src/main/res/mipmap-xxhdpi/imng_guowang.png similarity index 100% rename from live/src/main/res/mipmap-xxxhdpi/imng_guowang.png rename to common/src/main/res/mipmap-xxhdpi/imng_guowang.png diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java index daca96ade..ad6bd8159 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -695,23 +695,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL @Override public void onLinkMicPkStart(final String pkUid, final String pkhead, final String pkname) { Log.e("ry", "pkUid" + pkUid + "pkhead" + pkhead + "pkname" + pkname); -// if (isRy == false) { -// if (mLiveLinkMicPkPresenter != null && mLiveRoomViewHolder != null) { -// mLiveLinkMicPkPresenter.onLinkMicPkStart(pkUid, pkhead, pkname); -// Handler handler = new Handler(); -// handler.postDelayed(new Runnable() { -// @Override -// public void run() { -// if (mLiveRoomViewHolder != null) { -// if (mIsAnchor == false) { -// mLiveRoomViewHolder.setOtherInfo(pkUid, pkhead, pkname); -// } -// } -// } -// }, 4000);//3秒后执行Runnable中的run方法 -// -// } -// } else { if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) { mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1); Handler handler = new Handler(); @@ -728,7 +711,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL }, 4000);//3秒后执行Runnable中的run方法 } -// } } @@ -737,16 +719,10 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL */ @Override public void onLinkMicPkClose(int i) { -// if (isRy == false) { -// if (mLiveLinkMicPkPresenter != null) { -// mLiveLinkMicPkPresenter.onLinkMicPkClose(i); -// } -// } else { if (mLiveRyLinkMicPkPresenter != null) { mLiveRyLinkMicPkPresenter.onLinkMicPkClose(i); } else if (mLiveLinkMicPkPresenter != null) { mLiveLinkMicPkPresenter.onLinkMicPkClose(i); -// } } } @@ -779,12 +755,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL */ @Override public void onLinkMicPkEnd(String winUid) { -// if (isRy == false) { -// if (mLiveLinkMicPkPresenter != null) { -// mLiveLinkMicPkPresenter.onLinkMicPkEnd(winUid); -// mLiveRoomViewHolder.setDelOtherInfo(); -// } -// } else { if (mLiveRyLinkMicPkPresenter != null) { mLiveRyLinkMicPkPresenter.onLinkMicPkEnd(winUid); mLiveRoomViewHolder.setDelOtherInfo(); @@ -792,7 +762,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL mLiveLinkMicPkPresenter.onLinkMicPkEnd(winUid); mLiveRoomViewHolder.setDelOtherInfo(); } -// } } @@ -945,11 +914,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL onCoinChanged(coin); } String[] data = new String[]{obj.getString("barragetoken")}; -// if (isRy == false) { -// SocketChatUtil.sendDanmuMessage(mLiveUid, contents); -// } else { SocketRyChatUtil.sendDanmuMessage(mLiveUid, contents); -// } } else { ToastUtil.show(msg); } @@ -969,22 +934,14 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL } } int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE; -// if (isRy == false) { -// SocketChatUtil.sendChatMessage(mLiveUid, content, mIsAnchor, mSocketUserType, guardType); -// } else { SocketRyChatUtil.sendChatMessage(mLiveUid, content, mIsAnchor, mSocketUserType, guardType); -// } } /** * 发 系统 消息 */ public static void sendSystemMessage(String content) { -// if (isRy == false) { -// SocketChatUtil.sendSystemMessage(mLiveUid, content); -// } else { SocketRyChatUtil.sendSystemMessage(mLiveUid, content); -// } } @@ -993,12 +950,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL */ public void sendGiftMessage(LiveGiftBean giftBean, String giftToken, String ancherName, String by) { int guardType = mLiveGuardInfo != null ? mLiveGuardInfo.getMyGuardType() : Constants.GUARD_TYPE_NONE; - -// if (isRy == false) { -// SocketChatUtil.sendGiftMessage(giftBean.getType(), giftToken, mLiveUid, ancherName, guardType, by); -// } else { SocketRyChatUtil.sendGiftMessage(giftBean.getType(), giftToken, mLiveUid, ancherName, guardType, by); -// } } @@ -1006,33 +958,21 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL * 主播或管理员踢人 */ public void kickUser(String toUid, String toName) { -// if (isRy == false) { -// SocketChatUtil.sendKickMessage(mLiveUid, toUid, toName); -// } else { SocketRyChatUtil.sendKickMessage(mLiveUid, toUid, toName); -// } } /** * 禁言 */ public void setShutUp(String toUid, String toName, int type) { -// if (isRy == false) { -// SocketChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type); -// } else { SocketRyChatUtil.sendShutUpMessage(mLiveUid, toUid, toName, type); -// } } /** * 设置或取消管理员消息 */ public void sendSetAdminMessage(int action, String toUid, String toName) { -// if (isRy == false) { -// SocketChatUtil.sendSetAdminMessage(mLiveUid, action, toUid, toName); -// } else { SocketRyChatUtil.sendSetAdminMessage(mLiveUid, action, toUid, toName); -// } } @@ -1040,22 +980,14 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL * 超管关闭直播间 */ public void superCloseRoom() { -// if (isRy == false) { -// SocketChatUtil.superCloseRoom(mLiveUid); -// } else { SocketRyChatUtil.superCloseRoom(mLiveUid); -// } } /** * 更新主播映票数 */ public void sendUpdateVotesMessage(int deltaVal) { -// if (isRy == false) { -// SocketChatUtil.sendUpdateVotesMessage(mLiveUid, deltaVal); -// } else { SocketRyChatUtil.sendUpdateVotesMessage(mLiveUid, deltaVal); -// } } @@ -1063,20 +995,12 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL * 发送购买守护成功消息 */ public void sendBuyGuardMessage(String votes, int guardNum, int guardType) { -// if (isRy == false) { -// SocketChatUtil.sendBuyGuardMessage(mLiveUid, votes, guardNum, guardType); -// } else { SocketRyChatUtil.sendBuyGuardMessage(mLiveUid, votes, guardNum, guardType); -// } } public void sendBuyGuardMessage2(String votes, int guardNum, int guardType, String ancherName, String liveId) { if (guardType != 1) { -// if (isRy == false) { -// SocketChatUtil.sendBuyGuardMessage2(mLiveUid, votes, guardNum, guardType, ancherName, liveId); -// } else { SocketRyChatUtil.sendBuyGuardMessage2(mLiveUid, votes, guardNum, guardType, ancherName, liveId); -// } } } @@ -1084,11 +1008,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL * 发送发红包成功消息 */ public void sendRedPackMessage() { -// if (isRy == false) { -// SocketChatUtil.sendRedPackMessage(mLiveUid); -// } else { SocketRyChatUtil.sendRedPackMessage(mLiveUid); -// } } @@ -1196,8 +1116,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL public void onItemClick(String type) { if (Constants.LINK.equals(type)) { copyLink(); - } else { -// shareLive(type, null); } } @@ -1271,9 +1189,9 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL @Override public void onSuccess(int code, String msg, String[] info) { List list = JSON.parseArray(Arrays.toString(info), GuardUserBean.class); - if(list.isEmpty()){ + if (list.isEmpty()) { openNewBuyGuardWindow(true); - }else { + } else { LiveNewGuardListDialogFragment fragment = new LiveNewGuardListDialogFragment(); fragment.setList(list); fragment.setLiveGuardInfo(mLiveGuardInfo); @@ -1353,7 +1271,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL bundle.putString(Constants.STREAM, mStream); bundle.putString(Constants.LIVE_ANCHER_ICON, mAncherIcon); bundle.putString(Constants.USER_ICON, CommonAppConfig.getInstance().getUserBean().getAvatar()); - bundle.putBoolean("guard",isEmpty); + bundle.putBoolean("guard", isEmpty); fragment.setArguments(bundle); fragment.show(getSupportFragmentManager(), "LiveGuardBuyDialogFragment"); } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 68578c0a2..6856e207f 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -577,7 +577,6 @@ public class LiveAudienceActivity extends LiveActivity { if (verticalViewPager.ismEnableScroll()) { LiveBean liveBean = e.getLiveBean(); if (liveBean != null) { - LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE); LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM); LiveHttpUtil.cancel(LiveHttpConsts.ROOM_CHARGE); @@ -590,13 +589,10 @@ public class LiveAudienceActivity extends LiveActivity { mAncherName = liveBean.getUserNiceName(); mAncherIcon = liveBean.getAvatar(); manager.onAdd(liveBean, mLiveType, mLiveTypeVal, mLiveSDK); - } } else { verticalViewPager.setEnableScroll(true); } - - } @Override @@ -774,11 +770,6 @@ public class LiveAudienceActivity extends LiveActivity { verticalViewPager.setCurrentItem(mCurrentPage + 1); break; case REFRESH_THE_LIVEl_PAGE: -// loadingView.show(); -// AnchorRecommendItemModel model = event.getAnchorRecommendItemModel(); -// itemModelList.add(0, model); -// mPagerAdapter.notifyDataSetChanged(); -// verticalViewPager.setCurrentItem(0); getDrawer(); break; case REPORT: @@ -802,6 +793,9 @@ public class LiveAudienceActivity extends LiveActivity { case ONLINE: toSysMsgWeb("3"); break; + case TRUMPET_NOTIFY: + manager.showFullScreen(event.getMsgModel()); + break; } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java index 53207a66d..cba6260cd 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java @@ -171,7 +171,7 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O //单选选中监听 radioHornType.setOnCheckedChangeListener(changeListener); radioHornType.getCheckedRadioButtonId(); -// netHandler.post(getNobleTrumpetNumRunnable); + netHandler.post(getNobleTrumpetNumRunnable); } @Override diff --git a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java index df87443dc..42f04d017 100644 --- a/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java +++ b/live/src/main/java/com/yunbao/live/event/LiveAudienceEvent.java @@ -3,6 +3,7 @@ package com.yunbao.live.event; import com.yunbao.common.bean.ActiveModel; import com.yunbao.common.bean.AnchorRecommendItemModel; import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.bean.MsgModel; import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.OpenParametersModel; @@ -16,7 +17,16 @@ public class LiveAudienceEvent extends BaseModel { private LiveBean bean; private int liveType; private int liveTypeVal; + private MsgModel msgModel;//全服消息 + public MsgModel getMsgModel() { + return msgModel; + } + + public LiveAudienceEvent setMsgModel(MsgModel msgModel) { + this.msgModel = msgModel; + return this; + } public int getLiveType() { return liveType; @@ -118,7 +128,8 @@ public class LiveAudienceEvent extends BaseModel { REPORT(16, "舉報"), POPULAR(17, "人气票任务"), NOTICE(18, "系统通知"), - ONLINE(19, "在线客服"); + ONLINE(19, "在线客服"), + TRUMPET_NOTIFY(20, "全服喇叭"); private int type; private String name; diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index ae560eebc..05c0657ff 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -19,6 +19,7 @@ import com.yunbao.common.bean.SocketModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.L; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; @@ -35,6 +36,7 @@ import com.yunbao.live.bean.LiveLuckGiftWinBean; import com.yunbao.live.bean.LivePKUserListBean; import com.yunbao.live.bean.LiveReceiveGiftBean; import com.yunbao.live.bean.LiveUserGiftBean; +import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.views.LiveEndViewHolder; import com.yunbao.live.views.LivePlayKsyViewHolder; import com.yunbao.live.views.LivePlayRyViewHolder; @@ -369,7 +371,7 @@ public class SocketRyClient { mListener.onPrizePoolUp(map.getString("uplevel")); break; case Constants.SOCKET_HOUR://小时榜 - liveChatBean=new LiveChatBean(); + liveChatBean = new LiveChatBean(); liveChatBean.setId("-1"); liveChatBean.setType(LiveChatAdapter.MSG_HOUR_RANK_CHANGE); liveChatBean.setContent(map.getJSONObject("ct").getString("text")); @@ -451,7 +453,10 @@ public class SocketRyClient { SocketModel model = GsonUtils.fromJson(socketMsg, SocketModel.class); List msg = model.getMsg(); if (msg.size() > 0) { - EventBus.getDefault().post(msg.get(0)); +// EventBus.getDefault().post(msg.get(0)); + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.TRUMPET_NOTIFY) + .setMsgModel(msg.get(0))); } break; } diff --git a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java index 3a96bd73d..c7c87f475 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveAudienceViewHolder.java @@ -20,14 +20,12 @@ import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.ViewFlipper; -import com.opensource.svgaplayer.SVGACallback; import com.opensource.svgaplayer.SVGADrawable; import com.opensource.svgaplayer.SVGAImageView; import com.opensource.svgaplayer.SVGAParser; import com.opensource.svgaplayer.SVGAVideoEntity; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; -import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.NewPeopleInfo; import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.glide.ImgLoader; @@ -70,7 +68,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { private String url; private View v_msg_redpoint, stationHornBanner; private Activity context; - private SVGAImageView svga_new_user_gif, svga_new_user_double, svga_new_user_follow, svga_station_horn; + private SVGAImageView svga_new_user_gif, svga_new_user_double, svga_new_user_follow; private ViewFlipper viewFlipper; private TextView goToRomm; private int icon = 0; @@ -191,7 +189,6 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { svga_new_user_gif = (SVGAImageView) findViewById(R.id.svga_new_user_gif); svga_new_user_double = (SVGAImageView) findViewById(R.id.svga_new_user_double); svga_new_user_follow = (SVGAImageView) findViewById(R.id.svga_new_user_follow); - svga_station_horn = (SVGAImageView) findViewById(R.id.svga_station_horn); viewFlipper = (ViewFlipper) findViewById(R.id.viewflipper_banner); stationHornBanner = findViewById(R.id.station_horn_banner); liveNewPeople.setOnClickListener(this); @@ -239,65 +236,7 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { v_msg_redpoint = (View) findViewById(R.id.v_msg_redpoint); //获取系统未读消息 MessageIMManager.get(mContext).getSystemMessages(); - //全站喇叭 - svga_station_horn.setCallback(new SVGACallback() { - @Override - public void onPause() { - } - - @Override - public void onFinished() { - - } - - @Override - public void onRepeat() { - - } - - @Override - public void onStep(int frame, double percentage) { - Log.e("SVGADynamicEntity", "frame:" + frame); - Log.e("SVGADynamicEntity", "percentage:" + percentage); - if ((int) (percentage * 100) == 5) { - viewFlipper.removeAllViews(); - stationHornBanner.setVisibility(View.VISIBLE); - if ((nobleName + nobleTtext).length() > 15) { - - for (int i = 0; i < 2; i++) { - //展示内容子布局 - View childrenView = LayoutInflater.from(mContext).inflate(R.layout.view_whole_station_horn, null, false); - ImageView iconImg = childrenView.findViewById(R.id.icon_img); - TextView userName = childrenView.findViewById(R.id.rc_user_name); - TextView userText = childrenView.findViewById(R.id.rc_user_text); - userName.setText(nobleName); - userText.setText(" : " + nobleTtext); - ImgLoader.display2(mContext, icon, iconImg); - viewFlipper.addView(childrenView); - } - - } else { - //展示内容子布局 - View childrenView = LayoutInflater.from(mContext).inflate(R.layout.view_whole_station_horn, null, false); - ImageView iconImg = childrenView.findViewById(R.id.icon_img); - TextView userName = childrenView.findViewById(R.id.rc_user_name); - TextView userText = childrenView.findViewById(R.id.rc_user_text); - userName.setText(nobleName); - userText.setText(" : " + nobleTtext); - ImgLoader.display2(mContext, icon, iconImg); - viewFlipper.addView(childrenView); - } - - } - if ((int) (percentage * 100) == 50 && viewFlipper.getChildCount() > 1) { - viewFlipper.showNext(); - } - if ((int) (percentage * 100) == 92) { - stationHornBanner.setVisibility(View.GONE); - } - } - }); //底部改造 ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.total_image), new ViewClicksAntiShake.ViewClicksCallBack() { @Override @@ -440,7 +379,8 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { public void onMessageIMEvent(MessageIMEvent event) { //判断消息中心红点是否已经展示,如果已经展示并且未读消息大于0则不再执行之后的逻辑 int number = event.getMessage(); - if (v_msg_redpoint.getVisibility() == View.VISIBLE && number > 0 || SpUtil.getInstance().getBooleanValue("private_chat_message_switch")) return; + if (v_msg_redpoint.getVisibility() == View.VISIBLE && number > 0 || SpUtil.getInstance().getBooleanValue("private_chat_message_switch")) + return; if (number > 0) { v_msg_redpoint.setVisibility(View.VISIBLE); } else { @@ -520,41 +460,5 @@ public class LiveAudienceViewHolder extends AbsLiveViewHolder { return bitmap; } - /** - * 全站喇叭 - */ - @Subscribe(threadMode = ThreadMode.MAIN) - public void onMsgModelEvent(MsgModel model) { - nobleName = model.getUserName(); - nobleTtext = model.getTrumpetMsg(); - if (!svga_station_horn.isAnimating()) { - svga_station_horn.setLoops(1); - String backPath = ""; - if (model.getNobleId() == 5) { - backPath = "icon_livemsgbg_guowang.svga"; - icon = R.mipmap.imng_guowang; - } else if (model.getNobleId() == 6) { - backPath = "icon_livemsgbg_huangdi.svga"; - icon = R.mipmap.img_huangdi; - } else { - backPath = "icon_livemsgbg_chaohuang.svga"; - icon = R.mipmap.img_chaohuang; - } - new SVGAParser(mContext).decodeFromAssets(backPath, new SVGAParser.ParseCompletion() { - @Override - public void onComplete(SVGAVideoEntity videoItem) { - SVGADrawable drawable = new SVGADrawable(videoItem); - svga_station_horn.setImageDrawable(drawable); - svga_station_horn.startAnimation(); - } - - @Override - public void onError() { - Log.e("errqs", "errl"); - } - }, null); - } - - } } diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index b4f57a372..36c08a244 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -58,6 +58,7 @@ import com.yunbao.common.bean.BannerBean; import com.yunbao.common.bean.HourRank; import com.yunbao.common.bean.LevelBean; import com.yunbao.common.bean.LiveGiftBean; +import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.API; @@ -78,6 +79,7 @@ import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.formatBigNum; import com.yunbao.common.views.AbsViewHolder; +import com.yunbao.common.views.weight.FullServiceNotificationView; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.R; import com.yunbao.live.activity.LiveActivity; @@ -282,6 +284,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis private ConstraintLayout msgLayout; //悬浮窗 private TextView msgNumber;//悬浮窗左上角数标 private RoundedImageView msgUserIcon; //悬浮窗icon + private FullServiceNotificationView fullScreen;//全副喇叭 public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) { super(context, parentView); @@ -605,6 +608,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void init() { EventBus.getDefault().register(this); btnEvent = findViewById(R.id.btn_event); + fullScreen = (FullServiceNotificationView) findViewById(R.id.full_screen); btnEvent3 = findViewById(R.id.btn_event3); imgEvent = (ImageView) findViewById(R.id.img_event); btn_event2 = (LinearLayout) findViewById(R.id.btn_event2); @@ -731,7 +735,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis findViewById(R.id.hot_btn).setOnClickListener(this); try { Glide.with(mContext).asGif().load(R.drawable.fans_medal).into(mViewMedal); - }catch (Exception e){ + } catch (Exception e) { System.err.println("发生异常行为"); e.printStackTrace(); } @@ -1708,7 +1712,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } else if (i == R.id.user_guard) { // ((LiveActivity) mContext).openUserMoreListWindow(2, true); ((LiveActivity) mContext).openNewGuardListWindow(); - } if (i == R.id.lt_trickery) { + } + if (i == R.id.lt_trickery) { showTrickeryDialog(); } @@ -1800,7 +1805,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void onSuccess(List conversations) { if (conversations != null && !conversations.isEmpty()) { for (Conversation conversation : conversations) { - if(conversation.getUnreadMessageCount()!=0){ + if (conversation.getUnreadMessageCount() != 0) { UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(conversation.getTargetId()); if (userInfo != null) { ImgLoader.display(mContext, userInfo.getPortraitUri().toString(), msgUserIcon); @@ -1809,7 +1814,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } } - changeMsgView(msg2,msg); + changeMsgView(msg2, msg); } @Override @@ -2873,4 +2878,13 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } + /** + * 全服喇叭 + * + * @param msgModel + */ + public void showFullScreen(MsgModel msgModel) { + fullScreen.setUserNameAndUserText(msgModel.getUserName(), msgModel.getTrumpetMsg()) + .setType(msgModel.getRoleType()); + } } diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 0047042d2..43d51d0d1 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -31,6 +31,7 @@ import com.tencent.imsdk.v2.V2TIMManager; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; +import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.UserBean; import com.yunbao.common.custom.MyViewPager; import com.yunbao.common.event.FollowEvent; @@ -535,7 +536,7 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } - //是否处于返回键 + //是否处于返回键 全服通知 private boolean isBackPressed = false; @Override @@ -1514,4 +1515,13 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe } + /** + * 全服喇叭 + * + * @param msgModel + */ + public void showFullScreen(MsgModel msgModel) { + mLiveRoomViewHolder.showFullScreen(msgModel); + } + } diff --git a/live/src/main/res/layout/dialog_live_chat_input.xml b/live/src/main/res/layout/dialog_live_chat_input.xml index f0c1a9e81..e0d7805ca 100644 --- a/live/src/main/res/layout/dialog_live_chat_input.xml +++ b/live/src/main/res/layout/dialog_live_chat_input.xml @@ -58,7 +58,7 @@ android:drawableStart="@mipmap/icon_world_horn" android:text="@string/whole_station_horn" android:textColor="#FFB1B6C7" - android:visibility="gone" + android:visibility="visible" android:textSize="12sp" /> + + - + android:layout_height="30dp"> + @@ -2077,5 +2079,10 @@ + \ No newline at end of file diff --git a/live/src/main/res/layout/view_whole_station_horn.xml b/live/src/main/res/layout/view_whole_station_horn.xml deleted file mode 100644 index e0fcbec6f..000000000 --- a/live/src/main/res/layout/view_whole_station_horn.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/live/src/main/res/layout/view_whole_station_horn_layout.xml b/live/src/main/res/layout/view_whole_station_horn_layout.xml index a74ff911b..58faae0a7 100644 --- a/live/src/main/res/layout/view_whole_station_horn_layout.xml +++ b/live/src/main/res/layout/view_whole_station_horn_layout.xml @@ -24,7 +24,6 @@ android:layout_marginTop="8dp" android:layout_marginEnd="9dp" android:layout_marginBottom="5dp" - android:background="@drawable/background_whole_station_horn" android:paddingLeft="7dp" android:paddingTop="3dp" android:paddingRight="7dp" From 169bf74f31bd0efa0de1dde8dbe26e868f5f10df Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 14 Sep 2022 18:29:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=85=A8=E7=AB=99=E5=96=87=E5=8F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weight/FullServiceNotificationView.java | 49 +++++++++++++++---- .../yunbao/live/views/LiveRoomViewHolder.java | 43 +++++++++++++++- 2 files changed, 82 insertions(+), 10 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java b/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java index 49395e080..d4ca2674d 100644 --- a/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java +++ b/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java @@ -43,6 +43,7 @@ public class FullServiceNotificationView extends FrameLayout { private RelativeLayout contextLayout; private long animationTime = 8600; private String userName = "熱度卡如何獲得?", userText = "前往「個人中心」-「我的包裹」中,即可使用熱度卡。"; + private String anchorId = ""; public FullServiceNotificationView(@NonNull Context context) { super(context); @@ -64,6 +65,12 @@ public class FullServiceNotificationView extends FrameLayout { this.userText = userText; rcUserText.setText(":" + userText); rcUserName.setGradientColor(Color.parseColor("#FFFFFF"), Color.parseColor("#FFEF00")); + rcUserName.setText(userName); + return this; + } + + public FullServiceNotificationView setAnchorId(String anchorId) { + this.anchorId = anchorId; return this; } @@ -79,6 +86,16 @@ public class FullServiceNotificationView extends FrameLayout { contextLayout = rootView.findViewById(R.id.context_layout); gotoRoomView.setVisibility(GONE); contextLayout.setVisibility(GONE); + //点击跳转直播间 + gotoRoomView.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + + if (callBack != null) { + callBack.goToLive(); + } + } + }); } @@ -156,15 +173,18 @@ public class FullServiceNotificationView extends FrameLayout { if (frame == 12) { gotoRoomView.setVisibility(VISIBLE); contextLayout.setVisibility(VISIBLE); - contextLayout.post(() -> { - TranslateAnimation animationTranslate = new TranslateAnimation(0, -contextLayout.getMeasuredWidth(), 0, 0); - AnimationSet animationSet1 = new AnimationSet(true); - animationSet1.addAnimation(animationTranslate); - animationSet1.setFillAfter(true); - animationSet1.setDuration((animationTime - 800) / 2); - animationSet1.setAnimationListener(animationListener); - contextLayout.startAnimation(animationSet1); - }); + if ((userName.length()+userText.length())>13){ + contextLayout.post(() -> { + TranslateAnimation animationTranslate = new TranslateAnimation(0, -contextLayout.getMeasuredWidth(), 0, 0); + AnimationSet animationSet1 = new AnimationSet(true); + animationSet1.addAnimation(animationTranslate); + animationSet1.setFillAfter(true); + animationSet1.setDuration((animationTime - 800) / 2); + animationSet1.setAnimationListener(animationListener); + contextLayout.startAnimation(animationSet1); + }); + } + } if (frame == 165) { gotoRoomView.setVisibility(GONE); @@ -235,4 +255,15 @@ public class FullServiceNotificationView extends FrameLayout { return this; } } + + private FullServiceNotificationViewCallBack callBack; + + public FullServiceNotificationView setCallBack(FullServiceNotificationViewCallBack callBack) { + this.callBack = callBack; + return this; + } + + public interface FullServiceNotificationViewCallBack { + void goToLive(); + } } diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 36c08a244..80cd7e821 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -91,6 +91,7 @@ import com.yunbao.live.adapter.LiveChatAdapter; import com.yunbao.live.adapter.LiveRoomFastMessageRecyclerViewAdapter; import com.yunbao.live.adapter.LiveUserAdapter; import com.yunbao.live.bean.DrPkbean; +import com.yunbao.live.bean.LiveBean; import com.yunbao.live.bean.LiveBuyGuardMsgBean; import com.yunbao.live.bean.LiveChatBean; import com.yunbao.live.bean.LiveDanMuBean; @@ -110,12 +111,14 @@ import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveUserDialogFragment; import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience; import com.yunbao.live.event.LiveAudienceEvent; +import com.yunbao.live.event.LiveRoomChangeEvent; import com.yunbao.live.http.LiveHttpConsts; import com.yunbao.live.http.LiveHttpUtil; import com.yunbao.live.presenter.LiveDanmuPresenter; import com.yunbao.live.presenter.LiveEnterRoomAnimPresenter; import com.yunbao.live.presenter.LiveGiftAnimPresenter; import com.yunbao.live.presenter.LiveLightAnimPresenter; +import com.yunbao.live.presenter.LiveRoomCheckLivePresenter; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -2885,6 +2888,44 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis */ public void showFullScreen(MsgModel msgModel) { fullScreen.setUserNameAndUserText(msgModel.getUserName(), msgModel.getTrumpetMsg()) - .setType(msgModel.getRoleType()); + .setType(msgModel.getRoleType()) + .setCallBack(() -> gotoLive(msgModel.getAnchorId())); + } + + /** + * 前往直播间 + */ + private void gotoLive(final String liveId) { + LiveHttpUtil.getLiveInfo(liveId, new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + if (code == 0 && info.length > 0) { + LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class); + LiveRoomCheckLivePresenter mCheckLivePresenter = new LiveRoomCheckLivePresenter(mContext, (liveBean1, liveType, liveTypeVal, liveSdk) -> { + if (liveBean1 == null) { + return; + } + if (LivePlayRyViewHolder.Micing == 1) { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.LIAN_MAI) + .setMicIng(1) + .setBean(liveBean).setLiveType(liveType).setLiveTypeVal(liveTypeVal)); + } else if (LivePlayRyViewHolder.Micing == 2) { + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.LIAN_MAI) + .setMicIng(2) + .setBean(liveBean).setLiveType(liveType).setLiveTypeVal(liveTypeVal)); + } else { + EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, liveTypeVal)); + } + + }); + mCheckLivePresenter.checkLive(liveBean); + + } else { + RouteUtil.forwardUserHome(mContext, liveId, 0); + } + } + }); } } From 0af40fa7e5d0ad85eb27bd9988598caa104d8098 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 15 Sep 2022 10:40:15 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=85=A8=E7=AB=99=E5=96=87=E5=8F=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/yunbao/common/http/live/LiveNetManager.java | 2 +- .../yunbao/common/views/weight/FullServiceNotificationView.java | 1 + .../java/com/yunbao/live/dialog/LiveInputDialogFragment.java | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 9273db11c..58a5c0393 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -75,7 +75,7 @@ public class LiveNetManager { callback.onSuccess(baseModelResponseModel.getData().getInfo()); } else { if (callback != null) - callback.onError("发送失败"); + callback.onError(baseModelResponseModel.getData().getMsg()); } }, throwable -> { if (callback != null) diff --git a/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java b/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java index d4ca2674d..9b2d3b39e 100644 --- a/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java +++ b/common/src/main/java/com/yunbao/common/views/weight/FullServiceNotificationView.java @@ -159,6 +159,7 @@ public class FullServiceNotificationView extends FrameLayout { svagaBc.clear(); svagaBc.setVisibility(GONE); gotoRoomView.setVisibility(GONE); + contextLayout.setVisibility(GONE); } @Override diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java index cba6260cd..7b8b20b47 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveInputDialogFragment.java @@ -199,6 +199,8 @@ public class LiveInputDialogFragment extends AbsDialogFragment implements View.O @Override public void onError(String error) { + dismiss(); + ToastUtil.show(error); } }); break;